@aiquants/resize-panels 1.8.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2009 @@
1
+ import { createContext as er, useContext as tr, useCallback as ge, useMemo as j, useReducer as rr, useState as Te, useRef as _, useEffect as K, useLayoutEffect as St, memo as yt, useId as Ut, Suspense as ir, lazy as nr } from "react";
2
+ import { jsx as me, jsxs as Ze } from "react/jsx-runtime";
3
+ import { twMerge as at } from "tailwind-merge";
4
+ const jt = er(null), Mt = () => {
5
+ const e = tr(jt);
6
+ if (!e)
7
+ throw new Error("usePanelGroup must be used within a PanelGroup");
8
+ return e;
9
+ }, vt = (e, t = 0) => {
10
+ if (!Number.isFinite(e))
11
+ return e;
12
+ const n = 10 ** t, d = e * n, r = Math.floor(d), s = d - r, i = Number.EPSILON * Math.max(1, Math.abs(d));
13
+ return s < 0.5 - i ? r / n : s > 0.5 + i ? (r + 1) / n : (r % 2 === 0 ? r : r + 1) / n;
14
+ }, or = 12, sr = 8, ar = 6, lr = 48, cr = 80, dr = 2, ur = 32, fr = 64, pr = 8, hr = 8, _t = 10, Wt = 0.05, Vt = 10, zr = 0.05, gr = 20, mr = 0.05, kt = 0, Zt = 6, Fe = (e, t) => t <= 0 ? 0 : vt(e / t * 100, Zt), st = (e, t) => !e || t <= 0 ? 0 : e / 100 * t, Sr = (e, t = "percentage") => {
15
+ if (e !== void 0)
16
+ return typeof e == "number" ? { value: e, unit: t } : e;
17
+ }, G = (e, t, n) => e ? typeof e == "number" ? e / 100 * n : e.unit === "pixels" ? e.value : e.value / 100 * n : t, ye = (e, t, n) => Math.min(Math.max(e, t), n), Ct = (e) => {
18
+ if (!Number.isFinite(e) || e <= 0)
19
+ return kt;
20
+ const t = e * Wt, n = Math.min(or, Vt, t);
21
+ return Math.max(kt, n);
22
+ }, Kt = (e, t, n, d = {}) => {
23
+ if (Math.abs(t) <= 0)
24
+ return t;
25
+ const r = d.enforceAutoMinSize ?? !1, s = e.map((a, u) => ({ panel: a, index: u })).filter(({ panel: a }) => !a.collapsed && (a.sizeUnit === "pixels" || a.originalPixelSize !== void 0));
26
+ if (s.length === 0)
27
+ return t;
28
+ const i = t > 0, f = [...s].sort((a, u) => {
29
+ const l = a.panel.pixelAdjustPriority ?? a.index + 1, z = u.panel.pixelAdjustPriority ?? u.index + 1;
30
+ return l === z ? i ? u.index - a.index : a.index - u.index : i ? z - l : l - z;
31
+ });
32
+ let h = t;
33
+ const p = (a) => {
34
+ for (const { index: u } of f) {
35
+ if (Math.abs(h) <= 0)
36
+ break;
37
+ const l = e[u];
38
+ if (!l || l.collapsed)
39
+ continue;
40
+ const z = G(l.minSize, 0, n), m = G(l.maxSize, n, n), x = r ? G(l.autoMinSize, 0, n) : 0, b = Math.max(z, x), N = l.preferredPixelSize !== void 0 ? ye(l.preferredPixelSize, b, m) : l.size, k = l.collapseFromStart || l.collapseFromEnd;
41
+ if (h > 0) {
42
+ if (Math.abs(l.size) <= 0 && (l.percentageSize ?? 0) <= 0)
43
+ continue;
44
+ const W = Math.max(l.size, N), ce = a ? Math.min(m, W) : m, te = Math.max(0, ce - l.size);
45
+ if (te <= 0)
46
+ continue;
47
+ const oe = Math.min(te, h);
48
+ if (oe <= 0)
49
+ continue;
50
+ const $ = l.size + oe, A = Fe($, n), y = k ? $ : l.sizeBeforeCollapse, D = k ? l.measuredPixelSizeBeforeCollapse ?? l.measuredPixelSize ?? $ : l.measuredPixelSizeBeforeCollapse;
51
+ e[u] = {
52
+ ...l,
53
+ size: $,
54
+ percentageSize: A,
55
+ sizeBeforeCollapse: y,
56
+ measuredPixelSizeBeforeCollapse: D,
57
+ measuredPixelSize: void 0,
58
+ measuredPercentageSize: void 0
59
+ }, h -= oe;
60
+ } else {
61
+ const I = a ? N : b, W = Math.max(0, l.size - I);
62
+ if (W <= 0)
63
+ continue;
64
+ const ce = Math.min(W, Math.abs(h));
65
+ if (ce <= 0)
66
+ continue;
67
+ const te = l.size - ce, oe = Fe(te, n), $ = k ? te : l.sizeBeforeCollapse, A = k ? l.measuredPixelSizeBeforeCollapse ?? l.measuredPixelSize ?? te : l.measuredPixelSizeBeforeCollapse;
68
+ e[u] = {
69
+ ...l,
70
+ size: te,
71
+ percentageSize: oe,
72
+ sizeBeforeCollapse: $,
73
+ measuredPixelSizeBeforeCollapse: A,
74
+ measuredPixelSize: void 0,
75
+ measuredPercentageSize: void 0
76
+ }, h += ce;
77
+ }
78
+ }
79
+ };
80
+ return p(!0), (i && h > 0 || !i && h < 0) && p(!1), h;
81
+ }, ht = (e) => {
82
+ if (!e)
83
+ return 0;
84
+ const t = parseFloat(e);
85
+ return Number.isFinite(t) ? t : 0;
86
+ }, Ye = (e, t) => {
87
+ const n = e.getBoundingClientRect(), d = typeof window < "u" ? window.getComputedStyle(e) : null, r = d ? ht(d.borderLeftWidth) + ht(d.borderRightWidth) : 0, s = d ? ht(d.borderTopWidth) + ht(d.borderBottomWidth) : 0;
88
+ if (t === "horizontal") {
89
+ const p = n.width > 0 ? n.width : e.offsetWidth, a = n.width > 0 ? Math.max(0, n.width - r) : e.clientWidth, u = e.offsetWidth > 0 ? e.offsetWidth : e.clientWidth + r;
90
+ return {
91
+ inner: a > 0 ? a : Math.max(0, e.clientWidth),
92
+ outer: p > 0 ? p : Math.max(0, u)
93
+ };
94
+ }
95
+ const i = n.height > 0 ? n.height : e.offsetHeight, f = n.height > 0 ? Math.max(0, n.height - s) : e.clientHeight, h = e.offsetHeight > 0 ? e.offsetHeight : e.clientHeight + s;
96
+ return {
97
+ inner: f > 0 ? f : Math.max(0, e.clientHeight),
98
+ outer: i > 0 ? i : Math.max(0, h)
99
+ };
100
+ }, xr = (e, t) => {
101
+ try {
102
+ localStorage.setItem(`panel-layout-${e}`, JSON.stringify(t));
103
+ } catch (n) {
104
+ console.warn("Failed to save panel layout:", n);
105
+ }
106
+ }, Pr = (e) => {
107
+ try {
108
+ const t = localStorage.getItem(`panel-layout-${e}`);
109
+ return t ? JSON.parse(t) : null;
110
+ } catch (t) {
111
+ return console.warn("Failed to load panel layout:", t), null;
112
+ }
113
+ };
114
+ var qe = /* @__PURE__ */ ((e) => (e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.NONE = 4] = "NONE", e))(qe || {});
115
+ const Ne = class Ne {
116
+ /**
117
+ * @constructor
118
+ * @param {LogLevel} [level=LogLevel.WARN] - The minimum log level to output.
119
+ * @param {string} [prefix="[resize-panels]"] - The prefix to add to all log messages.
120
+ * @param {ILogger} [impl=console] - The implementation to use for logging.
121
+ */
122
+ constructor(t = 2, n = "[resize-panels]", d = console) {
123
+ this.level = t, this.prefix = n, this.impl = d, Ne.instances.add(this);
124
+ }
125
+ /**
126
+ * @method setLevel
127
+ * @description Updates the log level for every constructed logger (module-level loggers included).
128
+ * @description 生成済みのすべてのロガー (モジュールレベルのロガーを含む) のログレベルを更新します。
129
+ * @param {LogLevel} level - The new log level.
130
+ */
131
+ static setLevel(t) {
132
+ for (const n of Ne.instances)
133
+ n.setLevel(t);
134
+ }
135
+ /**
136
+ * @method setLevel
137
+ * @description Updates the current log level.
138
+ * @description 現在のログレベルを更新します。
139
+ * @param {LogLevel} level - The new log level.
140
+ */
141
+ setLevel(t) {
142
+ this.level = t;
143
+ }
144
+ /**
145
+ * @method setImplementation
146
+ * @description Updates the logger implementation for every constructed logger.
147
+ * @description 生成済みのすべてのロガーの実装を更新します。
148
+ * @param {ILogger} impl - The new logger implementation.
149
+ */
150
+ static setImplementation(t) {
151
+ for (const n of Ne.instances)
152
+ n.setImplementation(t);
153
+ }
154
+ /**
155
+ * @method setImplementation
156
+ * @description Updates the logger implementation.
157
+ * @description ロガーの実装を更新します。
158
+ * @param {ILogger} impl - The new logger implementation.
159
+ */
160
+ setImplementation(t) {
161
+ this.impl = t;
162
+ }
163
+ /**
164
+ * @method setPrefix
165
+ * @description Updates the log prefix for every constructed logger.
166
+ * @description 生成済みのすべてのロガーのログのプレフィックスを更新します。
167
+ * @param {string} prefix - The new prefix.
168
+ */
169
+ static setPrefix(t) {
170
+ for (const n of Ne.instances)
171
+ n.setPrefix(t);
172
+ }
173
+ /**
174
+ * @method setPrefix
175
+ * @description Updates the log prefix.
176
+ * @description ログのプレフィックスを更新します。
177
+ * @param {string} prefix - The new prefix.
178
+ */
179
+ setPrefix(t) {
180
+ this.prefix = t;
181
+ }
182
+ /**
183
+ * @method enabledFor
184
+ * @description Returns whether messages at the given level would be emitted.
185
+ * @description 指定レベルのメッセージが出力対象かどうかを返します。
186
+ * 高コストなログ引数 (スナップショット等) の組み立てを抑制中に省略するために使用します。
187
+ * @param {LogLevel} level - The message level to test.
188
+ */
189
+ enabledFor(t) {
190
+ return this.level <= t;
191
+ }
192
+ formatMessage(t) {
193
+ return typeof t == "string" ? [`${this.prefix} ${t}`] : [this.prefix, t];
194
+ }
195
+ static debug(t, ...n) {
196
+ Ne.instance.debug(t, ...n);
197
+ }
198
+ debug(t, ...n) {
199
+ this.level <= 0 && this.impl.debug(...this.formatMessage(t), ...n);
200
+ }
201
+ static info(t, ...n) {
202
+ Ne.instance.info(t, ...n);
203
+ }
204
+ info(t, ...n) {
205
+ this.level <= 1 && this.impl.info(...this.formatMessage(t), ...n);
206
+ }
207
+ static warn(t, ...n) {
208
+ Ne.instance.warn(t, ...n);
209
+ }
210
+ warn(t, ...n) {
211
+ this.level <= 2 && this.impl.warn(...this.formatMessage(t), ...n);
212
+ }
213
+ static error(t, ...n) {
214
+ Ne.instance.error(t, ...n);
215
+ }
216
+ error(t, ...n) {
217
+ this.level <= 3 && this.impl.error(...this.formatMessage(t), ...n);
218
+ }
219
+ };
220
+ Ne.instances = /* @__PURE__ */ new Set(), Ne.instance = new Ne(2, "[resize-panels]");
221
+ let lt = Ne;
222
+ const pe = new lt(qe.INFO, "[resize-panels]"), Ue = 1e-9, Le = (e) => e.map((t) => ({
223
+ id: t.id,
224
+ size: t.size,
225
+ percentageSize: t.percentageSize,
226
+ preferredPercentageSize: t.preferredPercentageSize,
227
+ sizeBeforeCollapse: t.sizeBeforeCollapse,
228
+ percentageSizeBeforeCollapse: t.percentageSizeBeforeCollapse,
229
+ preferredPercentageSizeBeforeCollapse: t.preferredPercentageSizeBeforeCollapse,
230
+ measuredPercentageSize: t.measuredPercentageSize,
231
+ excludeFromAutoGrowth: t.excludeFromAutoGrowth ?? !1,
232
+ collapsed: t.collapsed ?? !1,
233
+ collapseFromStart: t.collapseFromStart,
234
+ collapseFromEnd: t.collapseFromEnd,
235
+ collapsedByDirection: t.collapsedByDirection ?? null
236
+ })), zt = (e) => e ? Le([e])[0] : null, Xe = (e) => e ? !!(e.collapseFromStart || e.collapseFromEnd) : !1, gt = (e, t) => {
237
+ if (!Number.isFinite(t) || t <= 0)
238
+ return e;
239
+ const n = e.map((h) => ({ ...h })), d = [];
240
+ for (let h = 0; h < n.length; h += 1) {
241
+ const p = n[h];
242
+ if (p.collapsed) {
243
+ n[h] = {
244
+ ...p,
245
+ size: 0,
246
+ percentageSize: 0
247
+ };
248
+ continue;
249
+ }
250
+ const a = Math.max(0, G(p.minSize, 0, t)), u = Math.max(0, G(p.autoMinSize, 0, t)), l = Math.max(a, u), z = Math.max(1e-3, l), m = G(p.maxSize, t, t), x = Math.max(l, m), b = p.sizeUnit === "pixels" || p.originalPixelSize !== void 0, N = Math.max(0, p.size);
251
+ let k = l;
252
+ if (b) {
253
+ const W = p.preferredPixelSize ?? p.size ?? p.originalPixelSize ?? l;
254
+ k = ye(W, l, x);
255
+ } else {
256
+ const W = p.preferredPercentageSize ?? p.percentageSize ?? Fe(p.size, t), ce = st(W, t);
257
+ k = ye(ce, l, x);
258
+ }
259
+ const I = !b && (p.excludeFromAutoGrowth ?? !1) && N <= z;
260
+ d.push({
261
+ index: h,
262
+ isPixelPanel: b,
263
+ minSize: l,
264
+ maxSize: x,
265
+ preferredSize: k,
266
+ priority: p.pixelAdjustPriority ?? h + 1,
267
+ flexPriority: b ? void 0 : p.flexAdjustPriority,
268
+ excludeFromGrowth: I
269
+ });
270
+ }
271
+ if (d.length === 0)
272
+ return n;
273
+ const r = /* @__PURE__ */ new Map();
274
+ let s = 0;
275
+ for (const h of d)
276
+ r.set(h.index, h.minSize), s += h.minSize;
277
+ let i = t - s;
278
+ const f = (h, p) => {
279
+ if (p <= 0)
280
+ return 0;
281
+ const a = r.get(h.index) ?? h.minSize, u = Math.max(0, h.maxSize - a);
282
+ if (u <= 0)
283
+ return 0;
284
+ const l = Math.min(p, u);
285
+ return r.set(h.index, a + l), l;
286
+ };
287
+ if (i > 0) {
288
+ const h = (a) => {
289
+ for (; i > 1e-6; ) {
290
+ let l = 0;
291
+ const z = [];
292
+ for (const b of a) {
293
+ if (!b.isPixelPanel && b.excludeFromGrowth)
294
+ continue;
295
+ const N = r.get(b.index) ?? b.minSize, k = Math.min(b.preferredSize, b.maxSize), I = Math.max(0, k - N);
296
+ I > 1e-6 && (l += I, z.push({ descriptor: b, capacity: I }));
297
+ }
298
+ if (z.length === 0 || l <= 1e-6)
299
+ break;
300
+ let m = 0;
301
+ const x = i;
302
+ for (const b of z) {
303
+ if (i <= 1e-6)
304
+ break;
305
+ if (!b.descriptor.isPixelPanel && b.descriptor.excludeFromGrowth)
306
+ continue;
307
+ const N = x * b.capacity / l, k = Math.min(b.capacity, N);
308
+ if (k <= 0)
309
+ continue;
310
+ const I = f(b.descriptor, k);
311
+ I > 0 && (i -= I, m += I);
312
+ }
313
+ if (m <= 1e-6)
314
+ break;
315
+ }
316
+ }, p = d.filter((a) => a.isPixelPanel);
317
+ p.sort((a, u) => u.priority - a.priority);
318
+ for (const a of p) {
319
+ if (i <= 0)
320
+ break;
321
+ const u = r.get(a.index) ?? a.minSize, l = Math.min(a.preferredSize, a.maxSize), z = Math.max(0, l - u);
322
+ if (z <= 0)
323
+ continue;
324
+ const m = f(a, Math.min(z, i));
325
+ m > 0 && (i -= m);
326
+ }
327
+ if (i > 0) {
328
+ const a = d.filter((u) => !u.isPixelPanel);
329
+ if (a.length > 0) {
330
+ const u = a.filter((l) => l.flexPriority !== void 0 && !l.excludeFromGrowth);
331
+ if (u.length > 0) {
332
+ u.sort((l, z) => (z.flexPriority ?? 0) - (l.flexPriority ?? 0));
333
+ for (const l of u) {
334
+ if (i <= 0)
335
+ break;
336
+ if (l.excludeFromGrowth)
337
+ continue;
338
+ const z = r.get(l.index) ?? l.minSize, m = Math.min(l.preferredSize, l.maxSize), x = Math.max(0, m - z);
339
+ if (x <= 0)
340
+ continue;
341
+ const b = f(l, Math.min(x, i));
342
+ b > 0 && (i -= b);
343
+ }
344
+ }
345
+ if (i > 0) {
346
+ const l = u.length > 0 ? a.filter((z) => z.flexPriority === void 0 && !z.excludeFromGrowth) : a.filter((z) => !z.excludeFromGrowth);
347
+ l.length > 0 && h(l);
348
+ }
349
+ }
350
+ }
351
+ }
352
+ if (i > 0) {
353
+ let h = i;
354
+ for (; ; ) {
355
+ let p = 0;
356
+ const a = [];
357
+ for (const l of d) {
358
+ if (!l.isPixelPanel && l.excludeFromGrowth)
359
+ continue;
360
+ const z = r.get(l.index) ?? l.minSize, m = l.isPixelPanel ? Math.min(l.maxSize, l.preferredSize) : l.maxSize, x = Math.max(0, m - z);
361
+ x > 0 && (a.push(l), p += x);
362
+ }
363
+ if (p <= 0)
364
+ break;
365
+ const u = i;
366
+ for (const l of a) {
367
+ if (i <= 0)
368
+ break;
369
+ if (!l.isPixelPanel && l.excludeFromGrowth)
370
+ continue;
371
+ const z = r.get(l.index) ?? l.minSize, m = l.isPixelPanel ? Math.min(l.maxSize, l.preferredSize) : l.maxSize, x = Math.max(0, m - z);
372
+ if (x <= 0)
373
+ continue;
374
+ const b = u * x / p, N = f(l, Math.min(x, b));
375
+ N > 0 && (i -= N);
376
+ }
377
+ if (i <= 1e-6 || Math.abs(h - i) <= 1e-6)
378
+ break;
379
+ h = i;
380
+ }
381
+ i = Math.max(0, i);
382
+ }
383
+ for (const h of d) {
384
+ const p = r.get(h.index) ?? h.minSize, a = n[h.index], u = Xe(a), l = u ? p : a.sizeBeforeCollapse, z = u ? a.measuredPixelSizeBeforeCollapse ?? a.measuredPixelSize ?? p : a.measuredPixelSizeBeforeCollapse, m = t > 0 ? Fe(p, t) : 0;
385
+ n[h.index] = {
386
+ ...a,
387
+ size: p,
388
+ percentageSize: m,
389
+ preferredPercentageSize: a.preferredPercentageSize,
390
+ preferredPixelSize: h.isPixelPanel ? a.preferredPixelSize ?? p : a.preferredPixelSize,
391
+ sizeBeforeCollapse: l,
392
+ measuredPixelSizeBeforeCollapse: z,
393
+ measuredPixelSize: void 0,
394
+ measuredPercentageSize: void 0
395
+ };
396
+ }
397
+ return Ke(n);
398
+ }, Ke = (e) => {
399
+ let t = 0;
400
+ for (const r of e)
401
+ r.collapsed || (t += Math.max(r.size, 0));
402
+ if (t <= 0) {
403
+ let r = !1;
404
+ const s = e.map((i) => (i.percentageSize ?? 0) !== 0 ? (r = !0, {
405
+ ...i,
406
+ percentageSize: 0,
407
+ measuredPercentageSize: i.measuredPercentageSize !== void 0 ? 0 : i.measuredPercentageSize
408
+ }) : !i.collapsed && i.sizeBeforeCollapse !== i.size ? (r = !0, {
409
+ ...i,
410
+ sizeBeforeCollapse: i.size
411
+ }) : i);
412
+ return r ? s : e;
413
+ }
414
+ let n = !1;
415
+ const d = e.map((r) => {
416
+ if (r.collapsed)
417
+ return (r.percentageSize ?? 0) !== 0 ? (n = !0, {
418
+ ...r,
419
+ percentageSize: 0,
420
+ measuredPercentageSize: r.measuredPercentageSize !== void 0 ? 0 : r.measuredPercentageSize
421
+ }) : r;
422
+ const s = Fe(r.size, t), i = r.measuredPercentageSize, p = (i !== void 0 ? Math.abs(i - s) : 1 / 0) < 1e-4 && i !== void 0 ? i : s, a = vt(p, Zt), l = Math.abs((r.percentageSize ?? 0) - a) > 0 || r.percentageSize === void 0, z = r.sizeBeforeCollapse === void 0 || r.sizeBeforeCollapse !== r.size, m = Xe(r), x = m && z, b = r.measuredPixelSize ?? r.size, N = m && (r.measuredPixelSizeBeforeCollapse === void 0 || r.measuredPixelSizeBeforeCollapse !== b);
423
+ if (!(l || x || N))
424
+ return r;
425
+ n = !0;
426
+ const k = x ? r.size : r.sizeBeforeCollapse, I = N ? b : r.measuredPixelSizeBeforeCollapse;
427
+ return {
428
+ ...r,
429
+ percentageSize: a,
430
+ sizeBeforeCollapse: k,
431
+ measuredPixelSizeBeforeCollapse: I,
432
+ collapsedByDirection: r.collapsed ? r.collapsedByDirection ?? null : null
433
+ };
434
+ });
435
+ return n ? d : e;
436
+ }, mt = (e, t) => {
437
+ if (t <= 0)
438
+ return !1;
439
+ const n = [];
440
+ let d = 0;
441
+ for (let a = 0; a < e.length; a += 1) {
442
+ const u = e[a];
443
+ !u || u.collapsed || (n.push(a), d += u.size);
444
+ }
445
+ if (n.length === 0)
446
+ return !1;
447
+ let r = t - d;
448
+ if (Math.abs(r) <= 0)
449
+ return !1;
450
+ let s = !1;
451
+ const i = (a) => {
452
+ const u = e[a], l = G(u.minSize, 0, t), z = G(u.autoMinSize, 0, t), m = Math.max(l, z), x = G(u.maxSize, t, t), b = u.sizeUnit === "percentage" && u.originalPixelSize === void 0;
453
+ return {
454
+ index: a,
455
+ minSize: m,
456
+ maxSize: x,
457
+ isFlexible: b
458
+ };
459
+ }, f = (a, u) => {
460
+ if (!Number.isFinite(u) || Math.abs(u) <= 0)
461
+ return;
462
+ const l = e[a];
463
+ if (!l)
464
+ return;
465
+ const z = Math.max(0, l.size + u);
466
+ if (Math.abs(z - l.size) <= 0)
467
+ return;
468
+ const m = Fe(z, t), x = Xe(l), b = x ? z : l.sizeBeforeCollapse, N = x ? l.measuredPixelSizeBeforeCollapse ?? l.measuredPixelSize ?? z : l.measuredPixelSizeBeforeCollapse;
469
+ e[a] = {
470
+ ...l,
471
+ size: z,
472
+ percentageSize: m,
473
+ sizeBeforeCollapse: b,
474
+ measuredPixelSizeBeforeCollapse: N,
475
+ measuredPixelSize: void 0,
476
+ measuredPercentageSize: void 0
477
+ }, r -= u, s = !0;
478
+ }, h = (a) => {
479
+ for (const u of a) {
480
+ if (Math.abs(r) <= 0)
481
+ break;
482
+ const l = e[u.index];
483
+ if (!l || l.collapsed)
484
+ continue;
485
+ const z = l.size;
486
+ if (r > 0) {
487
+ const m = Math.max(0, u.maxSize - z);
488
+ if (m <= 0)
489
+ continue;
490
+ const x = Math.min(m, r);
491
+ if (x <= 0)
492
+ continue;
493
+ f(u.index, x);
494
+ } else {
495
+ const m = Math.max(0, z - u.minSize);
496
+ if (m <= 0)
497
+ continue;
498
+ const x = Math.min(m, Math.abs(r));
499
+ if (x <= 0)
500
+ continue;
501
+ f(u.index, -x);
502
+ }
503
+ }
504
+ }, p = n.map((a) => i(a)).filter((a) => a.isFlexible);
505
+ if (p.length > 0 && h(p), Math.abs(r) > 0) {
506
+ const a = r;
507
+ r = Kt(e, r, t, { enforceAutoMinSize: !0 }), Math.abs(r - a) > 0 && (s = !0);
508
+ }
509
+ return s;
510
+ }, Ot = (e, t, n) => {
511
+ if (!(e.sizeUnit === "pixels" || e.originalPixelSize !== void 0) || e.pixelAdjustPriority !== void 0)
512
+ return e;
513
+ const r = t.filter((i, f) => f !== n && (i.sizeUnit === "pixels" || i.originalPixelSize !== void 0)).map((i) => i.pixelAdjustPriority).filter((i) => i !== void 0), s = r.length > 0 ? Math.max(...r) + 1 : 1;
514
+ return {
515
+ ...e,
516
+ pixelAdjustPriority: s
517
+ };
518
+ }, br = (e, t) => {
519
+ switch (t.type) {
520
+ case "REGISTER_PANEL": {
521
+ pe.debug("REGISTER_PANEL", t.panel);
522
+ const n = e.findIndex((s) => s.id === t.panel.id);
523
+ if (n >= 0) {
524
+ const s = [...e], i = e[n], f = {
525
+ ...i,
526
+ minSize: t.panel.minSize,
527
+ maxSize: t.panel.maxSize,
528
+ collapseFromStart: t.panel.collapseFromStart,
529
+ collapseFromEnd: t.panel.collapseFromEnd,
530
+ collapsedByDirection: t.panel.collapsedByDirection !== void 0 ? t.panel.collapsedByDirection : i.collapsedByDirection,
531
+ sizeUnit: t.panel.sizeUnit,
532
+ originalPixelSize: t.panel.originalPixelSize,
533
+ preferredPercentageSize: t.panel.preferredPercentageSize !== void 0 ? t.panel.preferredPercentageSize : i.preferredPercentageSize,
534
+ preferredPercentageSizeBeforeCollapse: t.panel.preferredPercentageSizeBeforeCollapse !== void 0 ? t.panel.preferredPercentageSizeBeforeCollapse : i.preferredPercentageSizeBeforeCollapse,
535
+ percentageSizeBeforeCollapse: t.panel.percentageSizeBeforeCollapse !== void 0 ? t.panel.percentageSizeBeforeCollapse : i.percentageSizeBeforeCollapse,
536
+ pixelAdjustPriority: t.panel.pixelAdjustPriority !== void 0 ? t.panel.pixelAdjustPriority : i.pixelAdjustPriority,
537
+ flexAdjustPriority: t.panel.flexAdjustPriority !== void 0 ? t.panel.flexAdjustPriority : i.flexAdjustPriority,
538
+ autoMinSize: t.panel.autoMinSize !== void 0 ? t.panel.autoMinSize : i.autoMinSize,
539
+ excludeFromAutoGrowth: t.panel.excludeFromAutoGrowth !== void 0 ? t.panel.excludeFromAutoGrowth : i.excludeFromAutoGrowth
540
+ }, h = Ot(f, e, n);
541
+ if (pe.debug("register panel (update)", {
542
+ panelId: h.id,
543
+ incoming: zt(t.panel),
544
+ previous: zt(i),
545
+ next: zt(h)
546
+ }), s[n] = h, !h.collapsed) {
547
+ const p = s.reduce((a, u) => u.collapsed ? a : a + u.size, 0);
548
+ if (p > 0) {
549
+ const a = G(h.minSize, 0, p), u = Math.max(a, G(h.maxSize, p, p));
550
+ if (h.size < a - Ue || h.size > u + Ue)
551
+ return gt(s, p);
552
+ }
553
+ }
554
+ return s;
555
+ }
556
+ const d = { ...t.panel }, r = Ot(d, e);
557
+ return pe.debug("register panel (insert)", {
558
+ panelId: r.id,
559
+ incoming: zt(r),
560
+ previousLength: e.length
561
+ }), [...e, r];
562
+ }
563
+ case "UNREGISTER_PANEL": {
564
+ pe.debug("UNREGISTER_PANEL", t.id);
565
+ const n = e.filter((r) => r.id !== t.id), d = Ke(n);
566
+ return pe.enabledFor(qe.DEBUG) && pe.debug("unregister panel", {
567
+ panelId: t.id,
568
+ previous: Le(e),
569
+ filtered: Le(n),
570
+ next: Le(d)
571
+ }), d;
572
+ }
573
+ case "RESIZE_PANELS": {
574
+ pe.debug("RESIZE_PANELS", t.leftId, t.rightId, t.leftSize, t.rightSize);
575
+ const n = e.findIndex((C) => C.id === t.leftId), d = e.findIndex((C) => C.id === t.rightId);
576
+ if (n === -1 || d === -1) return e;
577
+ const r = [...e], s = r[n], i = r[d];
578
+ if (s.collapsed || i.collapsed || t.leftSize === s.size && t.rightSize === i.size)
579
+ return e;
580
+ const f = t.containerSize ?? e.reduce((C, ie) => C + ie.size, 0), h = G(s.minSize, 0, f), p = G(s.maxSize, f, f), a = G(i.minSize, 0, f), u = G(i.maxSize, f, f), l = s.size + i.size, z = e.reduce((C, ie) => ie.collapsed ? C : C + ie.size, 0), m = z - l, x = h + a, b = p + u, N = ye(t.leftSize + t.rightSize, x, b);
581
+ let k = f > 0 ? f - m : N;
582
+ Number.isFinite(k) || (k = N);
583
+ const I = ye(Math.max(N, k), x, b), W = (C) => ({
584
+ min: Math.max(h, C - u),
585
+ max: Math.min(p, C - a)
586
+ }), ce = (C) => ({
587
+ min: Math.max(a, C - p),
588
+ max: Math.min(u, C - h)
589
+ }), te = Math.abs(t.leftSize - s.size), oe = Math.abs(t.rightSize - i.size), $ = te >= oe;
590
+ let A = s.size, y = i.size;
591
+ if ($) {
592
+ const C = W(I);
593
+ if (C.min > C.max + Ue)
594
+ return e;
595
+ const ie = ye(t.leftSize, C.min, C.max), Se = I - ie;
596
+ if (Se < a - Ue || Se > u + Ue)
597
+ return e;
598
+ A = ie, y = ye(Se, a, u);
599
+ } else {
600
+ const C = ce(I);
601
+ if (C.min > C.max + Ue)
602
+ return e;
603
+ const ie = ye(t.rightSize, C.min, C.max), Se = I - ie;
604
+ if (Se < h - Ue || Se > p + Ue)
605
+ return e;
606
+ y = ie, A = ye(Se, h, p);
607
+ }
608
+ const D = A + y;
609
+ if (Math.abs(I - D) > Ue)
610
+ return e;
611
+ const V = z - s.size - i.size + D, H = f > 0 ? f : V, L = H > 0 ? Fe(A, H) : 0, Me = H > 0 ? Fe(y, H) : 0, F = s.sizeUnit === "pixels" || s.originalPixelSize !== void 0 ? A : s.preferredPixelSize, de = i.sizeUnit === "pixels" || i.originalPixelSize !== void 0 ? y : i.preferredPixelSize, Ge = G(s.autoMinSize, 0, f), fe = G(i.autoMinSize, 0, f), Ae = Math.max(1e-3, Ge), Pe = Math.max(1e-3, fe), ve = s.sizeUnit === "percentage" && s.originalPixelSize === void 0, se = i.sizeUnit === "percentage" && i.originalPixelSize === void 0;
612
+ let Ee = s.excludeFromAutoGrowth, _e = i.excludeFromAutoGrowth;
613
+ ve && (A <= Ae ? Ee = !0 : A > Ae && (Ee = !1)), se && (y <= Pe ? _e = !0 : y > Pe && (_e = !1));
614
+ const ke = Xe(s), $e = Xe(i);
615
+ return r[n] = {
616
+ ...s,
617
+ size: A,
618
+ percentageSize: L,
619
+ preferredPercentageSize: L > 0 ? L : s.preferredPercentageSize,
620
+ preferredPixelSize: F,
621
+ sizeBeforeCollapse: ke ? A : s.sizeBeforeCollapse,
622
+ measuredPixelSize: void 0,
623
+ measuredPercentageSize: void 0,
624
+ excludeFromAutoGrowth: Ee
625
+ }, r[d] = {
626
+ ...i,
627
+ size: y,
628
+ percentageSize: Me,
629
+ preferredPercentageSize: Me > 0 ? Me : i.preferredPercentageSize,
630
+ preferredPixelSize: de,
631
+ sizeBeforeCollapse: $e ? y : i.sizeBeforeCollapse,
632
+ measuredPixelSize: void 0,
633
+ measuredPercentageSize: void 0,
634
+ excludeFromAutoGrowth: _e
635
+ }, f > 0 && mt(r, f) ? Ke(r) : r;
636
+ }
637
+ case "SET_PANELS": {
638
+ pe.debug("SET_PANELS", t.panels);
639
+ const n = pe.enabledFor(qe.DEBUG), d = t.panels.map((p) => {
640
+ const a = p.sizeUnit === "pixels" || p.originalPixelSize !== void 0, u = p.preferredPercentageSize !== void 0 ? p.preferredPercentageSize : p.percentageSize, l = p.preferredPixelSize !== void 0 ? p.preferredPixelSize : a ? p.size : p.preferredPixelSize;
641
+ return {
642
+ ...p,
643
+ preferredPercentageSize: u,
644
+ preferredPixelSize: l
645
+ };
646
+ }), r = Le(e), s = n ? Le(d) : null, i = Ke(d), f = Le(i);
647
+ let h = r.length === f.length;
648
+ if (h)
649
+ for (let p = 0; p < f.length; p += 1) {
650
+ const a = f[p], u = r[p];
651
+ if (!u) {
652
+ h = !1;
653
+ break;
654
+ }
655
+ if (!(u.id === a.id && u.size === a.size && u.percentageSize === a.percentageSize && u.preferredPercentageSize === a.preferredPercentageSize && u.sizeBeforeCollapse === a.sizeBeforeCollapse && u.percentageSizeBeforeCollapse === a.percentageSizeBeforeCollapse && u.preferredPercentageSizeBeforeCollapse === a.preferredPercentageSizeBeforeCollapse && u.measuredPercentageSize === a.measuredPercentageSize && u.excludeFromAutoGrowth === a.excludeFromAutoGrowth && u.collapsed === a.collapsed && u.collapseFromStart === a.collapseFromStart && u.collapseFromEnd === a.collapseFromEnd && u.collapsedByDirection === a.collapsedByDirection)) {
656
+ h = !1;
657
+ break;
658
+ }
659
+ }
660
+ return h ? (n && pe.debug("set panels skipped (no diff)", {
661
+ previous: r,
662
+ incoming: s,
663
+ next: f,
664
+ previousLength: r.length,
665
+ incomingLength: s?.length ?? d.length
666
+ }), e) : (n && pe.debug("set panels", {
667
+ previous: r,
668
+ incoming: s,
669
+ next: f,
670
+ previousLength: r.length,
671
+ incomingLength: s?.length ?? d.length
672
+ }), i);
673
+ }
674
+ case "CONTAINER_RESIZED": {
675
+ pe.debug("CONTAINER_RESIZED", t.containerSize);
676
+ const n = pe.enabledFor(qe.DEBUG);
677
+ if (t.containerSize <= 0)
678
+ return n && pe.debug("container resized skipped (non-positive size)", {
679
+ containerSize: t.containerSize,
680
+ panels: Le(e)
681
+ }), e;
682
+ n && pe.debug("container resized (before)", {
683
+ containerSize: t.containerSize,
684
+ panels: Le(e)
685
+ });
686
+ const d = gt(e, t.containerSize);
687
+ if (n && pe.debug("container resized (after recalc)", {
688
+ containerSize: t.containerSize,
689
+ panels: Le(d)
690
+ }), t.containerSize > 0 && mt(d, t.containerSize)) {
691
+ const r = Ke(d);
692
+ return n && pe.debug("container resized (after reconcile)", {
693
+ containerSize: t.containerSize,
694
+ panels: Le(r)
695
+ }), r;
696
+ }
697
+ return n && pe.debug("container resized (final)", {
698
+ containerSize: t.containerSize,
699
+ panels: Le(d)
700
+ }), d;
701
+ }
702
+ case "COLLAPSE_PANEL": {
703
+ pe.debug("COLLAPSE_PANEL", t.id);
704
+ const n = e.findIndex((l) => l.id === t.id);
705
+ if (n === -1)
706
+ return e;
707
+ const d = e[n], r = t.from === "start" ? d.collapseFromStart : d.collapseFromEnd;
708
+ if (!(Xe(d) && r) || d.collapsed)
709
+ return e;
710
+ const i = d.size, f = d.measuredPixelSize ?? i, h = d.percentageSize ?? d.preferredPercentageSize ?? 0, p = {
711
+ ...d,
712
+ collapsed: !0,
713
+ collapsedByDirection: t.from,
714
+ sizeBeforeCollapse: i,
715
+ percentageSizeBeforeCollapse: h,
716
+ preferredPercentageSizeBeforeCollapse: d.preferredPercentageSize ?? h,
717
+ preferredPixelSizeBeforeCollapse: d.preferredPixelSize ?? i,
718
+ measuredPixelSizeBeforeCollapse: f,
719
+ size: 0,
720
+ percentageSize: 0,
721
+ preferredPercentageSize: d.preferredPercentageSize,
722
+ measuredPixelSize: d.measuredPixelSize !== void 0 ? 0 : d.measuredPixelSize,
723
+ measuredPercentageSize: d.measuredPercentageSize !== void 0 ? 0 : d.measuredPercentageSize
724
+ }, a = [...e];
725
+ a[n] = p;
726
+ const u = gt(a, t.containerSize);
727
+ return t.containerSize > 0 && mt(u, t.containerSize) ? Ke(u) : u;
728
+ }
729
+ case "EXPAND_PANEL": {
730
+ pe.debug("EXPAND_PANEL", t.id, t.targetSize);
731
+ const n = e.findIndex((I) => I.id === t.id);
732
+ if (n === -1)
733
+ return e;
734
+ const d = t.containerSize, r = e[n], s = t.from === "start" ? r.collapseFromStart : r.collapseFromEnd;
735
+ if (!(Xe(r) && s && r.collapsed) || r.collapsedByDirection && r.collapsedByDirection !== t.from)
736
+ return e;
737
+ const f = [t.targetSize, r.sizeBeforeCollapse, r.measuredPixelSizeBeforeCollapse, r.preferredPixelSizeBeforeCollapse, r.originalPixelSize].find((I) => I !== void 0) ?? 0, h = G(r.minSize, 0, d), p = G(r.maxSize, d, d), a = ye(f, h, p), u = Fe(a, d), l = r.measuredPixelSizeBeforeCollapse ?? a, z = Fe(l, d), m = r.preferredPercentageSizeBeforeCollapse ?? r.percentageSizeBeforeCollapse ?? u, x = r.preferredPixelSizeBeforeCollapse ?? r.preferredPixelSize ?? a, b = {
738
+ ...r,
739
+ collapsed: !1,
740
+ collapsedByDirection: null,
741
+ size: a,
742
+ percentageSize: u,
743
+ preferredPercentageSize: m,
744
+ preferredPixelSize: x,
745
+ sizeBeforeCollapse: a,
746
+ percentageSizeBeforeCollapse: void 0,
747
+ preferredPercentageSizeBeforeCollapse: void 0,
748
+ preferredPixelSizeBeforeCollapse: void 0,
749
+ measuredPixelSize: a,
750
+ measuredPixelSizeBeforeCollapse: l,
751
+ measuredPercentageSize: z
752
+ }, N = [...e];
753
+ N[n] = b;
754
+ const k = gt(N, d);
755
+ return d > 0 && mt(k, d) ? Ke(k) : k;
756
+ }
757
+ default:
758
+ return e;
759
+ }
760
+ }, nt = new lt(qe.INFO, "[resize-panels]"), Cr = ({ direction: e, style: t, onLayout: n, autoSaveId: d, showDebugInfo: r = !1 }) => {
761
+ const [s, i] = rr(br, []), [f, h] = Te({ width: 0, height: 0 }), [p, a] = Te(!1), [u, l] = Te(!1), [z, m] = Te(null), [x, b] = Te({}), [N, k] = Te({}), I = _(null), W = _(n), ce = _(!1), te = _(0), oe = _(f), $ = _(f), A = _(p), y = _(z?.reason ?? null), D = _({}), V = _(null), H = _(null), L = _(null), Me = _({ width: 0, height: 0 }), F = _({ width: 0, height: 0 }), de = _({}), Ge = _({}), fe = ge((c) => c.map((g) => ({ ...g })), []);
762
+ K(() => {
763
+ $.current = f;
764
+ }, [f]), K(() => {
765
+ A.current = p;
766
+ }, [p]), K(() => {
767
+ y.current = z?.reason ?? null;
768
+ }, [z?.reason]), K(() => {
769
+ if (z)
770
+ return;
771
+ const c = e === "horizontal" ? f.width : f.height;
772
+ !Number.isFinite(c) || c <= 4 || s.length !== 0 && (V.current = fe(s));
773
+ }, [z, s, e, f.width, f.height, fe]);
774
+ const Ae = _(s);
775
+ K(() => {
776
+ Ae.current = s;
777
+ }, [s]), K(() => {
778
+ const c = H.current;
779
+ if (z) {
780
+ H.current = z;
781
+ return;
782
+ }
783
+ if (c && !z && V.current) {
784
+ H.current = null;
785
+ const g = new Set(Ae.current.map((v) => v.id)), M = fe(V.current).filter((v) => g.has(v.id));
786
+ M.length > 0 && i({ type: "SET_PANELS", panels: M });
787
+ return;
788
+ }
789
+ H.current = z;
790
+ }, [z, fe]), St(() => {
791
+ if (!I.current) return;
792
+ const c = new ResizeObserver((g) => {
793
+ for (const M of g) {
794
+ const v = M.target, Y = v ? Ye(v, "horizontal") : null, ae = v ? Ye(v, "vertical") : null, re = Y ? Y.inner : 0, T = ae ? ae.inner : 0, he = M.contentRect.width, Z = M.contentRect.height, E = re > 0 ? re : he, S = T > 0 ? T : Z;
795
+ Me.current = { width: E, height: S };
796
+ const O = F.current, X = Math.abs(O.width - E) >= 0.5, Q = Math.abs(O.height - S) >= 0.5;
797
+ X || Q ? (L.current && (clearTimeout(L.current), L.current = null), !p && E > 0 && S > 0 && a(!0), h({ width: E, height: S }), F.current = { width: E, height: S }) : (L.current && clearTimeout(L.current), L.current = setTimeout(() => {
798
+ const U = Me.current;
799
+ h(U), F.current = U, L.current = null;
800
+ }, 150));
801
+ }
802
+ });
803
+ return c.observe(I.current), () => {
804
+ c.disconnect(), L.current && clearTimeout(L.current);
805
+ };
806
+ }, [p]), K(() => () => {
807
+ for (const c of Object.values(de.current))
808
+ clearTimeout(c);
809
+ }, []), St(() => {
810
+ const c = oe.current, g = f, M = e === "horizontal" ? Math.abs(c.width - g.width) >= 0.5 : Math.abs(c.height - g.height) >= 0.5;
811
+ if (u && M) {
812
+ const v = e === "horizontal" ? g.width : g.height;
813
+ i({ type: "CONTAINER_RESIZED", containerSize: v, direction: e });
814
+ }
815
+ oe.current = g;
816
+ }, [f, u, e]);
817
+ const Pe = ge(() => {
818
+ nt.debug("panels[0]?.id", s[0]?.id);
819
+ const c = s.some((o) => {
820
+ if (o.collapsed || o.sizeUnit !== "percentage")
821
+ return !1;
822
+ const J = o.collapseFromStart || o.collapseFromEnd ? o.sizeBeforeCollapse ?? o.measuredPixelSizeBeforeCollapse ?? o.originalPixelSize ?? o.measuredPixelSize ?? 0 : o.measuredPixelSize ?? o.originalPixelSize ?? o.size, ee = o.percentageSize !== void 0 && o.percentageSize > 0;
823
+ return o.size <= 0 && (J > 0 || ee);
824
+ }), g = e === "horizontal" ? f.width : f.height, M = g > 0;
825
+ if (z || !M || !(s.length > 0 && (s.length !== te.current || !u || c)))
826
+ return;
827
+ const ae = s.filter((o) => !o.collapsed && (o.originalPixelSize !== void 0 || o.sizeUnit === "pixels")).reduce((o, w) => {
828
+ const J = w.preferredPixelSize ?? w.originalPixelSize ?? w.size;
829
+ return o + Math.max(0, J ?? 0);
830
+ }, 0), re = s.filter((o) => o.sizeUnit === "percentage" && !o.collapsed), T = re.map((o) => o.id), he = re.map((o) => {
831
+ const w = o.preferredPercentageSize ?? o.percentageSize;
832
+ return w !== void 0 && w > 0 ? st(w, g) : o.size > 0 ? o.size : 0;
833
+ }), Z = he.reduce((o, w) => o + w, 0), E = g - ae, S = Math.max(0, E), O = S > 0, X = s.map((o) => {
834
+ if (o.collapsed) {
835
+ const w = o.sizeBeforeCollapse ?? o.measuredPixelSizeBeforeCollapse ?? o.originalPixelSize ?? (o.sizeUnit === "pixels" ? o.size : void 0), J = o.sizeUnit === "percentage" && o.percentageSize !== void 0 ? st(o.percentageSize, g) : void 0, ee = w ?? J ?? 0, Re = o.measuredPixelSizeBeforeCollapse ?? o.measuredPixelSize ?? ee;
836
+ return {
837
+ ...o,
838
+ size: 0,
839
+ percentageSize: 0,
840
+ preferredPercentageSize: o.preferredPercentageSize,
841
+ sizeBeforeCollapse: ee,
842
+ percentageSizeBeforeCollapse: o.percentageSizeBeforeCollapse ?? o.percentageSize ?? o.preferredPercentageSize ?? 0,
843
+ preferredPercentageSizeBeforeCollapse: o.preferredPercentageSizeBeforeCollapse ?? o.preferredPercentageSize ?? o.percentageSize ?? void 0,
844
+ preferredPixelSizeBeforeCollapse: o.preferredPixelSizeBeforeCollapse ?? o.preferredPixelSize ?? ee,
845
+ measuredPixelSizeBeforeCollapse: Re
846
+ };
847
+ }
848
+ if (o.sizeUnit === "pixels" || o.originalPixelSize !== void 0) {
849
+ const w = o.size, J = g > 0 ? Fe(w, g) : 0, ee = {
850
+ ...o,
851
+ size: w,
852
+ percentageSize: J,
853
+ preferredPixelSize: o.preferredPixelSize ?? o.originalPixelSize ?? w,
854
+ preferredPercentageSize: o.preferredPercentageSize !== void 0 ? o.preferredPercentageSize : J > 0 ? J : void 0
855
+ };
856
+ if (o.collapseFromStart || o.collapseFromEnd) {
857
+ const Re = o.sizeBeforeCollapse ?? w, Qe = o.measuredPixelSizeBeforeCollapse ?? o.measuredPixelSize ?? Re;
858
+ ee.sizeBeforeCollapse = Re, ee.measuredPixelSizeBeforeCollapse = Qe, ee.preferredPixelSizeBeforeCollapse = o.preferredPixelSizeBeforeCollapse ?? o.preferredPixelSize ?? Re;
859
+ }
860
+ return ee;
861
+ }
862
+ if (o.sizeUnit === "percentage") {
863
+ const w = T.indexOf(o.id), J = w !== -1 ? he[w] : 0, ee = G(o.minSize, 0, g), Re = G(o.maxSize, g, g), Qe = Math.max(
864
+ ee,
865
+ o.sizeBeforeCollapse ?? 0,
866
+ o.measuredPixelSizeBeforeCollapse ?? 0,
867
+ o.measuredPixelSize ?? 0,
868
+ o.originalPixelSize ?? 0,
869
+ o.size > 0 ? o.size : 0,
870
+ o.percentageSize !== void 0 ? st(o.percentageSize, g) : 0,
871
+ 1
872
+ ), ct = J > 0 ? J : Qe;
873
+ let De;
874
+ if (!O)
875
+ De = ee;
876
+ else if (w !== -1 && Z > 0) {
877
+ const R = ct / Z, B = S * R;
878
+ De = ye(B, ee, Re);
879
+ } else {
880
+ const R = o.percentageSize !== void 0 ? st(o.percentageSize, g) : o.size, B = R > 0 ? R : ct;
881
+ De = ye(B, ee, Re);
882
+ }
883
+ const et = g > 0 ? Fe(De, g) : 0, P = {
884
+ ...o,
885
+ size: De,
886
+ percentageSize: et,
887
+ preferredPercentageSize: o.preferredPercentageSize !== void 0 ? o.preferredPercentageSize : et > 0 ? et : void 0
888
+ };
889
+ if (o.collapseFromStart || o.collapseFromEnd) {
890
+ const R = o.sizeBeforeCollapse ?? De, B = o.measuredPixelSizeBeforeCollapse ?? o.measuredPixelSize ?? R;
891
+ P.sizeBeforeCollapse = R, P.measuredPixelSizeBeforeCollapse = B, P.preferredPixelSizeBeforeCollapse = o.preferredPixelSizeBeforeCollapse ?? o.preferredPixelSize ?? R;
892
+ }
893
+ return P;
894
+ }
895
+ return o;
896
+ }), Q = [];
897
+ for (let o = 0; o < X.length; o += 1) {
898
+ const w = X[o];
899
+ w.sizeUnit === "percentage" && !w.collapsed && Q.push(o);
900
+ }
901
+ const U = Q.reduce((o, w) => o + X[w].size, 0), q = E - U;
902
+ Math.abs(q) > 0 && Kt(X, q, g, { enforceAutoMinSize: !0 }), i({ type: "SET_PANELS", panels: X }), te.current = s.length, l(!0);
903
+ }, [s, e, f.width, f.height, u, z]);
904
+ K(() => {
905
+ const c = e === "horizontal" ? f.width : f.height, g = c > 0, M = g && s.length > 0;
906
+ if (g && s.length === 0) {
907
+ z && m(null);
908
+ return;
909
+ }
910
+ const v = M ? s.reduce((Z, E) => {
911
+ if (E.collapsed)
912
+ return Z;
913
+ const S = G(E.minSize, 0, c);
914
+ return Z + Math.max(0, S);
915
+ }, 0) : null, Y = M ? s.reduce((Z, E) => {
916
+ if (E.collapsed)
917
+ return Z;
918
+ const S = G(E.maxSize, c, c);
919
+ return Z + Math.max(0, S);
920
+ }, 0) : null, ae = v ?? z?.totalMinimumSize ?? null, re = Y ?? z?.totalMaximumSize ?? null;
921
+ if (!g) {
922
+ z && m((Z) => !Z || Z.availableContainerSize === c ? Z : {
923
+ reason: Z.reason,
924
+ // totalMinimumSize: previous.totalMinimumSize,
925
+ // totalMaximumSize: previous.totalMaximumSize,
926
+ totalMinimumSize: null,
927
+ totalMaximumSize: null,
928
+ availableContainerSize: c
929
+ });
930
+ return;
931
+ }
932
+ const T = ae !== null && ae - c > Number.EPSILON, he = re !== null && c - re > Number.EPSILON;
933
+ if (T || he) {
934
+ const E = {
935
+ reason: T ? "minimum-exceeded" : "maximum-insufficient",
936
+ totalMinimumSize: ae,
937
+ totalMaximumSize: re,
938
+ availableContainerSize: c
939
+ };
940
+ m((S) => S && S.reason === E.reason && Math.abs((S.totalMinimumSize ?? 0) - (E.totalMinimumSize ?? 0)) <= Number.EPSILON && Math.abs((S.totalMaximumSize ?? 0) - (E.totalMaximumSize ?? 0)) <= Number.EPSILON && Math.abs(S.availableContainerSize - E.availableContainerSize) <= Number.EPSILON ? S : E);
941
+ return;
942
+ }
943
+ if (z) {
944
+ const Z = z.reason === "minimum-exceeded", E = z.reason === "maximum-insufficient";
945
+ (!Z || ae !== null) && (!E || re !== null) && !T && !he && m((U) => U && null);
946
+ }
947
+ }, [s, e, f.width, f.height, z]), K(() => {
948
+ Pe();
949
+ }, [Pe]), K(() => {
950
+ W.current = n;
951
+ }, [n]);
952
+ const ve = j(() => s.map((c) => c.size), [s]), se = _(!1);
953
+ St(() => {
954
+ if (s.length === 0) {
955
+ se.current = !1;
956
+ return;
957
+ }
958
+ !se.current && (u || s.every((c) => c.collapsed || c.size > 0)) && (se.current = !0), se.current && W.current && W.current(ve);
959
+ }, [ve, s, u]), K(() => {
960
+ if (d && ve.length > 0 && se.current) {
961
+ const c = setTimeout(() => {
962
+ xr(d, ve);
963
+ }, 200);
964
+ return () => clearTimeout(c);
965
+ }
966
+ }, [d, ve]), K(() => {
967
+ if (!d || s.length === 0 || ce.current)
968
+ return;
969
+ const c = e === "horizontal" ? f.width : f.height;
970
+ if (c <= 0)
971
+ return;
972
+ const g = Pr(d);
973
+ if (g && g.length === s.length) {
974
+ const M = s.map((v, Y) => {
975
+ const ae = G(v.minSize, 0, c), re = G(v.maxSize, c, c), T = ye(g[Y], ae, re), he = Fe(T, c), Z = v.sizeUnit === "pixels" || v.originalPixelSize !== void 0 ? T : v.preferredPixelSize;
976
+ return {
977
+ ...v,
978
+ size: T,
979
+ percentageSize: he,
980
+ preferredPercentageSize: he > 0 ? he : v.preferredPercentageSize,
981
+ preferredPixelSize: Z
982
+ };
983
+ });
984
+ i({ type: "SET_PANELS", panels: M }), ce.current = !0;
985
+ }
986
+ }, [d, s, f.width, f.height, e]);
987
+ const Ee = ge((c) => {
988
+ const g = $.current, M = D.current, v = JSON.stringify({
989
+ id: c.id,
990
+ size: c.size ?? null,
991
+ percentageSize: c.percentageSize ?? null,
992
+ preferredPercentageSize: c.preferredPercentageSize ?? null,
993
+ preferredPixelSize: c.preferredPixelSize ?? null,
994
+ sizeUnit: c.sizeUnit,
995
+ originalPixelSize: c.originalPixelSize ?? null,
996
+ minSize: c.minSize ?? null,
997
+ maxSize: c.maxSize ?? null,
998
+ collapseFromStart: c.collapseFromStart,
999
+ collapseFromEnd: c.collapseFromEnd,
1000
+ collapsed: c.collapsed ?? !1,
1001
+ collapsedByDirection: c.collapsedByDirection ?? null,
1002
+ sizeBeforeCollapse: c.sizeBeforeCollapse ?? null,
1003
+ percentageSizeBeforeCollapse: c.percentageSizeBeforeCollapse ?? null,
1004
+ preferredPercentageSizeBeforeCollapse: c.preferredPercentageSizeBeforeCollapse ?? null,
1005
+ preferredPixelSizeBeforeCollapse: c.preferredPixelSizeBeforeCollapse ?? null,
1006
+ pixelAdjustPriority: c.pixelAdjustPriority ?? null,
1007
+ flexAdjustPriority: c.flexAdjustPriority ?? null,
1008
+ autoMinSize: c.autoMinSize ?? null
1009
+ });
1010
+ if (M[c.id] === v) {
1011
+ nt.debug("useResizablePanels.registerPanel skipped", {
1012
+ panelId: c.id,
1013
+ reason: "duplicate-registration"
1014
+ });
1015
+ return;
1016
+ }
1017
+ M[c.id] = v, nt.debug("useResizablePanels.registerPanel", {
1018
+ panelId: c.id,
1019
+ containerReady: A.current,
1020
+ violationReason: y.current,
1021
+ containerSize: {
1022
+ width: g.width,
1023
+ height: g.height
1024
+ }
1025
+ }), i({ type: "REGISTER_PANEL", panel: c });
1026
+ }, []), _e = ge((c) => {
1027
+ const g = $.current;
1028
+ nt.debug("useResizablePanels.unregisterPanel", {
1029
+ panelId: c,
1030
+ containerReady: A.current,
1031
+ violationReason: y.current,
1032
+ containerSize: {
1033
+ width: g.width,
1034
+ height: g.height
1035
+ }
1036
+ }), i({ type: "UNREGISTER_PANEL", id: c }), delete D.current[c], de.current[c] && (clearTimeout(de.current[c]), delete de.current[c]), delete Ge.current[c], b((M) => {
1037
+ if (!(c in M))
1038
+ return M;
1039
+ const v = { ...M };
1040
+ return delete v[c], v;
1041
+ });
1042
+ }, []), ke = ge(
1043
+ (c, g, M, v) => {
1044
+ const Y = e === "horizontal" ? f.width : f.height, ae = s.find((U) => U.id === c), re = s.find((U) => U.id === g);
1045
+ if (!(ae && re)) {
1046
+ i({ type: "RESIZE_PANELS", leftId: c, rightId: g, leftSize: M, rightSize: v, containerSize: Y });
1047
+ return;
1048
+ }
1049
+ if (ae.collapsed || re.collapsed)
1050
+ return;
1051
+ const T = G(ae.minSize, 0, Y), he = G(ae.maxSize, Y, Y), Z = G(re.minSize, 0, Y), E = G(re.maxSize, Y, Y);
1052
+ let S = ye(M, T, he), O = ye(v, Z, E);
1053
+ const X = S + O, Q = M + v;
1054
+ if (Math.abs(X - Q) > 1e-9) {
1055
+ const U = Q - X;
1056
+ if (U > 0) {
1057
+ const q = he - S, o = E - O, w = q + o;
1058
+ if (w > 0) {
1059
+ const J = Math.min(U * (q / w), q), ee = Math.min(U - J, o);
1060
+ S += J, O += ee;
1061
+ }
1062
+ } else if (U < 0) {
1063
+ const q = Math.abs(U), o = S - T, w = O - Z, J = o + w;
1064
+ if (J > 0) {
1065
+ const ee = Math.min(q * (o / J), o), Re = Math.min(q - ee, w);
1066
+ S -= ee, O -= Re;
1067
+ }
1068
+ }
1069
+ }
1070
+ S = ye(S, T, he), O = ye(O, Z, E), Math.abs(S + O - Q) > 1e-9 && nt.error("Total size after constraints should be close to the original total size.", { constrainedLeftSize: S, constrainedRightSize: O, originalTotalSize: Q }), i({ type: "RESIZE_PANELS", leftId: c, rightId: g, leftSize: S, rightSize: O, containerSize: Y });
1071
+ },
1072
+ [e, f.width, f.height, s]
1073
+ ), $e = ge(
1074
+ (c, g) => {
1075
+ const M = e === "horizontal" ? f.width : f.height;
1076
+ i({ type: "COLLAPSE_PANEL", id: c, from: g, containerSize: M });
1077
+ },
1078
+ [e, f.width, f.height]
1079
+ ), C = ge(
1080
+ (c, g, M) => {
1081
+ const v = e === "horizontal" ? f.width : f.height;
1082
+ i({ type: "EXPAND_PANEL", id: c, from: g, containerSize: v, targetSize: M });
1083
+ },
1084
+ [e, f.width, f.height]
1085
+ ), ie = ge(
1086
+ (c) => s.find((g) => g.id === c),
1087
+ [s]
1088
+ ), Se = ge((c, g) => {
1089
+ if (g === null) {
1090
+ de.current[c] && (clearTimeout(de.current[c]), delete de.current[c]), delete Ge.current[c], b((M) => {
1091
+ if (!(c in M))
1092
+ return M;
1093
+ const v = { ...M };
1094
+ return delete v[c], v;
1095
+ });
1096
+ return;
1097
+ }
1098
+ b((M) => {
1099
+ const v = M[c], Y = v && Math.abs(v.pixelSize - g.pixelSize) < 0.1, ae = v && Math.abs(v.percentageSize - g.percentageSize) < 0.01;
1100
+ return Y && ae ? (de.current[c] && clearTimeout(de.current[c]), Ge.current[c] = g, de.current[c] = setTimeout(() => {
1101
+ const re = Ge.current[c];
1102
+ re && b((T) => ({
1103
+ ...T,
1104
+ [c]: re
1105
+ })), delete de.current[c];
1106
+ }, 200), M) : (de.current[c] && (clearTimeout(de.current[c]), delete de.current[c]), {
1107
+ ...M,
1108
+ [c]: g
1109
+ });
1110
+ });
1111
+ }, []), ue = ge((c, g) => {
1112
+ k((M) => {
1113
+ if (g === null) {
1114
+ if (!(c in M))
1115
+ return M;
1116
+ const Y = { ...M };
1117
+ return delete Y[c], Y;
1118
+ }
1119
+ const v = M[c];
1120
+ return v && Math.abs(v.thickness - g.thickness) <= 0.25 && v.visible === g.visible && v.direction === g.direction && v.startPanelId === g.startPanelId && v.endPanelId === g.endPanelId ? M : {
1121
+ ...M,
1122
+ [c]: g
1123
+ };
1124
+ });
1125
+ }, []), we = j(
1126
+ () => ({
1127
+ direction: e,
1128
+ panels: s,
1129
+ containerSize: f,
1130
+ isContainerReady: p,
1131
+ showDebugInfo: r,
1132
+ registerPanel: Ee,
1133
+ unregisterPanel: _e,
1134
+ resizePanels: ke,
1135
+ collapsePanel: $e,
1136
+ expandPanel: C,
1137
+ getPanel: ie,
1138
+ reportPanelMeasurement: Se,
1139
+ panelMeasurements: x,
1140
+ reportHandleMeasurement: ue,
1141
+ handleMeasurements: N,
1142
+ layoutConstraintViolation: z
1143
+ }),
1144
+ [e, s, f, p, r, Ee, _e, ke, $e, C, ie, Se, x, ue, N, z]
1145
+ ), Oe = j(
1146
+ () => ({
1147
+ display: "flex",
1148
+ flexDirection: e === "horizontal" ? "row" : "column",
1149
+ alignItems: "stretch",
1150
+ width: "100%",
1151
+ height: "100%",
1152
+ minWidth: "0px",
1153
+ minHeight: "0px",
1154
+ position: "relative",
1155
+ overflow: "hidden",
1156
+ // リサイズハンドルのはみ出しでスクロールバーを表示させない
1157
+ ...t
1158
+ }),
1159
+ [e, t]
1160
+ );
1161
+ return {
1162
+ groupRef: I,
1163
+ contextValue: we,
1164
+ groupStyle: Oe
1165
+ };
1166
+ }, _r = (e) => {
1167
+ const { getPanel: t, collapsePanel: n, expandPanel: d } = Mt(), r = t(e), s = ge(
1168
+ (h) => {
1169
+ n(e, h);
1170
+ },
1171
+ [n, e]
1172
+ ), i = ge(
1173
+ (h, p) => {
1174
+ d(e, h, p);
1175
+ },
1176
+ [d, e]
1177
+ ), f = ge(
1178
+ (h, p) => {
1179
+ r?.collapsed ? i(h, p) : s(h);
1180
+ },
1181
+ [r?.collapsed, s, i]
1182
+ );
1183
+ return j(
1184
+ () => ({
1185
+ panel: r,
1186
+ isCollapsed: r?.collapsed ?? !1,
1187
+ canCollapseFromStart: r?.collapseFromStart ?? !1,
1188
+ canCollapseFromEnd: r?.collapseFromEnd ?? !1,
1189
+ collapse: s,
1190
+ expand: i,
1191
+ toggle: f
1192
+ }),
1193
+ [r, s, i, f]
1194
+ );
1195
+ }, yr = ({ panel: e, measuredPixelSize: t, measuredPercentageSize: n, containerAxisSize: d, containerLabel: r }) => {
1196
+ const s = e?.size, i = typeof s == "number" && Number.isFinite(s) ? `${s.toFixed(3)}px` : "-", f = e?.percentageSize !== void 0 ? `${e.percentageSize.toFixed(3)}%` : "-", h = Number.isFinite(t) ? `${t.toFixed(3)}px` : "-", p = Number.isFinite(n) ? `${n.toFixed(3)}%` : "-", a = Number.isFinite(d) ? `${d.toFixed(3)}px` : "-", u = `${i} / ${f}`, l = `${h} / ${p}`, z = e?.sizeUnit === "pixels" ? "Fixed" : "Flexible", m = [z, `${r}: ${a}`, `size (state): ${u}`, `size (measured): ${l}`];
1197
+ return {
1198
+ stateValueDisplay: u,
1199
+ measuredValueDisplay: l,
1200
+ containerDisplay: a,
1201
+ headlineLabel: z,
1202
+ titleText: m.join(`
1203
+ `)
1204
+ };
1205
+ }, Mr = yt(({ panel: e, measuredPixelSize: t, measuredPercentageSize: n, containerAxisSize: d, direction: r }) => {
1206
+ const s = r === "horizontal" ? "container width" : "container height", { stateValueDisplay: i, measuredValueDisplay: f, containerDisplay: h, headlineLabel: p, titleText: a } = j(
1207
+ () => yr({
1208
+ panel: e,
1209
+ measuredPixelSize: t,
1210
+ measuredPercentageSize: n,
1211
+ containerAxisSize: d,
1212
+ containerLabel: s
1213
+ }),
1214
+ [e, t, n, d, s]
1215
+ ), u = {
1216
+ position: "absolute",
1217
+ top: "2px",
1218
+ right: "4px",
1219
+ backgroundColor: "rgba(30, 41, 59, 0.6)",
1220
+ color: "#fff",
1221
+ padding: "4px 8px",
1222
+ borderRadius: "6px",
1223
+ fontSize: "11px",
1224
+ fontFamily: "monospace",
1225
+ pointerEvents: "auto",
1226
+ zIndex: 10,
1227
+ boxShadow: "0 2px 4px rgba(0,0,0,0.3)",
1228
+ border: "1px solid rgba(255,255,255,0.1)",
1229
+ maxWidth: "calc(100% - 12px)",
1230
+ minWidth: "60px",
1231
+ width: "fit-content",
1232
+ overflow: "hidden"
1233
+ }, l = {
1234
+ display: "flex",
1235
+ flexDirection: "column",
1236
+ gap: "1px",
1237
+ minWidth: "0",
1238
+ width: "100%"
1239
+ }, z = {
1240
+ display: "flex",
1241
+ justifyContent: "flex-start",
1242
+ alignItems: "center",
1243
+ gap: "6px",
1244
+ fontSize: "10px",
1245
+ color: "#ccc",
1246
+ whiteSpace: "nowrap",
1247
+ overflow: "hidden",
1248
+ textOverflow: "ellipsis",
1249
+ minWidth: "0",
1250
+ width: "100%"
1251
+ }, m = {
1252
+ display: "flex",
1253
+ justifyContent: "space-between",
1254
+ alignItems: "center",
1255
+ gap: "6px",
1256
+ whiteSpace: "nowrap",
1257
+ overflow: "hidden",
1258
+ textOverflow: "ellipsis",
1259
+ minWidth: "0",
1260
+ width: "100%"
1261
+ }, x = {
1262
+ marginLeft: "auto",
1263
+ fontVariantNumeric: "tabular-nums",
1264
+ whiteSpace: "nowrap"
1265
+ };
1266
+ return /* @__PURE__ */ me("div", { style: u, title: a, children: /* @__PURE__ */ Ze("div", { style: l, children: [
1267
+ /* @__PURE__ */ me("div", { style: z, children: /* @__PURE__ */ me("span", { children: p }) }),
1268
+ /* @__PURE__ */ Ze("div", { style: m, children: [
1269
+ /* @__PURE__ */ me("span", { children: s }),
1270
+ /* @__PURE__ */ me("span", { style: x, children: h })
1271
+ ] }),
1272
+ /* @__PURE__ */ Ze("div", { style: m, children: [
1273
+ /* @__PURE__ */ me("span", { children: "size (state)" }),
1274
+ /* @__PURE__ */ me("span", { style: x, children: i })
1275
+ ] }),
1276
+ /* @__PURE__ */ Ze("div", { style: m, children: [
1277
+ /* @__PURE__ */ me("span", { children: "size (measured)" }),
1278
+ /* @__PURE__ */ me("span", { style: x, children: f })
1279
+ ] })
1280
+ ] }) });
1281
+ }), xt = new lt(qe.INFO, "[resize-panels]"), vr = {
1282
+ both: {
1283
+ collapseFromStart: !0,
1284
+ collapseFromEnd: !0
1285
+ },
1286
+ start: {
1287
+ collapseFromStart: !0,
1288
+ collapseFromEnd: !1
1289
+ },
1290
+ end: {
1291
+ collapseFromStart: !1,
1292
+ collapseFromEnd: !0
1293
+ }
1294
+ }, wr = (e) => {
1295
+ if (!e)
1296
+ return {
1297
+ collapseFromStart: !1,
1298
+ collapseFromEnd: !1
1299
+ };
1300
+ const t = vr[e.from];
1301
+ if (!t)
1302
+ throw new Error("Invalid collapsible configuration: unsupported 'from' value");
1303
+ return t;
1304
+ }, Ht = ({ ref: e, setState: t, panelIdRef: n, label: d, timerRef: r }) => (s) => {
1305
+ if (!Number.isFinite(s))
1306
+ return;
1307
+ const i = s < 0 ? 0 : s, f = d === "pixel" ? 0.1 : 0.01;
1308
+ if (Math.abs(e.current - i) < f) {
1309
+ r && (r.current && clearTimeout(r.current), r.current = setTimeout(() => {
1310
+ e.current = i, t(i), r.current = null;
1311
+ }, 200));
1312
+ return;
1313
+ }
1314
+ r?.current && (clearTimeout(r.current), r.current = null), e.current = i, xt.debug(`commit ${d}`, {
1315
+ panelId: n.current,
1316
+ [d]: i
1317
+ }), t(i);
1318
+ }, kr = yt(
1319
+ ({ id: e, defaultSize: t = { value: 50, unit: "percentage" }, minSize: n, maxSize: d, autoMinSize: r, className: s, style: i, children: f, order: h = 0, collapsible: p, defaultCollapsed: a = !1, pixelAdjustPriority: u, flexAdjustPriority: l, contentOverflow: z = "auto" }) => {
1320
+ const { direction: m, registerPanel: x, unregisterPanel: b, getPanel: N, showDebugInfo: k, isContainerReady: I, reportPanelMeasurement: W, containerSize: ce } = Mt(), te = _(null), oe = Ut(), $ = _(e || `panel-${oe}`);
1321
+ K(() => {
1322
+ e && e !== $.current && xt.warn("Panel id prop change after mount is ignored.", {
1323
+ currentId: $.current,
1324
+ attemptedId: e
1325
+ });
1326
+ }, [e]);
1327
+ const A = j(() => wr(p), [p]), y = A.collapseFromStart || A.collapseFromEnd, D = j(() => y ? A.collapseFromStart ? "start" : A.collapseFromEnd ? "end" : null : null, [y, A.collapseFromStart, A.collapseFromEnd]), V = y && a, H = j(() => Sr(t), [t]), L = H?.unit === "pixels", Me = L ? void 0 : H?.value, F = N($.current), de = !!F?.collapsed, Ge = (F?.size ?? 0) <= 0, fe = de || Ge, Ae = _(F);
1328
+ Ae.current = F;
1329
+ const Pe = _(fe);
1330
+ Pe.current = fe;
1331
+ const [ve, se] = Te(() => L && H ? H.value : F?.size !== void 0 ? F.size : 0), [Ee, _e] = Te(() => !L && H ? H.value : F?.percentageSize !== void 0 ? F.percentageSize : 0), ke = _(ve), $e = _(Ee), C = _(null), ie = _(null);
1332
+ K(() => () => {
1333
+ C.current && clearTimeout(C.current), ie.current && clearTimeout(ie.current);
1334
+ }, []);
1335
+ const Se = j(
1336
+ () => Ht({
1337
+ ref: ke,
1338
+ setState: se,
1339
+ panelIdRef: $,
1340
+ label: "pixel",
1341
+ timerRef: C
1342
+ }),
1343
+ []
1344
+ ), ue = j(
1345
+ () => Ht({
1346
+ ref: $e,
1347
+ setState: _e,
1348
+ panelIdRef: $,
1349
+ label: "percentage",
1350
+ timerRef: ie
1351
+ }),
1352
+ []
1353
+ ), we = ge(() => {
1354
+ C.current && (clearTimeout(C.current), C.current = null), ie.current && (clearTimeout(ie.current), ie.current = null), ke.current !== 0 && (ke.current = 0, se(0)), $e.current !== 0 && ($e.current = 0, _e(0));
1355
+ }, []);
1356
+ K(() => {
1357
+ if (!I)
1358
+ return;
1359
+ let E = 0;
1360
+ if (L && H) {
1361
+ let w = H.value;
1362
+ n && typeof n == "object" && n.unit === "pixels" && (w = Math.max(w, n.value)), d && typeof d == "object" && d.unit === "pixels" && (w = Math.min(w, d.value)), E = w;
1363
+ }
1364
+ const S = V, O = S ? D : null;
1365
+ a && !y && xt.warn("Panel defaultCollapsed is ignored because collapsible configuration is not provided.");
1366
+ const X = y && S && L ? E : void 0, Q = y ? Me : void 0, U = L ? E : void 0, q = {
1367
+ id: $.current,
1368
+ size: S ? 0 : E,
1369
+ percentageSize: S ? 0 : Me,
1370
+ preferredPercentageSize: Me,
1371
+ preferredPixelSize: U,
1372
+ sizeUnit: H?.unit || "percentage",
1373
+ originalPixelSize: L ? E : void 0,
1374
+ minSize: n,
1375
+ maxSize: d,
1376
+ collapseFromStart: A.collapseFromStart,
1377
+ collapseFromEnd: A.collapseFromEnd,
1378
+ collapsedByDirection: O,
1379
+ collapsed: S,
1380
+ sizeBeforeCollapse: X,
1381
+ percentageSizeBeforeCollapse: Q,
1382
+ preferredPercentageSizeBeforeCollapse: y ? Me : void 0,
1383
+ preferredPixelSizeBeforeCollapse: y ? U : void 0,
1384
+ pixelAdjustPriority: u,
1385
+ flexAdjustPriority: l,
1386
+ autoMinSize: r
1387
+ };
1388
+ x(q);
1389
+ }, [
1390
+ r,
1391
+ A.collapseFromEnd,
1392
+ A.collapseFromStart,
1393
+ a,
1394
+ H,
1395
+ l,
1396
+ y,
1397
+ I,
1398
+ L,
1399
+ d,
1400
+ n,
1401
+ u,
1402
+ D,
1403
+ Me,
1404
+ x,
1405
+ V
1406
+ ]), K(() => () => {
1407
+ b($.current), W($.current, null);
1408
+ }, [b, W]);
1409
+ const Oe = F?.size ?? 0, c = ge(() => {
1410
+ const E = te.current;
1411
+ if (!E) return;
1412
+ const S = Ae.current;
1413
+ if (!S)
1414
+ return;
1415
+ const O = E.parentElement;
1416
+ if (!O) return;
1417
+ const X = E.getBoundingClientRect(), Q = Ye(O, "horizontal"), U = Ye(O, "vertical"), q = m === "horizontal" ? X.width : X.height, o = m === "horizontal" ? Q.inner : U.inner, w = Ct(o);
1418
+ if (Pe.current) {
1419
+ we();
1420
+ return;
1421
+ }
1422
+ const J = S.size ?? 0, ee = Math.max(2, w * 0.5);
1423
+ if (J > w && q < ee) {
1424
+ xt.debug("skip noisy measurement", {
1425
+ panelId: $.current,
1426
+ expectedPanelSize: J,
1427
+ measured: q,
1428
+ noiseThreshold: ee
1429
+ });
1430
+ return;
1431
+ }
1432
+ if (q > 0) {
1433
+ Se(q), o > 0 && ue(q / o * 100);
1434
+ return;
1435
+ }
1436
+ S.size !== void 0 && Se(S.size), S.percentageSize !== void 0 ? ue(S.percentageSize) : S.sizeUnit === "pixels" && S.size !== void 0 && o > 0 && ue(S.size / o * 100);
1437
+ }, [ue, Se, m, we]), g = _(!1);
1438
+ K(() => {
1439
+ !g.current && F && (g.current = !0, c());
1440
+ }, [F, c]), K(() => {
1441
+ const E = te.current;
1442
+ if (!E) return;
1443
+ const S = new ResizeObserver(() => {
1444
+ c();
1445
+ });
1446
+ S.observe(E), c();
1447
+ const O = [], X = new MutationObserver(() => {
1448
+ (() => {
1449
+ if (!te.current) return !1;
1450
+ const q = te.current.getBoundingClientRect();
1451
+ return (m === "horizontal" ? q.width : q.height) !== ke.current;
1452
+ })() && setTimeout(c, 0);
1453
+ }), Q = E.parentElement;
1454
+ return Q && X.observe(Q, {
1455
+ childList: !0,
1456
+ attributes: !0,
1457
+ attributeFilter: ["style", "class"]
1458
+ }), () => {
1459
+ S.disconnect(), X.disconnect();
1460
+ for (const U of O)
1461
+ clearTimeout(U);
1462
+ };
1463
+ }, [m, c]);
1464
+ const M = F?.size, v = F?.percentageSize, Y = F?.sizeUnit;
1465
+ K(() => {
1466
+ if (F) {
1467
+ if (fe) {
1468
+ we();
1469
+ return;
1470
+ }
1471
+ if (M !== void 0 && Se(M), v !== void 0)
1472
+ ue(v);
1473
+ else if (Y === "pixels" && M !== void 0) {
1474
+ const E = te.current, S = E?.parentElement;
1475
+ if (E && S) {
1476
+ const { width: O, height: X } = E.getBoundingClientRect(), Q = S.clientWidth, U = S.clientHeight, q = m === "horizontal" ? O : X, o = m === "horizontal" ? Q : U;
1477
+ if (q > 0 && o > 0) {
1478
+ const w = q / o * 100;
1479
+ ue(w);
1480
+ }
1481
+ }
1482
+ }
1483
+ }
1484
+ }, [ue, Se, F, v, M, Y, m, fe, we]), K(() => {
1485
+ W($.current, {
1486
+ pixelSize: ve,
1487
+ percentageSize: Ee
1488
+ });
1489
+ }, [W, ve, Ee]);
1490
+ const ae = () => fe ? "0px" : F?.originalPixelSize !== void 0 ? `${Oe}px` : F?.percentageSize !== void 0 ? `${F.percentageSize}%` : `${Oe}px`, re = F?.sizeUnit === "percentage" && !F?.collapsed ? 1 : 0, T = {
1491
+ flexBasis: ae(),
1492
+ flexGrow: 0,
1493
+ flexShrink: re,
1494
+ overflow: "hidden",
1495
+ position: "relative",
1496
+ boxSizing: "border-box",
1497
+ minHeight: "0px",
1498
+ minWidth: "0px",
1499
+ ...i
1500
+ };
1501
+ m === "horizontal" ? (T.height = "100%", T.minWidth = 0) : (T.width = "100%", T.minHeight = 0), fe && (m === "horizontal" ? (T.width = "0px", T.minWidth = "0px") : (T.height = "0px", T.minHeight = "0px"), T.flexGrow = 0, T.flexShrink = 0, T.pointerEvents = "none", T.visibility = "hidden", de && (T.display = "none"));
1502
+ const he = m === "horizontal" ? ce.width : ce.height, Z = j(
1503
+ () => ({
1504
+ position: "absolute",
1505
+ inset: "0px",
1506
+ overflow: z,
1507
+ display: "flex",
1508
+ flexDirection: "column",
1509
+ width: "100%",
1510
+ height: "100%",
1511
+ minWidth: "0px",
1512
+ minHeight: "0px"
1513
+ }),
1514
+ [z]
1515
+ );
1516
+ return /* @__PURE__ */ Ze(
1517
+ "div",
1518
+ {
1519
+ ref: te,
1520
+ className: at("panel", s),
1521
+ style: T,
1522
+ "data-panel-id": $.current,
1523
+ "data-panel-size": Oe,
1524
+ "data-panel-size-unit": F?.sizeUnit || "percentage",
1525
+ "data-panel-pixel-size": F?.sizeUnit === "pixels" ? F?.originalPixelSize : null,
1526
+ "data-panel-order": h,
1527
+ "data-panel-collapsible": y,
1528
+ "data-panel-collapse-start": A.collapseFromStart,
1529
+ "data-panel-collapse-end": A.collapseFromEnd,
1530
+ "data-panel-collapsed": F?.collapsed,
1531
+ "aria-hidden": fe,
1532
+ children: [
1533
+ /* @__PURE__ */ me("div", { style: Z, children: f }),
1534
+ k && /* @__PURE__ */ me(Mr, { panel: F, measuredPixelSize: ve, measuredPercentageSize: Ee, containerAxisSize: he, direction: m })
1535
+ ]
1536
+ }
1537
+ );
1538
+ }
1539
+ ), Er = nr(() => import("./GlobalDebugOverlay-Do70T2l6.js").then((e) => ({ default: e.GlobalDebugOverlayGate })));
1540
+ let Gt = 0;
1541
+ const Br = () => (Gt += 1, `panel-group-${Gt}`), Rr = (e) => {
1542
+ const t = e.reason === "minimum-exceeded", n = t ? "Layout unavailable: minimum panel sizes exceed the container." : "Layout unavailable: panels cannot fill the container with their maximum sizes.", d = t ? `Min required: ${Math.ceil(e.totalMinimumSize ?? 0)}px | Available: ${Math.floor(e.availableContainerSize)}px` : `Max total: ${Math.floor(e.totalMaximumSize ?? 0)}px | Needed: ${Math.floor(e.availableContainerSize)}px`;
1543
+ return { summary: n, detail: d };
1544
+ }, Ir = (e, t) => {
1545
+ let n = !1;
1546
+ const d = e.map((r) => {
1547
+ const s = t[r.id];
1548
+ return !s || r.measuredPixelSize === s.pixelSize && r.measuredPercentageSize === s.percentageSize ? r : (n = !0, {
1549
+ ...r,
1550
+ measuredPixelSize: s.pixelSize,
1551
+ measuredPercentageSize: s.percentageSize
1552
+ });
1553
+ });
1554
+ return n ? d : e;
1555
+ }, $t = (e, t, n) => {
1556
+ const d = Ye(e, "horizontal"), r = Ye(e, "vertical"), s = e.getBoundingClientRect(), i = d.inner > 0 ? d.inner : t ?? s.width, f = r.inner > 0 ? r.inner : n ?? s.height;
1557
+ return { width: i, height: f };
1558
+ }, Or = (e) => {
1559
+ const { id: t, className: n, style: d, children: r, direction: s } = e, { groupRef: i, contextValue: f, groupStyle: h } = Cr(e), [p, a] = Te({ width: 0, height: 0 }), u = f.layoutConstraintViolation, l = !!u, z = j(() => {
1560
+ if (!u)
1561
+ return null;
1562
+ const { summary: y, detail: D } = Rr(u);
1563
+ return /* @__PURE__ */ Ze(
1564
+ "div",
1565
+ {
1566
+ className: "flex w-full flex-1 flex-col items-center justify-center gap-2 rounded-lg border border-slate-300 border-dashed bg-slate-100/70 px-6 py-8 text-center text-slate-600 text-sm dark:border-slate-600 dark:bg-slate-800/50 dark:text-slate-200",
1567
+ "data-panel-group-placeholder": "constraint-violation",
1568
+ children: [
1569
+ /* @__PURE__ */ me("span", { children: y }),
1570
+ /* @__PURE__ */ me("span", { className: "text-slate-500 text-xs dark:text-slate-400", children: D })
1571
+ ]
1572
+ }
1573
+ );
1574
+ }, [u]), x = _(t ?? Br()).current, b = t ?? x, N = f.showDebugInfo && f.panels.length > 0, k = N ? f.panels : [], I = N ? f.panelMeasurements : {}, W = j(() => {
1575
+ if (!N)
1576
+ return [];
1577
+ const y = Object.values(f.handleMeasurements);
1578
+ return y.length <= 1 ? y : y.slice().sort((D, V) => D.id.localeCompare(V.id));
1579
+ }, [f.handleMeasurements, N]), ce = f.containerSize, te = p.width > 0 ? p.width : ce.width, oe = p.height > 0 ? p.height : ce.height;
1580
+ St(() => {
1581
+ if (!N) {
1582
+ a({ width: 0, height: 0 });
1583
+ return;
1584
+ }
1585
+ if (typeof window > "u" || typeof ResizeObserver > "u")
1586
+ return;
1587
+ const y = i.current;
1588
+ if (!y)
1589
+ return;
1590
+ const D = (H) => {
1591
+ a((L) => L.width === H.width && L.height === H.height ? L : H);
1592
+ }, V = new ResizeObserver((H) => {
1593
+ for (const L of H) {
1594
+ if (L.target !== y)
1595
+ continue;
1596
+ const Me = $t(y, L.contentRect.width, L.contentRect.height);
1597
+ D(Me);
1598
+ }
1599
+ });
1600
+ return V.observe(y), D($t(y)), () => {
1601
+ V.disconnect();
1602
+ };
1603
+ }, [i, N]);
1604
+ const $ = j(() => Ir(k, I), [k, I]);
1605
+ K(() => {
1606
+ if (!N)
1607
+ return;
1608
+ let y = !1, D = null;
1609
+ return import("./debugOverlayStore-Cntyxboe.js").then((V) => {
1610
+ y || (D = V, V.enableDebugOverlayGroup(x));
1611
+ }), () => {
1612
+ y = !0, D && (D.disableDebugOverlayGroup(x), D.removeDebugOverlayGroup(x));
1613
+ };
1614
+ }, [N, x]), K(() => {
1615
+ if (!N)
1616
+ return;
1617
+ let y = !1;
1618
+ return import("./debugOverlayStore-Cntyxboe.js").then((D) => {
1619
+ y || D.updateDebugOverlayGroup(x, {
1620
+ displayName: b,
1621
+ direction: s,
1622
+ containerSize: {
1623
+ width: te,
1624
+ height: oe
1625
+ },
1626
+ panels: $,
1627
+ handles: W
1628
+ });
1629
+ }), () => {
1630
+ y = !0;
1631
+ };
1632
+ }, [N, x, b, s, te, oe, $, W]);
1633
+ const A = j(() => {
1634
+ const y = {
1635
+ ...h,
1636
+ ...d
1637
+ };
1638
+ return y.position || (y.position = "relative"), y;
1639
+ }, [h, d]);
1640
+ return /* @__PURE__ */ Ze(jt.Provider, { value: f, children: [
1641
+ /* @__PURE__ */ Ze("div", { ref: i, className: at("panel-group", s === "horizontal" ? "flex-row" : "flex-col", n), style: A, "data-panel-group-id": t, "data-panel-group-direction": s, children: [
1642
+ r,
1643
+ l && z ? /* @__PURE__ */ me(
1644
+ "div",
1645
+ {
1646
+ className: "pointer-events-auto",
1647
+ style: {
1648
+ position: "absolute",
1649
+ inset: 0,
1650
+ zIndex: 40,
1651
+ display: "flex",
1652
+ flexDirection: "column",
1653
+ alignItems: "center",
1654
+ justifyContent: "center",
1655
+ backgroundColor: "rgba(248, 250, 252, 0.82)",
1656
+ backdropFilter: "blur(2px)"
1657
+ },
1658
+ children: z
1659
+ }
1660
+ ) : null
1661
+ ] }),
1662
+ N && /* @__PURE__ */ me(ir, { fallback: null, children: /* @__PURE__ */ me(Er, { groupId: x }) })
1663
+ ] });
1664
+ }, Nr = {
1665
+ display: "none",
1666
+ pointerEvents: "none",
1667
+ visibility: "hidden"
1668
+ }, Fr = {
1669
+ display: "none"
1670
+ }, ot = (e, t) => typeof e != "number" || !Number.isFinite(e) || e <= 0 ? t : e, Ar = (e) => {
1671
+ const t = Math.round(e);
1672
+ return t % 2 === 0 ? t : t + 1;
1673
+ }, Hr = yt((e) => {
1674
+ const { id: t, disabled: n = !1, className: d, style: r, children: s, onDragging: i, thickness: f, indicator: h = !0, indicatorThickness: p, indicatorLength: a, indicatorBarThickness: u, indicatorBarLength: l, title: z } = e, { direction: m, resizePanels: x, getPanel: b, collapsePanel: N, expandPanel: k, panels: I, reportHandleMeasurement: W, containerSize: ce, layoutConstraintViolation: te } = Mt(), [oe, $] = Te(!1), A = _(null), y = _(null), D = _(""), V = _(""), H = _(null), [L, Me] = Te(!1), [F, de] = Te({ left: null, right: null }), Ge = Ut(), fe = _(t ?? `resize-handle-${Ge}`), Ae = _(null), Pe = t ?? fe.current, ve = !!te, se = n || ve, Ee = ge(() => {
1675
+ const P = A.current;
1676
+ if (!P) return;
1677
+ const R = P.parentElement;
1678
+ if (!R) return;
1679
+ y.current = R, typeof window < "u" && Me(window.getComputedStyle(R).direction === "rtl");
1680
+ const B = Array.from(R.children), ne = B.indexOf(P);
1681
+ let le = null, be = null;
1682
+ for (let ze = ne - 1; ze >= 0; ze -= 1) {
1683
+ const Ce = B[ze];
1684
+ if (Ce.dataset.panelId) {
1685
+ le = Ce;
1686
+ break;
1687
+ }
1688
+ }
1689
+ for (let ze = ne + 1; ze < B.length; ze += 1) {
1690
+ const Ce = B[ze];
1691
+ if (Ce.dataset.panelId) {
1692
+ be = Ce;
1693
+ break;
1694
+ }
1695
+ }
1696
+ const xe = le?.dataset.panelId || "", Be = be?.dataset.panelId || "";
1697
+ xe === D.current && Be === V.current || (D.current = xe, V.current = Be, de({
1698
+ left: xe || null,
1699
+ right: Be || null
1700
+ }));
1701
+ }, []), _e = j(() => I.map((P) => P.id).join("|"), [I]);
1702
+ K(() => {
1703
+ Ee();
1704
+ }, [Ee, _e]), K(() => {
1705
+ if (Pe === fe.current)
1706
+ return;
1707
+ const P = fe.current;
1708
+ fe.current = Pe, Ae.current = null, P !== Pe && W(P, null);
1709
+ }, [W, Pe]), K(() => {
1710
+ const P = fe.current;
1711
+ return () => {
1712
+ W(P, null);
1713
+ };
1714
+ }, [W]), K(() => () => {
1715
+ H.current?.();
1716
+ }, []);
1717
+ const ke = ge(
1718
+ (P) => {
1719
+ if (se || !y.current || H.current) return;
1720
+ P.preventDefault(), P.stopPropagation();
1721
+ const R = y.current, { inner: B } = Ye(R, m), ne = { x: P.clientX, y: P.clientY }, le = b(D.current), be = b(V.current);
1722
+ if (!(le && be)) return;
1723
+ const xe = le.size, Be = be.size;
1724
+ let ze = 0;
1725
+ const Ce = hr;
1726
+ $(!0), i?.(!0);
1727
+ const Ie = P.pointerId, je = P.currentTarget, Je = m === "horizontal" && typeof window < "u" && window.getComputedStyle(R).direction === "rtl";
1728
+ je.setPointerCapture(Ie);
1729
+ const Et = (He) => {
1730
+ if (He.pointerId !== Ie || !A.current) return;
1731
+ He.preventDefault(), He.stopPropagation();
1732
+ const Ft = performance.now();
1733
+ if (Ft - ze < Ce) return;
1734
+ ze = Ft;
1735
+ const At = m === "horizontal" ? He.clientX - ne.x : He.clientY - ne.y, Pt = Je ? -At : At;
1736
+ if (Pt === 0)
1737
+ return;
1738
+ const tt = xe + Pt, rt = Be - Pt, We = b(D.current), Ve = b(V.current);
1739
+ if (We && Ve && D.current && V.current) {
1740
+ const ut = G(We.minSize, 0, B), ft = G(Ve.minSize, 0, B), Dt = Math.min(B * Wt, Vt), Lt = Math.min(B * zr, gr), Xt = Ve.collapseFromStart, qt = Ve.collapsedByDirection ?? "start";
1741
+ if (Xt && !Ve.collapsed && rt <= Math.max(ft * 0.3, Dt)) {
1742
+ N(V.current, "start");
1743
+ return;
1744
+ }
1745
+ const Yt = We.collapseFromEnd, Jt = We.collapsedByDirection ?? "end";
1746
+ if (Yt && !We.collapsed && tt <= Math.max(ut * 0.3, Dt)) {
1747
+ N(D.current, "end");
1748
+ return;
1749
+ }
1750
+ if (Ve.collapsed && rt > Math.max(ft * 0.3, Lt)) {
1751
+ k(V.current, qt, rt);
1752
+ return;
1753
+ }
1754
+ if (We.collapsed && tt > Math.max(ut * 0.3, Lt)) {
1755
+ k(D.current, Jt, tt);
1756
+ return;
1757
+ }
1758
+ if (B > 0) {
1759
+ const Tt = We.size + Ve.size, pt = Ct(B);
1760
+ let bt = !1;
1761
+ if (ut <= pt && tt <= pt && xe !== 0) {
1762
+ const it = Math.max(0, Tt - 0);
1763
+ it >= ft && (x(D.current, V.current, 0, it), bt = !0);
1764
+ } else if (ft <= pt && rt <= pt && Be !== 0) {
1765
+ const it = Math.max(0, Tt - 0);
1766
+ it >= ut && (x(D.current, V.current, it, 0), bt = !0);
1767
+ }
1768
+ if (bt)
1769
+ return;
1770
+ }
1771
+ if (We.collapsed || Ve.collapsed)
1772
+ return;
1773
+ x(D.current, V.current, tt, rt);
1774
+ }
1775
+ };
1776
+ let Bt = !0;
1777
+ const dt = () => {
1778
+ Bt && (Bt = !1, H.current = null, $(!1), i?.(!1), document.removeEventListener("pointermove", Et), document.removeEventListener("pointerup", Rt), document.removeEventListener("pointercancel", It), je.removeEventListener("lostpointercapture", Nt), je.hasPointerCapture?.(Ie) && je.releasePointerCapture(Ie));
1779
+ }, Rt = (He) => {
1780
+ He.pointerId === Ie && dt();
1781
+ }, It = (He) => {
1782
+ He.pointerId === Ie && dt();
1783
+ }, Nt = (He) => {
1784
+ He.pointerId === Ie && dt();
1785
+ };
1786
+ document.addEventListener("pointermove", Et), document.addEventListener("pointerup", Rt), document.addEventListener("pointercancel", It), je.addEventListener("lostpointercapture", Nt), H.current = dt;
1787
+ },
1788
+ [se, m, x, b, N, k, i]
1789
+ ), $e = ge(
1790
+ (P) => {
1791
+ if (se) return;
1792
+ const R = m === "horizontal", B = R ? "ArrowLeft" : "ArrowUp", ne = R ? "ArrowRight" : "ArrowDown";
1793
+ if (P.key !== B && P.key !== ne) return;
1794
+ P.preventDefault(), P.stopPropagation();
1795
+ let le = (P.key === ne ? 1 : -1) * (P.shiftKey ? _t * 5 : _t);
1796
+ R && typeof window < "u" && y.current !== null && window.getComputedStyle(y.current).direction === "rtl" && (le = -le);
1797
+ const xe = b(D.current), Be = b(V.current);
1798
+ !(xe && Be) || xe.collapsed || Be.collapsed || x(D.current, V.current, xe.size + le, Be.size - le);
1799
+ },
1800
+ [se, m, b, x]
1801
+ ), C = m === "horizontal", ie = C ? "cursor-col-resize" : "cursor-row-resize", Se = j(
1802
+ () => at(
1803
+ "group absolute z-20 flex select-none items-center justify-center border-none bg-transparent transition-colors duration-150 overflow-visible",
1804
+ ie,
1805
+ C ? "h-full" : "w-full",
1806
+ !se && "hover:bg-gray-200/70 dark:hover:bg-gray-700/70",
1807
+ !se && "active:bg-blue-300/60 dark:active:bg-blue-700/60",
1808
+ oe && "bg-blue-200/80 dark:bg-blue-800/60",
1809
+ se && "cursor-not-allowed opacity-50",
1810
+ "focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50",
1811
+ d
1812
+ ),
1813
+ [ie, C, se, oe, d]
1814
+ ), ue = j(() => {
1815
+ const P = (R) => {
1816
+ if (!R)
1817
+ return -1;
1818
+ for (let B = 0; B < I.length; B += 1)
1819
+ if (I[B].id === R)
1820
+ return B;
1821
+ return -1;
1822
+ };
1823
+ return {
1824
+ left: P(F.left),
1825
+ right: P(F.right)
1826
+ };
1827
+ }, [F.left, F.right, I]), we = C ? ce.width : ce.height, Oe = j(() => {
1828
+ const P = (R, B) => {
1829
+ if (R > B)
1830
+ return 0;
1831
+ let ne = 0;
1832
+ for (let le = R; le <= B; le += 1) {
1833
+ const be = I[le];
1834
+ if (!be)
1835
+ continue;
1836
+ const xe = be.size ?? 0, Be = Math.max(0, xe);
1837
+ ne += be.collapsed ? 0 : Be;
1838
+ }
1839
+ return ne;
1840
+ };
1841
+ return ue.left >= 0 ? P(0, ue.left) : ue.right > 0 ? P(0, ue.right - 1) : 0;
1842
+ }, [ue.left, ue.right, I]), c = j(() => !Number.isFinite(Oe) || Oe < 0 ? 0 : we > 0 && Oe > we ? we : Oe, [Oe, we]), g = typeof h == "object" && h !== null ? h : void 0, M = h === !1 || g?.visible === !1, v = ot(f, sr), Y = C ? lr : cr, ae = C ? ur : fr, re = ot(p ?? g?.thickness, ar), T = ot(a ?? g?.length, Y), he = ot(u ?? g?.barThickness, dr), Z = ot(l ?? g?.barLength, ae), E = Math.max(1, v), S = Math.min(E, Math.max(1, re)), O = Math.max(1, T), X = Math.min(S, Math.max(1, he)), Q = Math.min(O, Math.max(1, Z)), U = j(
1843
+ () => ({
1844
+ "--rp-handle-thickness": `${E}px`,
1845
+ "--rp-indicator-thickness": `${S}px`,
1846
+ "--rp-indicator-length": `${O}px`,
1847
+ "--rp-indicator-bar-thickness": `${X}px`,
1848
+ "--rp-indicator-bar-length": `${Q}px`
1849
+ }),
1850
+ [E, S, O, X, Q]
1851
+ ), q = j(() => {
1852
+ const P = C && L && we > 0 ? we - c : c, R = vt(P - E / 2, 0), B = {
1853
+ position: "absolute",
1854
+ zIndex: 20,
1855
+ touchAction: "none",
1856
+ ...U
1857
+ };
1858
+ return C ? (B.top = 0, B.left = `${R}px`, B.width = `${E}px`, B.height = "100%") : (B.left = 0, B.top = `${R}px`, B.height = `${E}px`, B.width = "100%"), B;
1859
+ }, [c, C, L, we, E, U]), o = j(() => {
1860
+ const P = Ct(we), R = (Ce) => {
1861
+ if (Ce < 0 || Ce >= I.length)
1862
+ return !1;
1863
+ const Ie = I[Ce];
1864
+ return Ie ? Ie.collapsed ? !0 : Ie.size <= P : !1;
1865
+ }, B = (Ce, Ie) => {
1866
+ if (!R(Ce))
1867
+ return 0;
1868
+ let je = 0;
1869
+ for (let Je = Ce; Je >= 0 && Je < I.length && R(Je); Je += Ie)
1870
+ je += 1;
1871
+ return je;
1872
+ }, ne = ue.left, le = ue.right, be = ne >= 0 ? B(ne, -1) : 0, xe = le >= 0 ? B(le, 1) : 0;
1873
+ return {
1874
+ groupSize: be + xe + 1,
1875
+ overlapIndex: be
1876
+ };
1877
+ }, [ue.left, ue.right, I, we]), w = j(() => {
1878
+ if (ve)
1879
+ return !0;
1880
+ if (o.groupSize <= 1)
1881
+ return !1;
1882
+ const P = o.groupSize - 1;
1883
+ return o.overlapIndex > 0 && o.overlapIndex < P;
1884
+ }, [o, ve]), J = j(() => {
1885
+ if (o.groupSize <= 1 || w)
1886
+ return 0;
1887
+ const P = o.groupSize > 1 ? 2 : 1;
1888
+ if (P === 1)
1889
+ return 0;
1890
+ const R = Ar(Math.max(pr, S + 4)), B = o.overlapIndex === 0 ? 0 : P - 1, ne = (P - 1) / 2, le = (B - ne) * R;
1891
+ return C && L ? -le : le;
1892
+ }, [o, w, S, C, L]), ee = j(() => {
1893
+ if (w || M)
1894
+ return Fr;
1895
+ const P = C ? S : O, R = C ? O : S, B = {
1896
+ width: `${P}px`,
1897
+ height: `${R}px`,
1898
+ flexShrink: 0
1899
+ };
1900
+ return J !== 0 && (B.transform = C ? `translateX(${J}px)` : `translateY(${J}px)`), B;
1901
+ }, [w, M, C, S, O, J]), Re = j(() => {
1902
+ const P = C ? X : Q, R = C ? Q : X;
1903
+ return {
1904
+ width: `${P}px`,
1905
+ height: `${R}px`,
1906
+ flexShrink: 0
1907
+ };
1908
+ }, [C, X, Q]), Qe = j(
1909
+ () => at(
1910
+ "pointer-events-none flex items-center justify-center rounded-full bg-white text-slate-700 ring-1 ring-inset ring-white/80 backdrop-blur-sm transition-colors duration-150 shadow-[0_0_0_1px_rgba(255,255,255,0.85),0_1px_3px_rgba(15,23,42,0.18)]",
1911
+ "dark:bg-slate-800/95 dark:text-slate-200 dark:ring-slate-500/60 dark:shadow-[0_0_0_1px_rgba(148,163,184,0.45),0_1px_3px_rgba(2,6,23,0.55)]",
1912
+ oe && "bg-blue-200/80 ring-blue-300 shadow-[0_0_0_1px_rgba(191,219,254,0.65),0_1px_4px_rgba(59,130,246,0.45)] dark:bg-blue-900/70 dark:ring-blue-400 dark:shadow-[0_0_0_1px_rgba(147,197,253,0.5),0_1px_4px_rgba(59,130,246,0.55)]",
1913
+ g?.className
1914
+ ),
1915
+ [oe, g?.className]
1916
+ ), ct = j(
1917
+ () => at(
1918
+ "pointer-events-none rounded-full bg-slate-600 transition-colors duration-150 shadow-[0_0_0_1px_rgba(255,255,255,0.9)] dark:bg-slate-200 dark:shadow-[0_0_0_1px_rgba(15,23,42,0.55)]",
1919
+ oe && "bg-blue-500 dark:bg-blue-300",
1920
+ !se && "group-hover:bg-slate-700 dark:group-hover:bg-slate-100",
1921
+ g?.barClassName
1922
+ ),
1923
+ [oe, se, g?.barClassName]
1924
+ ), De = ge(() => {
1925
+ const P = A.current;
1926
+ if (!P)
1927
+ return;
1928
+ let R = 0;
1929
+ if (!w) {
1930
+ const le = m === "horizontal" ? P.offsetWidth : P.offsetHeight;
1931
+ let be = 0, xe = 0;
1932
+ if (typeof window < "u") {
1933
+ const ze = window.getComputedStyle(P);
1934
+ m === "horizontal" ? (be = Number.parseFloat(ze.marginLeft || "0"), xe = Number.parseFloat(ze.marginRight || "0")) : (be = Number.parseFloat(ze.marginTop || "0"), xe = Number.parseFloat(ze.marginBottom || "0"));
1935
+ }
1936
+ R = [le, be, xe].reduce((ze, Ce) => Number.isFinite(Ce) ? ze + Ce : ze, 0);
1937
+ }
1938
+ (!Number.isFinite(R) || R < 0) && (R = 0);
1939
+ const B = {
1940
+ id: Pe,
1941
+ thickness: R,
1942
+ direction: m,
1943
+ visible: !w && R > mr,
1944
+ startPanelId: F.left,
1945
+ endPanelId: F.right
1946
+ }, ne = Ae.current;
1947
+ ne && Math.abs(ne.thickness - B.thickness) <= 0.25 && ne.visible === B.visible && ne.direction === B.direction && ne.startPanelId === B.startPanelId && ne.endPanelId === B.endPanelId || (Ae.current = B, W(Pe, B));
1948
+ }, [m, F.left, F.right, W, Pe, w]);
1949
+ K(() => {
1950
+ De();
1951
+ }, [De]), K(() => {
1952
+ const P = A.current;
1953
+ if (!P)
1954
+ return;
1955
+ if (typeof ResizeObserver > "u") {
1956
+ De();
1957
+ return;
1958
+ }
1959
+ const R = new ResizeObserver(() => {
1960
+ De();
1961
+ });
1962
+ return R.observe(P), () => {
1963
+ R.disconnect();
1964
+ };
1965
+ }, [De]);
1966
+ const et = j(() => {
1967
+ const P = r ? { ...q, ...r } : q;
1968
+ return w ? {
1969
+ ...P,
1970
+ ...Nr
1971
+ } : P;
1972
+ }, [q, w, r]);
1973
+ return /* @__PURE__ */ me(
1974
+ "button",
1975
+ {
1976
+ type: "button",
1977
+ ref: A,
1978
+ className: Se,
1979
+ style: et,
1980
+ onPointerDown: ke,
1981
+ onKeyDown: $e,
1982
+ disabled: se,
1983
+ "aria-hidden": w || void 0,
1984
+ "aria-label": `Resize ${C ? "columns" : "rows"} - Drag or use arrow keys to resize, drag to the edge to collapse/expand panels`,
1985
+ "data-resize-handle-id": Pe,
1986
+ title: z ?? `Resize ${C ? "columns" : "rows"} - Drag or use arrow keys to resize, drag to the edge to collapse/expand panels`,
1987
+ children: s || !M && /* @__PURE__ */ me("div", { className: Qe, style: ee, "data-resize-handle-indicator": "", "aria-hidden": "true", children: /* @__PURE__ */ me("span", { className: ct, style: Re, "data-resize-handle-indicator-bar": "", "aria-hidden": "true" }) })
1988
+ }
1989
+ );
1990
+ }), wt = (e) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&"), Gr = (e) => typeof document > "u" ? null : document.querySelector(`[data-panel-id="${wt(e)}"]`), $r = (e) => typeof document > "u" ? null : document.querySelector(`[data-panel-group-id="${wt(e)}"]`), Ur = (e) => typeof document > "u" ? null : document.querySelector(`[data-resize-handle-id="${wt(e)}"]`);
1991
+ export {
1992
+ or as P,
1993
+ kr as a,
1994
+ Or as b,
1995
+ jt as c,
1996
+ Hr as d,
1997
+ ye as e,
1998
+ Ye as f,
1999
+ G as g,
2000
+ Gr as h,
2001
+ $r as i,
2002
+ Ur as j,
2003
+ Mt as k,
2004
+ Pr as l,
2005
+ Cr as m,
2006
+ Sr as n,
2007
+ xr as s,
2008
+ _r as u
2009
+ };