@aiquants/resize-panels 1.6.0 → 1.7.2

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,1972 @@
1
+ import { createContext as It, useContext as Nt, useCallback as fe, useMemo as ee, useReducer as At, useState as Ee, useRef as H, useEffect as q, useLayoutEffect as Qe, memo as ot, useId as xt, Suspense as Dt, lazy as Lt } from "react";
2
+ import { jsx as pe, jsxs as Le } from "react/jsx-runtime";
3
+ import { twMerge as Ve } from "tailwind-merge";
4
+ const Pt = It(null), st = () => {
5
+ const e = Nt(Pt);
6
+ if (!e)
7
+ throw new Error("usePanelGroup must be used within a PanelGroup");
8
+ return e;
9
+ }, bt = (e, t = 0) => {
10
+ if (!Number.isFinite(e))
11
+ return e;
12
+ const n = 10 ** t, u = e * n, r = Math.floor(u), s = u - r, i = Number.EPSILON * Math.max(1, Math.abs(u));
13
+ return s < 0.5 - i ? r / n : s > 0.5 + i ? (r + 1) / n : (r % 2 === 0 ? r : r + 1) / n;
14
+ }, Tt = 12, ft = 8, _t = 8, Ot = 8, pt = 10, Ct = 0.05, yt = 10, kt = 0.05, Gt = 20, Ht = 0.05, zt = 0, Mt = 6, ye = (e, t) => t <= 0 ? 0 : bt(e / t * 100, Mt), We = (e, t) => !e || t <= 0 ? 0 : e / 100 * t, Ut = (e, t = "percentage") => {
15
+ if (e !== void 0)
16
+ return typeof e == "number" ? { value: e, unit: t } : e;
17
+ }, W = (e, t, n) => e ? typeof e == "number" ? e / 100 * n : e.unit === "pixels" ? e.value : e.value / 100 * n : t, ge = (e, t, n) => Math.min(Math.max(e, t), n), nt = (e) => {
18
+ if (!Number.isFinite(e) || e <= 0)
19
+ return zt;
20
+ const t = e * Ct, n = Math.min(Tt, yt, t);
21
+ return Math.max(zt, n);
22
+ }, vt = (e, t, n, u = {}) => {
23
+ if (Math.abs(t) <= 0)
24
+ return t;
25
+ const r = u.enforceAutoMinSize ?? !1, s = e.map((a, c) => ({ panel: a, index: c })).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, p = [...s].sort((a, c) => {
29
+ const o = a.panel.pixelAdjustPriority ?? a.index + 1, m = c.panel.pixelAdjustPriority ?? c.index + 1;
30
+ return o === m ? i ? c.index - a.index : a.index - c.index : i ? m - o : o - m;
31
+ });
32
+ let h = t;
33
+ const z = (a) => {
34
+ for (const { index: c } of p) {
35
+ if (Math.abs(h) <= 0)
36
+ break;
37
+ const o = e[c];
38
+ if (!o || o.collapsed)
39
+ continue;
40
+ const m = W(o.minSize, 0, n), b = W(o.maxSize, n, n), C = r ? W(o.autoMinSize, 0, n) : 0, M = Math.max(m, C), E = o.preferredPixelSize !== void 0 ? ge(o.preferredPixelSize, M, b) : o.size, L = o.collapseFromStart || o.collapseFromEnd;
41
+ if (h > 0) {
42
+ if (Math.abs(o.size) <= 0 && (o.percentageSize ?? 0) <= 0)
43
+ continue;
44
+ const O = Math.max(o.size, E), ie = a ? Math.min(b, O) : b, Q = Math.max(0, ie - o.size);
45
+ if (Q <= 0)
46
+ continue;
47
+ const ze = Math.min(Q, h);
48
+ if (ze <= 0)
49
+ continue;
50
+ const T = o.size + ze, U = ye(T, n), w = L ? T : o.sizeBeforeCollapse, V = L ? o.measuredPixelSizeBeforeCollapse ?? o.measuredPixelSize ?? T : o.measuredPixelSizeBeforeCollapse;
51
+ e[c] = {
52
+ ...o,
53
+ size: T,
54
+ percentageSize: U,
55
+ sizeBeforeCollapse: w,
56
+ measuredPixelSizeBeforeCollapse: V,
57
+ measuredPixelSize: void 0,
58
+ measuredPercentageSize: void 0
59
+ }, h -= ze;
60
+ } else {
61
+ const B = a ? E : M, O = Math.max(0, o.size - B);
62
+ if (O <= 0)
63
+ continue;
64
+ const ie = Math.min(O, Math.abs(h));
65
+ if (ie <= 0)
66
+ continue;
67
+ const Q = o.size - ie, ze = ye(Q, n), T = L ? Q : o.sizeBeforeCollapse, U = L ? o.measuredPixelSizeBeforeCollapse ?? o.measuredPixelSize ?? Q : o.measuredPixelSizeBeforeCollapse;
68
+ e[c] = {
69
+ ...o,
70
+ size: Q,
71
+ percentageSize: ze,
72
+ sizeBeforeCollapse: T,
73
+ measuredPixelSizeBeforeCollapse: U,
74
+ measuredPixelSize: void 0,
75
+ measuredPercentageSize: void 0
76
+ }, h += ie;
77
+ }
78
+ }
79
+ };
80
+ return z(!0), (i && h > 0 || !i && h < 0) && z(!1), h;
81
+ }, qe = (e) => {
82
+ if (!e)
83
+ return 0;
84
+ const t = parseFloat(e);
85
+ return Number.isFinite(t) ? t : 0;
86
+ }, Ge = (e, t) => {
87
+ const n = e.getBoundingClientRect(), u = typeof window < "u" ? window.getComputedStyle(e) : null, r = u ? qe(u.borderLeftWidth) + qe(u.borderRightWidth) : 0, s = u ? qe(u.borderTopWidth) + qe(u.borderBottomWidth) : 0;
88
+ if (t === "horizontal") {
89
+ const z = n.width > 0 ? n.width : e.offsetWidth, a = n.width > 0 ? Math.max(0, n.width - r) : e.clientWidth, c = e.offsetWidth > 0 ? e.offsetWidth : e.clientWidth + r;
90
+ return {
91
+ inner: a > 0 ? a : Math.max(0, e.clientWidth),
92
+ outer: z > 0 ? z : Math.max(0, c)
93
+ };
94
+ }
95
+ const i = n.height > 0 ? n.height : e.offsetHeight, p = n.height > 0 ? Math.max(0, n.height - s) : e.clientHeight, h = e.offsetHeight > 0 ? e.offsetHeight : e.clientHeight + s;
96
+ return {
97
+ inner: p > 0 ? p : Math.max(0, e.clientHeight),
98
+ outer: i > 0 ? i : Math.max(0, h)
99
+ };
100
+ }, jt = (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
+ }, $t = (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 ke = /* @__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))(ke || {});
115
+ const Ce = class Ce {
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]", u = console) {
123
+ this.level = t, this.prefix = n, this.impl = u, Ce.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 Ce.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 Ce.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 Ce.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
+ Ce.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
+ Ce.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
+ Ce.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
+ Ce.instance.error(t, ...n);
215
+ }
216
+ error(t, ...n) {
217
+ this.level <= 3 && this.impl.error(...this.formatMessage(t), ...n);
218
+ }
219
+ };
220
+ Ce.instances = /* @__PURE__ */ new Set(), Ce.instance = new Ce(2, "[resize-panels]");
221
+ let Ze = Ce;
222
+ const ue = new Ze(ke.INFO, "[resize-panels]"), Ae = 1e-9, we = (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
+ })), Ke = (e) => e ? we([e])[0] : null, Oe = (e) => e ? !!(e.collapseFromStart || e.collapseFromEnd) : !1, Ye = (e, t) => {
237
+ if (!Number.isFinite(t) || t <= 0)
238
+ return e;
239
+ const n = e.map((h) => ({ ...h })), u = [];
240
+ for (let h = 0; h < n.length; h += 1) {
241
+ const z = n[h];
242
+ if (z.collapsed) {
243
+ n[h] = {
244
+ ...z,
245
+ size: 0,
246
+ percentageSize: 0
247
+ };
248
+ continue;
249
+ }
250
+ const a = Math.max(0, W(z.minSize, 0, t)), c = Math.max(0, W(z.autoMinSize, 0, t)), o = Math.max(a, c), m = Math.max(1e-3, o), b = W(z.maxSize, t, t), C = Math.max(o, b), M = z.sizeUnit === "pixels" || z.originalPixelSize !== void 0, E = Math.max(0, z.size);
251
+ let L = o;
252
+ if (M) {
253
+ const O = z.preferredPixelSize ?? z.size ?? z.originalPixelSize ?? o;
254
+ L = ge(O, o, C);
255
+ } else {
256
+ const O = z.preferredPercentageSize ?? z.percentageSize ?? ye(z.size, t), ie = We(O, t);
257
+ L = ge(ie, o, C);
258
+ }
259
+ const B = !M && (z.excludeFromAutoGrowth ?? !1) && E <= m;
260
+ u.push({
261
+ index: h,
262
+ isPixelPanel: M,
263
+ minSize: o,
264
+ maxSize: C,
265
+ preferredSize: L,
266
+ priority: z.pixelAdjustPriority ?? h + 1,
267
+ flexPriority: M ? void 0 : z.flexAdjustPriority,
268
+ excludeFromGrowth: B
269
+ });
270
+ }
271
+ if (u.length === 0)
272
+ return n;
273
+ const r = /* @__PURE__ */ new Map();
274
+ let s = 0;
275
+ for (const h of u)
276
+ r.set(h.index, h.minSize), s += h.minSize;
277
+ let i = t - s;
278
+ const p = (h, z) => {
279
+ if (z <= 0)
280
+ return 0;
281
+ const a = r.get(h.index) ?? h.minSize, c = Math.max(0, h.maxSize - a);
282
+ if (c <= 0)
283
+ return 0;
284
+ const o = Math.min(z, c);
285
+ return r.set(h.index, a + o), o;
286
+ };
287
+ if (i > 0) {
288
+ const h = (a) => {
289
+ for (; i > 1e-6; ) {
290
+ let o = 0;
291
+ const m = [];
292
+ for (const M of a) {
293
+ if (!M.isPixelPanel && M.excludeFromGrowth)
294
+ continue;
295
+ const E = r.get(M.index) ?? M.minSize, L = Math.min(M.preferredSize, M.maxSize), B = Math.max(0, L - E);
296
+ B > 1e-6 && (o += B, m.push({ descriptor: M, capacity: B }));
297
+ }
298
+ if (m.length === 0 || o <= 1e-6)
299
+ break;
300
+ let b = 0;
301
+ const C = i;
302
+ for (const M of m) {
303
+ if (i <= 1e-6)
304
+ break;
305
+ if (!M.descriptor.isPixelPanel && M.descriptor.excludeFromGrowth)
306
+ continue;
307
+ const E = C * M.capacity / o, L = Math.min(M.capacity, E);
308
+ if (L <= 0)
309
+ continue;
310
+ const B = p(M.descriptor, L);
311
+ B > 0 && (i -= B, b += B);
312
+ }
313
+ if (b <= 1e-6)
314
+ break;
315
+ }
316
+ }, z = u.filter((a) => a.isPixelPanel);
317
+ z.sort((a, c) => c.priority - a.priority);
318
+ for (const a of z) {
319
+ if (i <= 0)
320
+ break;
321
+ const c = r.get(a.index) ?? a.minSize, o = Math.min(a.preferredSize, a.maxSize), m = Math.max(0, o - c);
322
+ if (m <= 0)
323
+ continue;
324
+ const b = p(a, Math.min(m, i));
325
+ b > 0 && (i -= b);
326
+ }
327
+ if (i > 0) {
328
+ const a = u.filter((c) => !c.isPixelPanel);
329
+ if (a.length > 0) {
330
+ const c = a.filter((o) => o.flexPriority !== void 0 && !o.excludeFromGrowth);
331
+ if (c.length > 0) {
332
+ c.sort((o, m) => (m.flexPriority ?? 0) - (o.flexPriority ?? 0));
333
+ for (const o of c) {
334
+ if (i <= 0)
335
+ break;
336
+ if (o.excludeFromGrowth)
337
+ continue;
338
+ const m = r.get(o.index) ?? o.minSize, b = Math.min(o.preferredSize, o.maxSize), C = Math.max(0, b - m);
339
+ if (C <= 0)
340
+ continue;
341
+ const M = p(o, Math.min(C, i));
342
+ M > 0 && (i -= M);
343
+ }
344
+ }
345
+ if (i > 0) {
346
+ const o = c.length > 0 ? a.filter((m) => m.flexPriority === void 0 && !m.excludeFromGrowth) : a.filter((m) => !m.excludeFromGrowth);
347
+ o.length > 0 && h(o);
348
+ }
349
+ }
350
+ }
351
+ }
352
+ if (i > 0) {
353
+ let h = i;
354
+ for (; ; ) {
355
+ let z = 0;
356
+ const a = [];
357
+ for (const o of u) {
358
+ if (!o.isPixelPanel && o.excludeFromGrowth)
359
+ continue;
360
+ const m = r.get(o.index) ?? o.minSize, b = o.isPixelPanel ? Math.min(o.maxSize, o.preferredSize) : o.maxSize, C = Math.max(0, b - m);
361
+ C > 0 && (a.push(o), z += C);
362
+ }
363
+ if (z <= 0)
364
+ break;
365
+ const c = i;
366
+ for (const o of a) {
367
+ if (i <= 0)
368
+ break;
369
+ if (!o.isPixelPanel && o.excludeFromGrowth)
370
+ continue;
371
+ const m = r.get(o.index) ?? o.minSize, b = o.isPixelPanel ? Math.min(o.maxSize, o.preferredSize) : o.maxSize, C = Math.max(0, b - m);
372
+ if (C <= 0)
373
+ continue;
374
+ const M = c * C / z, E = p(o, Math.min(C, M));
375
+ E > 0 && (i -= E);
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 u) {
384
+ const z = r.get(h.index) ?? h.minSize, a = n[h.index], c = Oe(a), o = c ? z : a.sizeBeforeCollapse, m = c ? a.measuredPixelSizeBeforeCollapse ?? a.measuredPixelSize ?? z : a.measuredPixelSizeBeforeCollapse, b = t > 0 ? ye(z, t) : 0;
385
+ n[h.index] = {
386
+ ...a,
387
+ size: z,
388
+ percentageSize: b,
389
+ preferredPercentageSize: a.preferredPercentageSize,
390
+ preferredPixelSize: h.isPixelPanel ? a.preferredPixelSize ?? z : a.preferredPixelSize,
391
+ sizeBeforeCollapse: o,
392
+ measuredPixelSizeBeforeCollapse: m,
393
+ measuredPixelSize: void 0,
394
+ measuredPercentageSize: void 0
395
+ };
396
+ }
397
+ return _e(n);
398
+ }, _e = (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 u = 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 = ye(r.size, t), i = r.measuredPercentageSize, z = (i !== void 0 ? Math.abs(i - s) : 1 / 0) < 1e-4 && i !== void 0 ? i : s, a = bt(z, Mt), o = Math.abs((r.percentageSize ?? 0) - a) > 0 || r.percentageSize === void 0, m = r.sizeBeforeCollapse === void 0 || r.sizeBeforeCollapse !== r.size, b = Oe(r), C = b && m, M = r.measuredPixelSize ?? r.size, E = b && (r.measuredPixelSizeBeforeCollapse === void 0 || r.measuredPixelSizeBeforeCollapse !== M);
423
+ if (!(o || C || E))
424
+ return r;
425
+ n = !0;
426
+ const L = C ? r.size : r.sizeBeforeCollapse, B = E ? M : r.measuredPixelSizeBeforeCollapse;
427
+ return {
428
+ ...r,
429
+ percentageSize: a,
430
+ sizeBeforeCollapse: L,
431
+ measuredPixelSizeBeforeCollapse: B,
432
+ collapsedByDirection: r.collapsed ? r.collapsedByDirection ?? null : null
433
+ };
434
+ });
435
+ return n ? u : e;
436
+ }, Je = (e, t) => {
437
+ if (t <= 0)
438
+ return !1;
439
+ const n = [];
440
+ let u = 0;
441
+ for (let a = 0; a < e.length; a += 1) {
442
+ const c = e[a];
443
+ !c || c.collapsed || (n.push(a), u += c.size);
444
+ }
445
+ if (n.length === 0)
446
+ return !1;
447
+ let r = t - u;
448
+ if (Math.abs(r) <= 0)
449
+ return !1;
450
+ let s = !1;
451
+ const i = (a) => {
452
+ const c = e[a], o = W(c.minSize, 0, t), m = W(c.autoMinSize, 0, t), b = Math.max(o, m), C = W(c.maxSize, t, t), M = c.sizeUnit === "percentage" && c.originalPixelSize === void 0;
453
+ return {
454
+ index: a,
455
+ minSize: b,
456
+ maxSize: C,
457
+ isFlexible: M
458
+ };
459
+ }, p = (a, c) => {
460
+ if (!Number.isFinite(c) || Math.abs(c) <= 0)
461
+ return;
462
+ const o = e[a];
463
+ if (!o)
464
+ return;
465
+ const m = Math.max(0, o.size + c);
466
+ if (Math.abs(m - o.size) <= 0)
467
+ return;
468
+ const b = ye(m, t), C = Oe(o), M = C ? m : o.sizeBeforeCollapse, E = C ? o.measuredPixelSizeBeforeCollapse ?? o.measuredPixelSize ?? m : o.measuredPixelSizeBeforeCollapse;
469
+ e[a] = {
470
+ ...o,
471
+ size: m,
472
+ percentageSize: b,
473
+ sizeBeforeCollapse: M,
474
+ measuredPixelSizeBeforeCollapse: E,
475
+ measuredPixelSize: void 0,
476
+ measuredPercentageSize: void 0
477
+ }, r -= c, s = !0;
478
+ }, h = (a) => {
479
+ for (const c of a) {
480
+ if (Math.abs(r) <= 0)
481
+ break;
482
+ const o = e[c.index];
483
+ if (!o || o.collapsed)
484
+ continue;
485
+ const m = o.size;
486
+ if (r > 0) {
487
+ const b = Math.max(0, c.maxSize - m);
488
+ if (b <= 0)
489
+ continue;
490
+ const C = Math.min(b, r);
491
+ if (C <= 0)
492
+ continue;
493
+ p(c.index, C);
494
+ } else {
495
+ const b = Math.max(0, m - c.minSize);
496
+ if (b <= 0)
497
+ continue;
498
+ const C = Math.min(b, Math.abs(r));
499
+ if (C <= 0)
500
+ continue;
501
+ p(c.index, -C);
502
+ }
503
+ }
504
+ }, z = n.map((a) => i(a)).filter((a) => a.isFlexible);
505
+ if (z.length > 0 && h(z), Math.abs(r) > 0) {
506
+ const a = r;
507
+ r = vt(e, r, t, { enforceAutoMinSize: !0 }), Math.abs(r - a) > 0 && (s = !0);
508
+ }
509
+ return s;
510
+ }, ht = (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, p) => p !== 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
+ }, Wt = (e, t) => {
519
+ switch (t.type) {
520
+ case "REGISTER_PANEL": {
521
+ ue.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], p = {
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 = ht(p, e, n);
541
+ if (ue.debug("register panel (update)", {
542
+ panelId: h.id,
543
+ incoming: Ke(t.panel),
544
+ previous: Ke(i),
545
+ next: Ke(h)
546
+ }), s[n] = h, !h.collapsed) {
547
+ const z = s.reduce((a, c) => c.collapsed ? a : a + c.size, 0);
548
+ if (z > 0) {
549
+ const a = W(h.minSize, 0, z), c = Math.max(a, W(h.maxSize, z, z));
550
+ if (h.size < a - Ae || h.size > c + Ae)
551
+ return Ye(s, z);
552
+ }
553
+ }
554
+ return s;
555
+ }
556
+ const u = { ...t.panel }, r = ht(u, e);
557
+ return ue.debug("register panel (insert)", {
558
+ panelId: r.id,
559
+ incoming: Ke(r),
560
+ previousLength: e.length
561
+ }), [...e, r];
562
+ }
563
+ case "UNREGISTER_PANEL": {
564
+ ue.debug("UNREGISTER_PANEL", t.id);
565
+ const n = e.filter((r) => r.id !== t.id), u = _e(n);
566
+ return ue.enabledFor(ke.DEBUG) && ue.debug("unregister panel", {
567
+ panelId: t.id,
568
+ previous: we(e),
569
+ filtered: we(n),
570
+ next: we(u)
571
+ }), u;
572
+ }
573
+ case "RESIZE_PANELS": {
574
+ ue.debug("RESIZE_PANELS", t.leftId, t.rightId, t.leftSize, t.rightSize);
575
+ const n = e.findIndex((F) => F.id === t.leftId), u = e.findIndex((F) => F.id === t.rightId);
576
+ if (n === -1 || u === -1) return e;
577
+ const r = [...e], s = r[n], i = r[u];
578
+ if (s.collapsed || i.collapsed || t.leftSize === s.size && t.rightSize === i.size)
579
+ return e;
580
+ const p = t.containerSize ?? e.reduce((F, $) => F + $.size, 0), h = W(s.minSize, 0, p), z = W(s.maxSize, p, p), a = W(i.minSize, 0, p), c = W(i.maxSize, p, p), o = s.size + i.size, m = e.reduce((F, $) => $.collapsed ? F : F + $.size, 0), b = m - o, C = h + a, M = z + c, E = ge(t.leftSize + t.rightSize, C, M);
581
+ let L = p > 0 ? p - b : E;
582
+ Number.isFinite(L) || (L = E);
583
+ const B = ge(Math.max(E, L), C, M), O = (F) => ({
584
+ min: Math.max(h, F - c),
585
+ max: Math.min(z, F - a)
586
+ }), ie = (F) => ({
587
+ min: Math.max(a, F - z),
588
+ max: Math.min(c, F - h)
589
+ }), Q = Math.abs(t.leftSize - s.size), ze = Math.abs(t.rightSize - i.size), T = Q >= ze;
590
+ let U = s.size, w = i.size;
591
+ if (T) {
592
+ const F = O(B);
593
+ if (F.min > F.max + Ae)
594
+ return e;
595
+ const $ = ge(t.leftSize, F.min, F.max), le = B - $;
596
+ if (le < a - Ae || le > c + Ae)
597
+ return e;
598
+ U = $, w = ge(le, a, c);
599
+ } else {
600
+ const F = ie(B);
601
+ if (F.min > F.max + Ae)
602
+ return e;
603
+ const $ = ge(t.rightSize, F.min, F.max), le = B - $;
604
+ if (le < h - Ae || le > z + Ae)
605
+ return e;
606
+ w = $, U = ge(le, h, z);
607
+ }
608
+ const V = U + w;
609
+ if (Math.abs(B - V) > Ae)
610
+ return e;
611
+ const ce = m - s.size - i.size + V, k = p > 0 ? p : ce, j = k > 0 ? ye(U, k) : 0, te = k > 0 ? ye(w, k) : 0, G = s.sizeUnit === "pixels" || s.originalPixelSize !== void 0 ? U : s.preferredPixelSize, oe = i.sizeUnit === "pixels" || i.originalPixelSize !== void 0 ? w : i.preferredPixelSize, Be = W(s.autoMinSize, 0, p), me = W(i.autoMinSize, 0, p), de = Math.max(1e-3, Be), Ie = Math.max(1e-3, me), xe = s.sizeUnit === "percentage" && s.originalPixelSize === void 0, se = i.sizeUnit === "percentage" && i.originalPixelSize === void 0;
612
+ let ae = s.excludeFromAutoGrowth, Se = i.excludeFromAutoGrowth;
613
+ xe && (U <= de ? ae = !0 : U > de && (ae = !1)), se && (w <= Ie ? Se = !0 : w > Ie && (Se = !1));
614
+ const Pe = Oe(s), Me = Oe(i);
615
+ return r[n] = {
616
+ ...s,
617
+ size: U,
618
+ percentageSize: j,
619
+ preferredPercentageSize: j > 0 ? j : s.preferredPercentageSize,
620
+ preferredPixelSize: G,
621
+ sizeBeforeCollapse: Pe ? U : s.sizeBeforeCollapse,
622
+ measuredPixelSize: void 0,
623
+ measuredPercentageSize: void 0,
624
+ excludeFromAutoGrowth: ae
625
+ }, r[u] = {
626
+ ...i,
627
+ size: w,
628
+ percentageSize: te,
629
+ preferredPercentageSize: te > 0 ? te : i.preferredPercentageSize,
630
+ preferredPixelSize: oe,
631
+ sizeBeforeCollapse: Me ? w : i.sizeBeforeCollapse,
632
+ measuredPixelSize: void 0,
633
+ measuredPercentageSize: void 0,
634
+ excludeFromAutoGrowth: Se
635
+ }, p > 0 && Je(r, p) ? _e(r) : r;
636
+ }
637
+ case "SET_PANELS": {
638
+ ue.debug("SET_PANELS", t.panels);
639
+ const n = ue.enabledFor(ke.DEBUG), u = t.panels.map((z) => {
640
+ const a = z.sizeUnit === "pixels" || z.originalPixelSize !== void 0, c = z.preferredPercentageSize !== void 0 ? z.preferredPercentageSize : z.percentageSize, o = z.preferredPixelSize !== void 0 ? z.preferredPixelSize : a ? z.size : z.preferredPixelSize;
641
+ return {
642
+ ...z,
643
+ preferredPercentageSize: c,
644
+ preferredPixelSize: o
645
+ };
646
+ }), r = we(e), s = n ? we(u) : null, i = _e(u), p = we(i);
647
+ let h = r.length === p.length;
648
+ if (h)
649
+ for (let z = 0; z < p.length; z += 1) {
650
+ const a = p[z], c = r[z];
651
+ if (!c) {
652
+ h = !1;
653
+ break;
654
+ }
655
+ if (!(c.id === a.id && c.size === a.size && c.percentageSize === a.percentageSize && c.preferredPercentageSize === a.preferredPercentageSize && c.sizeBeforeCollapse === a.sizeBeforeCollapse && c.percentageSizeBeforeCollapse === a.percentageSizeBeforeCollapse && c.preferredPercentageSizeBeforeCollapse === a.preferredPercentageSizeBeforeCollapse && c.measuredPercentageSize === a.measuredPercentageSize && c.excludeFromAutoGrowth === a.excludeFromAutoGrowth && c.collapsed === a.collapsed && c.collapseFromStart === a.collapseFromStart && c.collapseFromEnd === a.collapseFromEnd && c.collapsedByDirection === a.collapsedByDirection)) {
656
+ h = !1;
657
+ break;
658
+ }
659
+ }
660
+ return h ? (n && ue.debug("set panels skipped (no diff)", {
661
+ previous: r,
662
+ incoming: s,
663
+ next: p,
664
+ previousLength: r.length,
665
+ incomingLength: s?.length ?? u.length
666
+ }), e) : (n && ue.debug("set panels", {
667
+ previous: r,
668
+ incoming: s,
669
+ next: p,
670
+ previousLength: r.length,
671
+ incomingLength: s?.length ?? u.length
672
+ }), i);
673
+ }
674
+ case "CONTAINER_RESIZED": {
675
+ ue.debug("CONTAINER_RESIZED", t.containerSize);
676
+ const n = ue.enabledFor(ke.DEBUG);
677
+ if (t.containerSize <= 0)
678
+ return n && ue.debug("container resized skipped (non-positive size)", {
679
+ containerSize: t.containerSize,
680
+ panels: we(e)
681
+ }), e;
682
+ n && ue.debug("container resized (before)", {
683
+ containerSize: t.containerSize,
684
+ panels: we(e)
685
+ });
686
+ const u = Ye(e, t.containerSize);
687
+ if (n && ue.debug("container resized (after recalc)", {
688
+ containerSize: t.containerSize,
689
+ panels: we(u)
690
+ }), t.containerSize > 0 && Je(u, t.containerSize)) {
691
+ const r = _e(u);
692
+ return n && ue.debug("container resized (after reconcile)", {
693
+ containerSize: t.containerSize,
694
+ panels: we(r)
695
+ }), r;
696
+ }
697
+ return n && ue.debug("container resized (final)", {
698
+ containerSize: t.containerSize,
699
+ panels: we(u)
700
+ }), u;
701
+ }
702
+ case "COLLAPSE_PANEL": {
703
+ ue.debug("COLLAPSE_PANEL", t.id);
704
+ const n = e.findIndex((o) => o.id === t.id);
705
+ if (n === -1)
706
+ return e;
707
+ const u = e[n], r = t.from === "start" ? u.collapseFromStart : u.collapseFromEnd;
708
+ if (!(Oe(u) && r) || u.collapsed)
709
+ return e;
710
+ const i = u.size, p = u.measuredPixelSize ?? i, h = u.percentageSize ?? u.preferredPercentageSize ?? 0, z = {
711
+ ...u,
712
+ collapsed: !0,
713
+ collapsedByDirection: t.from,
714
+ sizeBeforeCollapse: i,
715
+ percentageSizeBeforeCollapse: h,
716
+ preferredPercentageSizeBeforeCollapse: u.preferredPercentageSize ?? h,
717
+ preferredPixelSizeBeforeCollapse: u.preferredPixelSize ?? i,
718
+ measuredPixelSizeBeforeCollapse: p,
719
+ size: 0,
720
+ percentageSize: 0,
721
+ preferredPercentageSize: u.preferredPercentageSize,
722
+ measuredPixelSize: u.measuredPixelSize !== void 0 ? 0 : u.measuredPixelSize,
723
+ measuredPercentageSize: u.measuredPercentageSize !== void 0 ? 0 : u.measuredPercentageSize
724
+ }, a = [...e];
725
+ a[n] = z;
726
+ const c = Ye(a, t.containerSize);
727
+ return t.containerSize > 0 && Je(c, t.containerSize) ? _e(c) : c;
728
+ }
729
+ case "EXPAND_PANEL": {
730
+ ue.debug("EXPAND_PANEL", t.id, t.targetSize);
731
+ const n = e.findIndex((B) => B.id === t.id);
732
+ if (n === -1)
733
+ return e;
734
+ const u = t.containerSize, r = e[n], s = t.from === "start" ? r.collapseFromStart : r.collapseFromEnd;
735
+ if (!(Oe(r) && s && r.collapsed) || r.collapsedByDirection && r.collapsedByDirection !== t.from)
736
+ return e;
737
+ const p = [t.targetSize, r.sizeBeforeCollapse, r.measuredPixelSizeBeforeCollapse, r.preferredPixelSizeBeforeCollapse, r.originalPixelSize].find((B) => B !== void 0) ?? 0, h = W(r.minSize, 0, u), z = W(r.maxSize, u, u), a = ge(p, h, z), c = ye(a, u), o = r.measuredPixelSizeBeforeCollapse ?? a, m = ye(o, u), b = r.preferredPercentageSizeBeforeCollapse ?? r.percentageSizeBeforeCollapse ?? c, C = r.preferredPixelSizeBeforeCollapse ?? r.preferredPixelSize ?? a, M = {
738
+ ...r,
739
+ collapsed: !1,
740
+ collapsedByDirection: null,
741
+ size: a,
742
+ percentageSize: c,
743
+ preferredPercentageSize: b,
744
+ preferredPixelSize: C,
745
+ sizeBeforeCollapse: a,
746
+ percentageSizeBeforeCollapse: void 0,
747
+ preferredPercentageSizeBeforeCollapse: void 0,
748
+ preferredPixelSizeBeforeCollapse: void 0,
749
+ measuredPixelSize: a,
750
+ measuredPixelSizeBeforeCollapse: o,
751
+ measuredPercentageSize: m
752
+ }, E = [...e];
753
+ E[n] = M;
754
+ const L = Ye(E, u);
755
+ return u > 0 && Je(L, u) ? _e(L) : L;
756
+ }
757
+ default:
758
+ return e;
759
+ }
760
+ }, $e = new Ze(ke.INFO, "[resize-panels]"), Vt = ({ direction: e, style: t, onLayout: n, autoSaveId: u, showDebugInfo: r = !1 }) => {
761
+ const [s, i] = At(Wt, []), [p, h] = Ee({ width: 0, height: 0 }), [z, a] = Ee(!1), [c, o] = Ee(!1), [m, b] = Ee(null), [C, M] = Ee({}), [E, L] = Ee({}), B = H(null), O = H(n), ie = H(!1), Q = H(0), ze = H(p), T = H(p), U = H(z), w = H(m?.reason ?? null), V = H({}), ce = H(null), k = H(null), j = H(null), te = H({ width: 0, height: 0 }), G = H({ width: 0, height: 0 }), oe = H({}), Be = H({}), me = fe((d) => d.map((x) => ({ ...x })), []);
762
+ q(() => {
763
+ T.current = p;
764
+ }, [p]), q(() => {
765
+ U.current = z;
766
+ }, [z]), q(() => {
767
+ w.current = m?.reason ?? null;
768
+ }, [m?.reason]), q(() => {
769
+ if (m)
770
+ return;
771
+ const d = e === "horizontal" ? p.width : p.height;
772
+ !Number.isFinite(d) || d <= 4 || s.length !== 0 && (ce.current = me(s));
773
+ }, [m, s, e, p.width, p.height, me]);
774
+ const de = H(s);
775
+ q(() => {
776
+ de.current = s;
777
+ }, [s]), q(() => {
778
+ const d = k.current;
779
+ if (m) {
780
+ k.current = m;
781
+ return;
782
+ }
783
+ if (d && !m && ce.current) {
784
+ k.current = null;
785
+ const x = new Set(de.current.map((g) => g.id)), f = me(ce.current).filter((g) => x.has(g.id));
786
+ f.length > 0 && i({ type: "SET_PANELS", panels: f });
787
+ return;
788
+ }
789
+ k.current = m;
790
+ }, [m, me]), Qe(() => {
791
+ if (!B.current) return;
792
+ const d = new ResizeObserver((x) => {
793
+ for (const f of x) {
794
+ const g = f.target, y = g ? Ge(g, "horizontal") : null, I = g ? Ge(g, "vertical") : null, N = y ? y.inner : 0, v = I ? I.inner : 0, _ = f.contentRect.width, A = f.contentRect.height, P = N > 0 ? N : _, S = v > 0 ? v : A;
795
+ te.current = { width: P, height: S };
796
+ const D = G.current, Z = Math.abs(D.width - P) >= 0.5, K = Math.abs(D.height - S) >= 0.5;
797
+ Z || K ? (j.current && (clearTimeout(j.current), j.current = null), !z && P > 0 && S > 0 && a(!0), h({ width: P, height: S }), G.current = { width: P, height: S }) : (j.current && clearTimeout(j.current), j.current = setTimeout(() => {
798
+ const X = te.current;
799
+ h(X), G.current = X, j.current = null;
800
+ }, 150));
801
+ }
802
+ });
803
+ return d.observe(B.current), () => {
804
+ d.disconnect(), j.current && clearTimeout(j.current);
805
+ };
806
+ }, [z]), q(() => () => {
807
+ for (const d of Object.values(oe.current))
808
+ clearTimeout(d);
809
+ }, []), Qe(() => {
810
+ const d = ze.current, x = p, f = e === "horizontal" ? Math.abs(d.width - x.width) >= 0.5 : Math.abs(d.height - x.height) >= 0.5;
811
+ if (c && f) {
812
+ const g = e === "horizontal" ? x.width : x.height;
813
+ i({ type: "CONTAINER_RESIZED", containerSize: g, direction: e });
814
+ }
815
+ ze.current = x;
816
+ }, [p, c, e]);
817
+ const Ie = fe(() => {
818
+ $e.debug("panels[0]?.id", s[0]?.id);
819
+ const d = s.some((l) => {
820
+ if (l.collapsed || l.sizeUnit !== "percentage")
821
+ return !1;
822
+ const re = l.collapseFromStart || l.collapseFromEnd ? l.sizeBeforeCollapse ?? l.measuredPixelSizeBeforeCollapse ?? l.originalPixelSize ?? l.measuredPixelSize ?? 0 : l.measuredPixelSize ?? l.originalPixelSize ?? l.size, J = l.percentageSize !== void 0 && l.percentageSize > 0;
823
+ return l.size <= 0 && (re > 0 || J);
824
+ }), x = e === "horizontal" ? p.width : p.height, f = x > 0;
825
+ if (m || !f || !(s.length > 0 && (s.length !== Q.current || !c || d)))
826
+ return;
827
+ const I = s.filter((l) => !l.collapsed && (l.originalPixelSize !== void 0 || l.sizeUnit === "pixels")).reduce((l, R) => {
828
+ const re = R.preferredPixelSize ?? R.originalPixelSize ?? R.size;
829
+ return l + Math.max(0, re ?? 0);
830
+ }, 0), N = s.filter((l) => l.sizeUnit === "percentage" && !l.collapsed), v = N.map((l) => l.id), _ = N.map((l) => {
831
+ const R = l.preferredPercentageSize ?? l.percentageSize;
832
+ return R !== void 0 && R > 0 ? We(R, x) : l.size > 0 ? l.size : 0;
833
+ }), A = _.reduce((l, R) => l + R, 0), P = x - I, S = Math.max(0, P), D = S > 0, Z = s.map((l) => {
834
+ if (l.collapsed) {
835
+ const R = l.sizeBeforeCollapse ?? l.measuredPixelSizeBeforeCollapse ?? l.originalPixelSize ?? (l.sizeUnit === "pixels" ? l.size : void 0), re = l.sizeUnit === "percentage" && l.percentageSize !== void 0 ? We(l.percentageSize, x) : void 0, J = R ?? re ?? 0, ne = l.measuredPixelSizeBeforeCollapse ?? l.measuredPixelSize ?? J;
836
+ return {
837
+ ...l,
838
+ size: 0,
839
+ percentageSize: 0,
840
+ preferredPercentageSize: l.preferredPercentageSize,
841
+ sizeBeforeCollapse: J,
842
+ percentageSizeBeforeCollapse: l.percentageSizeBeforeCollapse ?? l.percentageSize ?? l.preferredPercentageSize ?? 0,
843
+ preferredPercentageSizeBeforeCollapse: l.preferredPercentageSizeBeforeCollapse ?? l.preferredPercentageSize ?? l.percentageSize ?? void 0,
844
+ preferredPixelSizeBeforeCollapse: l.preferredPixelSizeBeforeCollapse ?? l.preferredPixelSize ?? J,
845
+ measuredPixelSizeBeforeCollapse: ne
846
+ };
847
+ }
848
+ if (l.sizeUnit === "pixels" || l.originalPixelSize !== void 0) {
849
+ const R = l.size, re = x > 0 ? ye(R, x) : 0, J = {
850
+ ...l,
851
+ size: R,
852
+ percentageSize: re,
853
+ preferredPixelSize: l.preferredPixelSize ?? l.originalPixelSize ?? R,
854
+ preferredPercentageSize: l.preferredPercentageSize !== void 0 ? l.preferredPercentageSize : re > 0 ? re : void 0
855
+ };
856
+ if (l.collapseFromStart || l.collapseFromEnd) {
857
+ const ne = l.sizeBeforeCollapse ?? R, He = l.measuredPixelSizeBeforeCollapse ?? l.measuredPixelSize ?? ne;
858
+ J.sizeBeforeCollapse = ne, J.measuredPixelSizeBeforeCollapse = He, J.preferredPixelSizeBeforeCollapse = l.preferredPixelSizeBeforeCollapse ?? l.preferredPixelSize ?? ne;
859
+ }
860
+ return J;
861
+ }
862
+ if (l.sizeUnit === "percentage") {
863
+ const R = v.indexOf(l.id), re = R !== -1 ? _[R] : 0, J = W(l.minSize, 0, x), ne = W(l.maxSize, x, x), He = Math.max(
864
+ J,
865
+ l.sizeBeforeCollapse ?? 0,
866
+ l.measuredPixelSizeBeforeCollapse ?? 0,
867
+ l.measuredPixelSize ?? 0,
868
+ l.originalPixelSize ?? 0,
869
+ l.size > 0 ? l.size : 0,
870
+ l.percentageSize !== void 0 ? We(l.percentageSize, x) : 0,
871
+ 1
872
+ ), Ue = re > 0 ? re : He;
873
+ let Re;
874
+ if (!D)
875
+ Re = J;
876
+ else if (R !== -1 && A > 0) {
877
+ const he = Ue / A, be = S * he;
878
+ Re = ge(be, J, ne);
879
+ } else {
880
+ const he = l.percentageSize !== void 0 ? We(l.percentageSize, x) : l.size, be = he > 0 ? he : Ue;
881
+ Re = ge(be, J, ne);
882
+ }
883
+ const Ne = x > 0 ? ye(Re, x) : 0, Fe = {
884
+ ...l,
885
+ size: Re,
886
+ percentageSize: Ne,
887
+ preferredPercentageSize: l.preferredPercentageSize !== void 0 ? l.preferredPercentageSize : Ne > 0 ? Ne : void 0
888
+ };
889
+ if (l.collapseFromStart || l.collapseFromEnd) {
890
+ const he = l.sizeBeforeCollapse ?? Re, be = l.measuredPixelSizeBeforeCollapse ?? l.measuredPixelSize ?? he;
891
+ Fe.sizeBeforeCollapse = he, Fe.measuredPixelSizeBeforeCollapse = be, Fe.preferredPixelSizeBeforeCollapse = l.preferredPixelSizeBeforeCollapse ?? l.preferredPixelSize ?? he;
892
+ }
893
+ return Fe;
894
+ }
895
+ return l;
896
+ }), K = [];
897
+ for (let l = 0; l < Z.length; l += 1) {
898
+ const R = Z[l];
899
+ R.sizeUnit === "percentage" && !R.collapsed && K.push(l);
900
+ }
901
+ const X = K.reduce((l, R) => l + Z[R].size, 0), Y = P - X;
902
+ Math.abs(Y) > 0 && vt(Z, Y, x, { enforceAutoMinSize: !0 }), i({ type: "SET_PANELS", panels: Z }), Q.current = s.length, o(!0);
903
+ }, [s, e, p.width, p.height, c, m]);
904
+ q(() => {
905
+ const d = e === "horizontal" ? p.width : p.height, x = d > 0, f = x && s.length > 0;
906
+ if (x && s.length === 0) {
907
+ m && b(null);
908
+ return;
909
+ }
910
+ const g = f ? s.reduce((A, P) => {
911
+ if (P.collapsed)
912
+ return A;
913
+ const S = W(P.minSize, 0, d);
914
+ return A + Math.max(0, S);
915
+ }, 0) : null, y = f ? s.reduce((A, P) => {
916
+ if (P.collapsed)
917
+ return A;
918
+ const S = W(P.maxSize, d, d);
919
+ return A + Math.max(0, S);
920
+ }, 0) : null, I = g ?? m?.totalMinimumSize ?? null, N = y ?? m?.totalMaximumSize ?? null;
921
+ if (!x) {
922
+ m && b((A) => !A || A.availableContainerSize === d ? A : {
923
+ reason: A.reason,
924
+ // totalMinimumSize: previous.totalMinimumSize,
925
+ // totalMaximumSize: previous.totalMaximumSize,
926
+ totalMinimumSize: null,
927
+ totalMaximumSize: null,
928
+ availableContainerSize: d
929
+ });
930
+ return;
931
+ }
932
+ const v = I !== null && I - d > Number.EPSILON, _ = N !== null && d - N > Number.EPSILON;
933
+ if (v || _) {
934
+ const P = {
935
+ reason: v ? "minimum-exceeded" : "maximum-insufficient",
936
+ totalMinimumSize: I,
937
+ totalMaximumSize: N,
938
+ availableContainerSize: d
939
+ };
940
+ b((S) => S && S.reason === P.reason && Math.abs((S.totalMinimumSize ?? 0) - (P.totalMinimumSize ?? 0)) <= Number.EPSILON && Math.abs((S.totalMaximumSize ?? 0) - (P.totalMaximumSize ?? 0)) <= Number.EPSILON && Math.abs(S.availableContainerSize - P.availableContainerSize) <= Number.EPSILON ? S : P);
941
+ return;
942
+ }
943
+ if (m) {
944
+ const A = m.reason === "minimum-exceeded", P = m.reason === "maximum-insufficient";
945
+ (!A || I !== null) && (!P || N !== null) && !v && !_ && b((X) => X && null);
946
+ }
947
+ }, [s, e, p.width, p.height, m]), q(() => {
948
+ Ie();
949
+ }, [Ie]), q(() => {
950
+ O.current = n;
951
+ }, [n]);
952
+ const xe = ee(() => s.map((d) => d.size), [s]), se = H(!1);
953
+ Qe(() => {
954
+ if (s.length === 0) {
955
+ se.current = !1;
956
+ return;
957
+ }
958
+ !se.current && (c || s.every((d) => d.collapsed || d.size > 0)) && (se.current = !0), se.current && O.current && O.current(xe);
959
+ }, [xe, s, c]), q(() => {
960
+ if (u && xe.length > 0 && se.current) {
961
+ const d = setTimeout(() => {
962
+ jt(u, xe);
963
+ }, 200);
964
+ return () => clearTimeout(d);
965
+ }
966
+ }, [u, xe]), q(() => {
967
+ if (!u || s.length === 0 || ie.current)
968
+ return;
969
+ const d = e === "horizontal" ? p.width : p.height;
970
+ if (d <= 0)
971
+ return;
972
+ const x = $t(u);
973
+ if (x && x.length === s.length) {
974
+ const f = s.map((g, y) => {
975
+ const I = W(g.minSize, 0, d), N = W(g.maxSize, d, d), v = ge(x[y], I, N), _ = ye(v, d), A = g.sizeUnit === "pixels" || g.originalPixelSize !== void 0 ? v : g.preferredPixelSize;
976
+ return {
977
+ ...g,
978
+ size: v,
979
+ percentageSize: _,
980
+ preferredPercentageSize: _ > 0 ? _ : g.preferredPercentageSize,
981
+ preferredPixelSize: A
982
+ };
983
+ });
984
+ i({ type: "SET_PANELS", panels: f }), ie.current = !0;
985
+ }
986
+ }, [u, s, p.width, p.height, e]);
987
+ const ae = fe((d) => {
988
+ const x = T.current, f = V.current, g = JSON.stringify({
989
+ id: d.id,
990
+ size: d.size ?? null,
991
+ percentageSize: d.percentageSize ?? null,
992
+ preferredPercentageSize: d.preferredPercentageSize ?? null,
993
+ preferredPixelSize: d.preferredPixelSize ?? null,
994
+ sizeUnit: d.sizeUnit,
995
+ originalPixelSize: d.originalPixelSize ?? null,
996
+ minSize: d.minSize ?? null,
997
+ maxSize: d.maxSize ?? null,
998
+ collapseFromStart: d.collapseFromStart,
999
+ collapseFromEnd: d.collapseFromEnd,
1000
+ collapsed: d.collapsed ?? !1,
1001
+ collapsedByDirection: d.collapsedByDirection ?? null,
1002
+ sizeBeforeCollapse: d.sizeBeforeCollapse ?? null,
1003
+ percentageSizeBeforeCollapse: d.percentageSizeBeforeCollapse ?? null,
1004
+ preferredPercentageSizeBeforeCollapse: d.preferredPercentageSizeBeforeCollapse ?? null,
1005
+ preferredPixelSizeBeforeCollapse: d.preferredPixelSizeBeforeCollapse ?? null,
1006
+ pixelAdjustPriority: d.pixelAdjustPriority ?? null,
1007
+ flexAdjustPriority: d.flexAdjustPriority ?? null,
1008
+ autoMinSize: d.autoMinSize ?? null
1009
+ });
1010
+ if (f[d.id] === g) {
1011
+ $e.debug("useResizablePanels.registerPanel skipped", {
1012
+ panelId: d.id,
1013
+ reason: "duplicate-registration"
1014
+ });
1015
+ return;
1016
+ }
1017
+ f[d.id] = g, $e.debug("useResizablePanels.registerPanel", {
1018
+ panelId: d.id,
1019
+ containerReady: U.current,
1020
+ violationReason: w.current,
1021
+ containerSize: {
1022
+ width: x.width,
1023
+ height: x.height
1024
+ }
1025
+ }), i({ type: "REGISTER_PANEL", panel: d });
1026
+ }, []), Se = fe((d) => {
1027
+ const x = T.current;
1028
+ $e.debug("useResizablePanels.unregisterPanel", {
1029
+ panelId: d,
1030
+ containerReady: U.current,
1031
+ violationReason: w.current,
1032
+ containerSize: {
1033
+ width: x.width,
1034
+ height: x.height
1035
+ }
1036
+ }), i({ type: "UNREGISTER_PANEL", id: d }), delete V.current[d], oe.current[d] && (clearTimeout(oe.current[d]), delete oe.current[d]), delete Be.current[d], M((f) => {
1037
+ if (!(d in f))
1038
+ return f;
1039
+ const g = { ...f };
1040
+ return delete g[d], g;
1041
+ });
1042
+ }, []), Pe = fe(
1043
+ (d, x, f, g) => {
1044
+ const y = e === "horizontal" ? p.width : p.height, I = s.find((X) => X.id === d), N = s.find((X) => X.id === x);
1045
+ if (!(I && N)) {
1046
+ i({ type: "RESIZE_PANELS", leftId: d, rightId: x, leftSize: f, rightSize: g, containerSize: y });
1047
+ return;
1048
+ }
1049
+ if (I.collapsed || N.collapsed)
1050
+ return;
1051
+ const v = W(I.minSize, 0, y), _ = W(I.maxSize, y, y), A = W(N.minSize, 0, y), P = W(N.maxSize, y, y);
1052
+ let S = ge(f, v, _), D = ge(g, A, P);
1053
+ const Z = S + D, K = f + g;
1054
+ if (Math.abs(Z - K) > 1e-9) {
1055
+ const X = K - Z;
1056
+ if (X > 0) {
1057
+ const Y = _ - S, l = P - D, R = Y + l;
1058
+ if (R > 0) {
1059
+ const re = Math.min(X * (Y / R), Y), J = Math.min(X - re, l);
1060
+ S += re, D += J;
1061
+ }
1062
+ } else if (X < 0) {
1063
+ const Y = Math.abs(X), l = S - v, R = D - A, re = l + R;
1064
+ if (re > 0) {
1065
+ const J = Math.min(Y * (l / re), l), ne = Math.min(Y - J, R);
1066
+ S -= J, D -= ne;
1067
+ }
1068
+ }
1069
+ }
1070
+ S = ge(S, v, _), D = ge(D, A, P), Math.abs(S + D - K) > 1e-9 && $e.error("Total size after constraints should be close to the original total size.", { constrainedLeftSize: S, constrainedRightSize: D, originalTotalSize: K }), i({ type: "RESIZE_PANELS", leftId: d, rightId: x, leftSize: S, rightSize: D, containerSize: y });
1071
+ },
1072
+ [e, p.width, p.height, s]
1073
+ ), Me = fe(
1074
+ (d, x) => {
1075
+ const f = e === "horizontal" ? p.width : p.height;
1076
+ i({ type: "COLLAPSE_PANEL", id: d, from: x, containerSize: f });
1077
+ },
1078
+ [e, p.width, p.height]
1079
+ ), F = fe(
1080
+ (d, x, f) => {
1081
+ const g = e === "horizontal" ? p.width : p.height;
1082
+ i({ type: "EXPAND_PANEL", id: d, from: x, containerSize: g, targetSize: f });
1083
+ },
1084
+ [e, p.width, p.height]
1085
+ ), $ = fe(
1086
+ (d) => s.find((x) => x.id === d),
1087
+ [s]
1088
+ ), le = fe((d, x) => {
1089
+ if (x === null) {
1090
+ oe.current[d] && (clearTimeout(oe.current[d]), delete oe.current[d]), delete Be.current[d], M((f) => {
1091
+ if (!(d in f))
1092
+ return f;
1093
+ const g = { ...f };
1094
+ return delete g[d], g;
1095
+ });
1096
+ return;
1097
+ }
1098
+ M((f) => {
1099
+ const g = f[d], y = g && Math.abs(g.pixelSize - x.pixelSize) < 0.1, I = g && Math.abs(g.percentageSize - x.percentageSize) < 0.01;
1100
+ return y && I ? (oe.current[d] && clearTimeout(oe.current[d]), Be.current[d] = x, oe.current[d] = setTimeout(() => {
1101
+ const N = Be.current[d];
1102
+ N && M((v) => ({
1103
+ ...v,
1104
+ [d]: N
1105
+ })), delete oe.current[d];
1106
+ }, 200), f) : (oe.current[d] && (clearTimeout(oe.current[d]), delete oe.current[d]), {
1107
+ ...f,
1108
+ [d]: x
1109
+ });
1110
+ });
1111
+ }, []), ve = fe((d, x) => {
1112
+ L((f) => {
1113
+ if (x === null) {
1114
+ if (!(d in f))
1115
+ return f;
1116
+ const y = { ...f };
1117
+ return delete y[d], y;
1118
+ }
1119
+ const g = f[d];
1120
+ return g && Math.abs(g.thickness - x.thickness) <= 0.25 && g.visible === x.visible && g.direction === x.direction && g.startPanelId === x.startPanelId && g.endPanelId === x.endPanelId ? f : {
1121
+ ...f,
1122
+ [d]: x
1123
+ };
1124
+ });
1125
+ }, []), De = ee(
1126
+ () => ({
1127
+ direction: e,
1128
+ panels: s,
1129
+ containerSize: p,
1130
+ isContainerReady: z,
1131
+ showDebugInfo: r,
1132
+ registerPanel: ae,
1133
+ unregisterPanel: Se,
1134
+ resizePanels: Pe,
1135
+ collapsePanel: Me,
1136
+ expandPanel: F,
1137
+ getPanel: $,
1138
+ reportPanelMeasurement: le,
1139
+ panelMeasurements: C,
1140
+ reportHandleMeasurement: ve,
1141
+ handleMeasurements: E,
1142
+ layoutConstraintViolation: m
1143
+ }),
1144
+ [e, s, p, z, r, ae, Se, Pe, Me, F, $, le, C, ve, E, m]
1145
+ ), Te = ee(
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: B,
1163
+ contextValue: De,
1164
+ groupStyle: Te
1165
+ };
1166
+ }, nr = (e) => {
1167
+ const { getPanel: t, collapsePanel: n, expandPanel: u } = st(), r = t(e), s = fe(
1168
+ (h) => {
1169
+ n(e, h);
1170
+ },
1171
+ [n, e]
1172
+ ), i = fe(
1173
+ (h, z) => {
1174
+ u(e, h, z);
1175
+ },
1176
+ [u, e]
1177
+ ), p = fe(
1178
+ (h, z) => {
1179
+ r?.collapsed ? i(h, z) : s(h);
1180
+ },
1181
+ [r?.collapsed, s, i]
1182
+ );
1183
+ return ee(
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: p
1192
+ }),
1193
+ [r, s, i, p]
1194
+ );
1195
+ }, Zt = ({ panel: e, measuredPixelSize: t, measuredPercentageSize: n, containerAxisSize: u, containerLabel: r }) => {
1196
+ const s = e?.size, i = typeof s == "number" && Number.isFinite(s) ? `${s.toFixed(3)}px` : "-", p = e?.percentageSize !== void 0 ? `${e.percentageSize.toFixed(3)}%` : "-", h = Number.isFinite(t) ? `${t.toFixed(3)}px` : "-", z = Number.isFinite(n) ? `${n.toFixed(3)}%` : "-", a = Number.isFinite(u) ? `${u.toFixed(3)}px` : "-", c = `${i} / ${p}`, o = `${h} / ${z}`, m = e?.sizeUnit === "pixels" ? "Fixed" : "Flexible", b = [m, `${r}: ${a}`, `size (state): ${c}`, `size (measured): ${o}`];
1197
+ return {
1198
+ stateValueDisplay: c,
1199
+ measuredValueDisplay: o,
1200
+ containerDisplay: a,
1201
+ headlineLabel: m,
1202
+ titleText: b.join(`
1203
+ `)
1204
+ };
1205
+ }, Xt = ot(({ panel: e, measuredPixelSize: t, measuredPercentageSize: n, containerAxisSize: u, direction: r }) => {
1206
+ const s = r === "horizontal" ? "container width" : "container height", { stateValueDisplay: i, measuredValueDisplay: p, containerDisplay: h, headlineLabel: z, titleText: a } = ee(
1207
+ () => Zt({
1208
+ panel: e,
1209
+ measuredPixelSize: t,
1210
+ measuredPercentageSize: n,
1211
+ containerAxisSize: u,
1212
+ containerLabel: s
1213
+ }),
1214
+ [e, t, n, u, s]
1215
+ ), c = {
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
+ }, o = {
1234
+ display: "flex",
1235
+ flexDirection: "column",
1236
+ gap: "1px",
1237
+ minWidth: "0",
1238
+ width: "100%"
1239
+ }, m = {
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
+ }, b = {
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
+ }, C = {
1262
+ marginLeft: "auto",
1263
+ fontVariantNumeric: "tabular-nums",
1264
+ whiteSpace: "nowrap"
1265
+ };
1266
+ return /* @__PURE__ */ pe("div", { style: c, title: a, children: /* @__PURE__ */ Le("div", { style: o, children: [
1267
+ /* @__PURE__ */ pe("div", { style: m, children: /* @__PURE__ */ pe("span", { children: z }) }),
1268
+ /* @__PURE__ */ Le("div", { style: b, children: [
1269
+ /* @__PURE__ */ pe("span", { children: s }),
1270
+ /* @__PURE__ */ pe("span", { style: C, children: h })
1271
+ ] }),
1272
+ /* @__PURE__ */ Le("div", { style: b, children: [
1273
+ /* @__PURE__ */ pe("span", { children: "size (state)" }),
1274
+ /* @__PURE__ */ pe("span", { style: C, children: i })
1275
+ ] }),
1276
+ /* @__PURE__ */ Le("div", { style: b, children: [
1277
+ /* @__PURE__ */ pe("span", { children: "size (measured)" }),
1278
+ /* @__PURE__ */ pe("span", { style: C, children: p })
1279
+ ] })
1280
+ ] }) });
1281
+ }), et = new Ze(ke.INFO, "[resize-panels]"), qt = {
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
+ }, Kt = (e) => {
1295
+ if (!e)
1296
+ return {
1297
+ collapseFromStart: !1,
1298
+ collapseFromEnd: !1
1299
+ };
1300
+ const t = qt[e.from];
1301
+ if (!t)
1302
+ throw new Error("Invalid collapsible configuration: unsupported 'from' value");
1303
+ return t;
1304
+ }, gt = ({ ref: e, setState: t, panelIdRef: n, label: u, timerRef: r }) => (s) => {
1305
+ if (!Number.isFinite(s))
1306
+ return;
1307
+ const i = s < 0 ? 0 : s, p = u === "pixel" ? 0.1 : 0.01;
1308
+ if (Math.abs(e.current - i) < p) {
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, et.debug(`commit ${u}`, {
1315
+ panelId: n.current,
1316
+ [u]: i
1317
+ }), t(i);
1318
+ }, or = ot(
1319
+ ({ id: e, defaultSize: t = { value: 50, unit: "percentage" }, minSize: n, maxSize: u, autoMinSize: r, className: s, style: i, children: p, order: h = 0, collapsible: z, defaultCollapsed: a = !1, pixelAdjustPriority: c, flexAdjustPriority: o, contentOverflow: m = "auto" }) => {
1320
+ const { direction: b, registerPanel: C, unregisterPanel: M, getPanel: E, showDebugInfo: L, isContainerReady: B, reportPanelMeasurement: O, containerSize: ie } = st(), Q = H(null), ze = xt(), T = H(e || `panel-${ze}`);
1321
+ q(() => {
1322
+ e && e !== T.current && et.warn("Panel id prop change after mount is ignored.", {
1323
+ currentId: T.current,
1324
+ attemptedId: e
1325
+ });
1326
+ }, [e]);
1327
+ const U = ee(() => Kt(z), [z]), w = U.collapseFromStart || U.collapseFromEnd, V = ee(() => w ? U.collapseFromStart ? "start" : U.collapseFromEnd ? "end" : null : null, [w, U.collapseFromStart, U.collapseFromEnd]), ce = w && a, k = ee(() => Ut(t), [t]), j = k?.unit === "pixels", te = j ? void 0 : k?.value, G = E(T.current), oe = !!G?.collapsed, Be = (G?.size ?? 0) <= 0, me = oe || Be, de = H(G);
1328
+ de.current = G;
1329
+ const Ie = H(me);
1330
+ Ie.current = me;
1331
+ const [xe, se] = Ee(() => j && k ? k.value : G?.size !== void 0 ? G.size : 0), [ae, Se] = Ee(() => !j && k ? k.value : G?.percentageSize !== void 0 ? G.percentageSize : 0), Pe = H(xe), Me = H(ae), F = H(null), $ = H(null);
1332
+ q(() => () => {
1333
+ F.current && clearTimeout(F.current), $.current && clearTimeout($.current);
1334
+ }, []);
1335
+ const le = ee(
1336
+ () => gt({
1337
+ ref: Pe,
1338
+ setState: se,
1339
+ panelIdRef: T,
1340
+ label: "pixel",
1341
+ timerRef: F
1342
+ }),
1343
+ []
1344
+ ), ve = ee(
1345
+ () => gt({
1346
+ ref: Me,
1347
+ setState: Se,
1348
+ panelIdRef: T,
1349
+ label: "percentage",
1350
+ timerRef: $
1351
+ }),
1352
+ []
1353
+ ), De = fe(() => {
1354
+ F.current && (clearTimeout(F.current), F.current = null), $.current && (clearTimeout($.current), $.current = null), Pe.current !== 0 && (Pe.current = 0, se(0)), Me.current !== 0 && (Me.current = 0, Se(0));
1355
+ }, []);
1356
+ q(() => {
1357
+ if (!B)
1358
+ return;
1359
+ let P = 0;
1360
+ if (j && k) {
1361
+ let R = k.value;
1362
+ n && typeof n == "object" && n.unit === "pixels" && (R = Math.max(R, n.value)), u && typeof u == "object" && u.unit === "pixels" && (R = Math.min(R, u.value)), P = R;
1363
+ }
1364
+ const S = ce, D = S ? V : null;
1365
+ a && !w && et.warn("Panel defaultCollapsed is ignored because collapsible configuration is not provided.");
1366
+ const Z = w && S && j ? P : void 0, K = w ? te : void 0, X = j ? P : void 0, Y = {
1367
+ id: T.current,
1368
+ size: S ? 0 : P,
1369
+ percentageSize: S ? 0 : te,
1370
+ preferredPercentageSize: te,
1371
+ preferredPixelSize: X,
1372
+ sizeUnit: k?.unit || "percentage",
1373
+ originalPixelSize: j ? P : void 0,
1374
+ minSize: n,
1375
+ maxSize: u,
1376
+ collapseFromStart: U.collapseFromStart,
1377
+ collapseFromEnd: U.collapseFromEnd,
1378
+ collapsedByDirection: D,
1379
+ collapsed: S,
1380
+ sizeBeforeCollapse: Z,
1381
+ percentageSizeBeforeCollapse: K,
1382
+ preferredPercentageSizeBeforeCollapse: w ? te : void 0,
1383
+ preferredPixelSizeBeforeCollapse: w ? X : void 0,
1384
+ pixelAdjustPriority: c,
1385
+ flexAdjustPriority: o,
1386
+ autoMinSize: r
1387
+ };
1388
+ C(Y);
1389
+ }, [
1390
+ r,
1391
+ U.collapseFromEnd,
1392
+ U.collapseFromStart,
1393
+ a,
1394
+ k,
1395
+ o,
1396
+ w,
1397
+ B,
1398
+ j,
1399
+ u,
1400
+ n,
1401
+ c,
1402
+ V,
1403
+ te,
1404
+ C,
1405
+ ce
1406
+ ]), q(() => () => {
1407
+ M(T.current), O(T.current, null);
1408
+ }, [M, O]);
1409
+ const Te = G?.size ?? 0, d = fe(() => {
1410
+ const P = Q.current;
1411
+ if (!P) return;
1412
+ const S = de.current;
1413
+ if (!S)
1414
+ return;
1415
+ const D = P.parentElement;
1416
+ if (!D) return;
1417
+ const Z = P.getBoundingClientRect(), K = Ge(D, "horizontal"), X = Ge(D, "vertical"), Y = b === "horizontal" ? Z.width : Z.height, l = b === "horizontal" ? K.inner : X.inner, R = nt(l);
1418
+ if (Ie.current) {
1419
+ De();
1420
+ return;
1421
+ }
1422
+ const re = S.size ?? 0, J = Math.max(2, R * 0.5);
1423
+ if (re > R && Y < J) {
1424
+ et.debug("skip noisy measurement", {
1425
+ panelId: T.current,
1426
+ expectedPanelSize: re,
1427
+ measured: Y,
1428
+ noiseThreshold: J
1429
+ });
1430
+ return;
1431
+ }
1432
+ if (Y > 0) {
1433
+ le(Y), l > 0 && ve(Y / l * 100);
1434
+ return;
1435
+ }
1436
+ S.size !== void 0 && le(S.size), S.percentageSize !== void 0 ? ve(S.percentageSize) : S.sizeUnit === "pixels" && S.size !== void 0 && l > 0 && ve(S.size / l * 100);
1437
+ }, [ve, le, b, De]), x = H(!1);
1438
+ q(() => {
1439
+ !x.current && G && (x.current = !0, d());
1440
+ }, [G, d]), q(() => {
1441
+ const P = Q.current;
1442
+ if (!P) return;
1443
+ const S = new ResizeObserver(() => {
1444
+ d();
1445
+ });
1446
+ S.observe(P), d();
1447
+ const D = [], Z = new MutationObserver(() => {
1448
+ (() => {
1449
+ if (!Q.current) return !1;
1450
+ const Y = Q.current.getBoundingClientRect();
1451
+ return (b === "horizontal" ? Y.width : Y.height) !== Pe.current;
1452
+ })() && setTimeout(d, 0);
1453
+ }), K = P.parentElement;
1454
+ return K && Z.observe(K, {
1455
+ childList: !0,
1456
+ attributes: !0,
1457
+ attributeFilter: ["style", "class"]
1458
+ }), () => {
1459
+ S.disconnect(), Z.disconnect();
1460
+ for (const X of D)
1461
+ clearTimeout(X);
1462
+ };
1463
+ }, [b, d]);
1464
+ const f = G?.size, g = G?.percentageSize, y = G?.sizeUnit;
1465
+ q(() => {
1466
+ if (G) {
1467
+ if (me) {
1468
+ De();
1469
+ return;
1470
+ }
1471
+ if (f !== void 0 && le(f), g !== void 0)
1472
+ ve(g);
1473
+ else if (y === "pixels" && f !== void 0) {
1474
+ const P = Q.current, S = P?.parentElement;
1475
+ if (P && S) {
1476
+ const { width: D, height: Z } = P.getBoundingClientRect(), K = S.clientWidth, X = S.clientHeight, Y = b === "horizontal" ? D : Z, l = b === "horizontal" ? K : X;
1477
+ if (Y > 0 && l > 0) {
1478
+ const R = Y / l * 100;
1479
+ ve(R);
1480
+ }
1481
+ }
1482
+ }
1483
+ }
1484
+ }, [ve, le, G, g, f, y, b, me, De]), q(() => {
1485
+ O(T.current, {
1486
+ pixelSize: xe,
1487
+ percentageSize: ae
1488
+ });
1489
+ }, [O, xe, ae]);
1490
+ const I = () => me ? "0px" : G?.originalPixelSize !== void 0 ? `${Te}px` : G?.percentageSize !== void 0 ? `${G.percentageSize}%` : `${Te}px`, N = G?.sizeUnit === "percentage" && !G?.collapsed ? 1 : 0, v = {
1491
+ flexBasis: I(),
1492
+ flexGrow: 0,
1493
+ flexShrink: N,
1494
+ overflow: "hidden",
1495
+ position: "relative",
1496
+ boxSizing: "border-box",
1497
+ minHeight: "0px",
1498
+ minWidth: "0px",
1499
+ ...i
1500
+ };
1501
+ b === "horizontal" ? (v.height = "100%", v.minWidth = 0) : (v.width = "100%", v.minHeight = 0), me && (b === "horizontal" ? (v.width = "0px", v.minWidth = "0px") : (v.height = "0px", v.minHeight = "0px"), v.flexGrow = 0, v.flexShrink = 0, v.pointerEvents = "none", v.visibility = "hidden", oe && (v.display = "none"));
1502
+ const _ = b === "horizontal" ? ie.width : ie.height, A = ee(
1503
+ () => ({
1504
+ position: "absolute",
1505
+ inset: "0px",
1506
+ overflow: m,
1507
+ display: "flex",
1508
+ flexDirection: "column",
1509
+ width: "100%",
1510
+ height: "100%",
1511
+ minWidth: "0px",
1512
+ minHeight: "0px"
1513
+ }),
1514
+ [m]
1515
+ );
1516
+ return /* @__PURE__ */ Le(
1517
+ "div",
1518
+ {
1519
+ ref: Q,
1520
+ className: Ve("panel", s),
1521
+ style: v,
1522
+ "data-panel-id": T.current,
1523
+ "data-panel-size": Te,
1524
+ "data-panel-size-unit": G?.sizeUnit || "percentage",
1525
+ "data-panel-pixel-size": G?.sizeUnit === "pixels" ? G?.originalPixelSize : null,
1526
+ "data-panel-order": h,
1527
+ "data-panel-collapsible": w,
1528
+ "data-panel-collapse-start": U.collapseFromStart,
1529
+ "data-panel-collapse-end": U.collapseFromEnd,
1530
+ "data-panel-collapsed": G?.collapsed,
1531
+ "aria-hidden": me,
1532
+ children: [
1533
+ /* @__PURE__ */ pe("div", { style: A, children: p }),
1534
+ L && /* @__PURE__ */ pe(Xt, { panel: G, measuredPixelSize: xe, measuredPercentageSize: ae, containerAxisSize: _, direction: b })
1535
+ ]
1536
+ }
1537
+ );
1538
+ }
1539
+ ), Yt = Lt(() => import("./GlobalDebugOverlay-DYCR0FIu.js").then((e) => ({ default: e.GlobalDebugOverlayGate })));
1540
+ let mt = 0;
1541
+ const Jt = () => (mt += 1, `panel-group-${mt}`), Qt = (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.", u = 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: u };
1544
+ }, er = (e, t) => {
1545
+ let n = !1;
1546
+ const u = 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 ? u : e;
1555
+ }, St = (e, t, n) => {
1556
+ const u = Ge(e, "horizontal"), r = Ge(e, "vertical"), s = e.getBoundingClientRect(), i = u.inner > 0 ? u.inner : t ?? s.width, p = r.inner > 0 ? r.inner : n ?? s.height;
1557
+ return { width: i, height: p };
1558
+ }, sr = (e) => {
1559
+ const { id: t, className: n, style: u, children: r, direction: s } = e, { groupRef: i, contextValue: p, groupStyle: h } = Vt(e), [z, a] = Ee({ width: 0, height: 0 }), c = p.layoutConstraintViolation, o = !!c, m = ee(() => {
1560
+ if (!c)
1561
+ return null;
1562
+ const { summary: w, detail: V } = Qt(c);
1563
+ return /* @__PURE__ */ Le(
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__ */ pe("span", { children: w }),
1570
+ /* @__PURE__ */ pe("span", { className: "text-slate-500 text-xs dark:text-slate-400", children: V })
1571
+ ]
1572
+ }
1573
+ );
1574
+ }, [c]), C = H(t ?? Jt()).current, M = t ?? C, E = p.showDebugInfo && p.panels.length > 0, L = E ? p.panels : [], B = E ? p.panelMeasurements : {}, O = ee(() => {
1575
+ if (!E)
1576
+ return [];
1577
+ const w = Object.values(p.handleMeasurements);
1578
+ return w.length <= 1 ? w : w.slice().sort((V, ce) => V.id.localeCompare(ce.id));
1579
+ }, [p.handleMeasurements, E]), ie = p.containerSize, Q = z.width > 0 ? z.width : ie.width, ze = z.height > 0 ? z.height : ie.height;
1580
+ Qe(() => {
1581
+ if (!E) {
1582
+ a({ width: 0, height: 0 });
1583
+ return;
1584
+ }
1585
+ if (typeof window > "u" || typeof ResizeObserver > "u")
1586
+ return;
1587
+ const w = i.current;
1588
+ if (!w)
1589
+ return;
1590
+ const V = (k) => {
1591
+ a((j) => j.width === k.width && j.height === k.height ? j : k);
1592
+ }, ce = new ResizeObserver((k) => {
1593
+ for (const j of k) {
1594
+ if (j.target !== w)
1595
+ continue;
1596
+ const te = St(w, j.contentRect.width, j.contentRect.height);
1597
+ V(te);
1598
+ }
1599
+ });
1600
+ return ce.observe(w), V(St(w)), () => {
1601
+ ce.disconnect();
1602
+ };
1603
+ }, [i, E]);
1604
+ const T = ee(() => er(L, B), [L, B]);
1605
+ q(() => {
1606
+ if (!E)
1607
+ return;
1608
+ let w = !1, V = null;
1609
+ return import("./debugOverlayStore-Cntyxboe.js").then((ce) => {
1610
+ w || (V = ce, ce.enableDebugOverlayGroup(C));
1611
+ }), () => {
1612
+ w = !0, V && (V.disableDebugOverlayGroup(C), V.removeDebugOverlayGroup(C));
1613
+ };
1614
+ }, [E, C]), q(() => {
1615
+ if (!E)
1616
+ return;
1617
+ let w = !1;
1618
+ return import("./debugOverlayStore-Cntyxboe.js").then((V) => {
1619
+ w || V.updateDebugOverlayGroup(C, {
1620
+ displayName: M,
1621
+ direction: s,
1622
+ containerSize: {
1623
+ width: Q,
1624
+ height: ze
1625
+ },
1626
+ panels: T,
1627
+ handles: O
1628
+ });
1629
+ }), () => {
1630
+ w = !0;
1631
+ };
1632
+ }, [E, C, M, s, Q, ze, T, O]);
1633
+ const U = ee(() => {
1634
+ const w = {
1635
+ ...h,
1636
+ ...u
1637
+ };
1638
+ return w.position || (w.position = "relative"), w;
1639
+ }, [h, u]);
1640
+ return /* @__PURE__ */ Le(Pt.Provider, { value: p, children: [
1641
+ /* @__PURE__ */ Le("div", { ref: i, className: Ve("panel-group", s === "horizontal" ? "flex-row" : "flex-col", n), style: U, "data-panel-group-id": t, "data-panel-group-direction": s, children: [
1642
+ r,
1643
+ o && m ? /* @__PURE__ */ pe(
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: m
1659
+ }
1660
+ ) : null
1661
+ ] }),
1662
+ E && /* @__PURE__ */ pe(Dt, { fallback: null, children: /* @__PURE__ */ pe(Yt, { groupId: C }) })
1663
+ ] });
1664
+ }, ar = ot(({ id: e, disabled: t = !1, className: n, style: u, children: r, onDragging: s }) => {
1665
+ const { direction: i, resizePanels: p, getPanel: h, collapsePanel: z, expandPanel: a, panels: c, reportHandleMeasurement: o, containerSize: m, layoutConstraintViolation: b } = st(), [C, M] = Ee(!1), E = H(null), L = H(null), B = H(""), O = H(""), ie = H(null), [Q, ze] = Ee(!1), [T, U] = Ee({ left: null, right: null }), w = xt(), V = H(e ?? `resize-handle-${w}`), ce = H(null), k = e ?? V.current, j = !!b, te = t || j, G = fe(() => {
1666
+ const f = E.current;
1667
+ if (!f) return;
1668
+ const g = f.parentElement;
1669
+ if (!g) return;
1670
+ L.current = g, typeof window < "u" && ze(window.getComputedStyle(g).direction === "rtl");
1671
+ const y = Array.from(g.children), I = y.indexOf(f);
1672
+ let N = null, v = null;
1673
+ for (let P = I - 1; P >= 0; P -= 1) {
1674
+ const S = y[P];
1675
+ if (S.dataset.panelId) {
1676
+ N = S;
1677
+ break;
1678
+ }
1679
+ }
1680
+ for (let P = I + 1; P < y.length; P += 1) {
1681
+ const S = y[P];
1682
+ if (S.dataset.panelId) {
1683
+ v = S;
1684
+ break;
1685
+ }
1686
+ }
1687
+ const _ = N?.dataset.panelId || "", A = v?.dataset.panelId || "";
1688
+ _ === B.current && A === O.current || (B.current = _, O.current = A, U({
1689
+ left: _ || null,
1690
+ right: A || null
1691
+ }));
1692
+ }, []), oe = ee(() => c.map((f) => f.id).join("|"), [c]);
1693
+ q(() => {
1694
+ G();
1695
+ }, [G, oe]), q(() => {
1696
+ if (k === V.current)
1697
+ return;
1698
+ const f = V.current;
1699
+ V.current = k, ce.current = null, f !== k && o(f, null);
1700
+ }, [o, k]), q(() => {
1701
+ const f = V.current;
1702
+ return () => {
1703
+ o(f, null);
1704
+ };
1705
+ }, [o]), q(() => () => {
1706
+ ie.current?.();
1707
+ }, []);
1708
+ const Be = fe(
1709
+ (f) => {
1710
+ if (te || !L.current || ie.current) return;
1711
+ f.preventDefault(), f.stopPropagation();
1712
+ const g = L.current, { inner: y } = Ge(g, i), I = { x: f.clientX, y: f.clientY }, N = h(B.current), v = h(O.current);
1713
+ if (!(N && v)) return;
1714
+ const _ = N.size, A = v.size;
1715
+ let P = 0;
1716
+ const S = Ot;
1717
+ M(!0), s?.(!0);
1718
+ const D = f.pointerId, Z = f.currentTarget, K = i === "horizontal" && typeof window < "u" && window.getComputedStyle(g).direction === "rtl";
1719
+ Z.setPointerCapture(D);
1720
+ const X = (ne) => {
1721
+ if (ne.pointerId !== D || !E.current) return;
1722
+ ne.preventDefault(), ne.stopPropagation();
1723
+ const He = performance.now();
1724
+ if (He - P < S) return;
1725
+ P = He;
1726
+ const Ue = i === "horizontal" ? ne.clientX - I.x : ne.clientY - I.y, Re = K ? -Ue : Ue;
1727
+ if (Re === 0)
1728
+ return;
1729
+ const Ne = _ + Re, Fe = A - Re, he = h(B.current), be = h(O.current);
1730
+ if (he && be && B.current && O.current) {
1731
+ const tt = W(he.minSize, 0, y), rt = W(be.minSize, 0, y), at = tt, lt = rt, ct = Math.min(y * Ct, yt), dt = Math.min(y * kt, Gt), wt = be.collapseFromStart, Et = be.collapsedByDirection ?? "start";
1732
+ if (wt && !be.collapsed && Fe <= Math.max(rt * 0.3, ct)) {
1733
+ z(O.current, "start");
1734
+ return;
1735
+ }
1736
+ const Bt = he.collapseFromEnd, Rt = he.collapsedByDirection ?? "end";
1737
+ if (Bt && !he.collapsed && Ne <= Math.max(tt * 0.3, ct)) {
1738
+ z(B.current, "end");
1739
+ return;
1740
+ }
1741
+ if (be.collapsed && Fe > Math.max(rt * 0.3, dt)) {
1742
+ a(O.current, Et, Fe);
1743
+ return;
1744
+ }
1745
+ if (he.collapsed && Ne > Math.max(tt * 0.3, dt)) {
1746
+ a(B.current, Rt, Ne);
1747
+ return;
1748
+ }
1749
+ if (y > 0) {
1750
+ const ut = he.size + be.size, Xe = nt(y);
1751
+ let it = !1;
1752
+ if (at <= Xe && Ne <= Xe && _ !== 0) {
1753
+ const je = Math.max(0, ut - 0);
1754
+ je >= lt && (p(B.current, O.current, 0, je), it = !0);
1755
+ } else if (lt <= Xe && Fe <= Xe && A !== 0) {
1756
+ const je = Math.max(0, ut - 0);
1757
+ je >= at && (p(B.current, O.current, je, 0), it = !0);
1758
+ }
1759
+ if (it)
1760
+ return;
1761
+ }
1762
+ if (he.collapsed || be.collapsed)
1763
+ return;
1764
+ p(B.current, O.current, Ne, Fe);
1765
+ }
1766
+ };
1767
+ let Y = !0;
1768
+ const l = () => {
1769
+ Y && (Y = !1, ie.current = null, M(!1), s?.(!1), document.removeEventListener("pointermove", X), document.removeEventListener("pointerup", R), document.removeEventListener("pointercancel", re), Z.removeEventListener("lostpointercapture", J), Z.hasPointerCapture?.(D) && Z.releasePointerCapture(D));
1770
+ }, R = (ne) => {
1771
+ ne.pointerId === D && l();
1772
+ }, re = (ne) => {
1773
+ ne.pointerId === D && l();
1774
+ }, J = (ne) => {
1775
+ ne.pointerId === D && l();
1776
+ };
1777
+ document.addEventListener("pointermove", X), document.addEventListener("pointerup", R), document.addEventListener("pointercancel", re), Z.addEventListener("lostpointercapture", J), ie.current = l;
1778
+ },
1779
+ [te, i, p, h, z, a, s]
1780
+ ), me = fe(
1781
+ (f) => {
1782
+ if (te) return;
1783
+ const g = i === "horizontal", y = g ? "ArrowLeft" : "ArrowUp", I = g ? "ArrowRight" : "ArrowDown";
1784
+ if (f.key !== y && f.key !== I) return;
1785
+ f.preventDefault(), f.stopPropagation();
1786
+ let N = (f.key === I ? 1 : -1) * (f.shiftKey ? pt * 5 : pt);
1787
+ g && typeof window < "u" && L.current !== null && window.getComputedStyle(L.current).direction === "rtl" && (N = -N);
1788
+ const _ = h(B.current), A = h(O.current);
1789
+ !(_ && A) || _.collapsed || A.collapsed || p(B.current, O.current, _.size + N, A.size - N);
1790
+ },
1791
+ [te, i, h, p]
1792
+ ), de = i === "horizontal", xe = Ve(
1793
+ "group absolute z-20 flex select-none items-center justify-center border-none bg-transparent transition-colors duration-150 overflow-visible",
1794
+ de ? "cursor-col-resize" : "cursor-row-resize",
1795
+ de ? "h-full" : "w-full",
1796
+ !te && "hover:bg-gray-200/70 dark:hover:bg-gray-700/70",
1797
+ !te && "active:bg-blue-300/60 dark:active:bg-blue-700/60",
1798
+ C && "bg-blue-200/80 dark:bg-blue-800/60",
1799
+ te && "cursor-not-allowed opacity-50",
1800
+ "focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50",
1801
+ n
1802
+ ), se = ee(() => {
1803
+ const f = (g) => {
1804
+ if (!g)
1805
+ return -1;
1806
+ for (let y = 0; y < c.length; y += 1)
1807
+ if (c[y].id === g)
1808
+ return y;
1809
+ return -1;
1810
+ };
1811
+ return {
1812
+ left: f(T.left),
1813
+ right: f(T.right)
1814
+ };
1815
+ }, [T.left, T.right, c]), ae = de ? m.width : m.height, Se = ee(() => {
1816
+ const f = (g, y) => {
1817
+ if (g > y)
1818
+ return 0;
1819
+ let I = 0;
1820
+ for (let N = g; N <= y; N += 1) {
1821
+ const v = c[N];
1822
+ if (!v)
1823
+ continue;
1824
+ const _ = v.size ?? 0, A = Math.max(0, _);
1825
+ I += v.collapsed ? 0 : A;
1826
+ }
1827
+ return I;
1828
+ };
1829
+ return se.left >= 0 ? f(0, se.left) : se.right > 0 ? f(0, se.right - 1) : 0;
1830
+ }, [se.left, se.right, c]), Pe = ee(() => !Number.isFinite(Se) || Se < 0 ? 0 : ae > 0 && Se > ae ? ae : Se, [Se, ae]), Me = ee(() => {
1831
+ const f = {
1832
+ position: "absolute",
1833
+ zIndex: 20,
1834
+ touchAction: "none"
1835
+ };
1836
+ return de ? (f.top = 0, f.left = Q && ae > 0 ? `${ae - Pe}px` : `${Pe}px`, f.transform = "translateX(-50%)", f.width = `${ft}px`, f.height = "100%") : (f.left = 0, f.top = `${Pe}px`, f.transform = "translateY(-50%)", f.height = `${ft}px`, f.width = "100%"), f;
1837
+ }, [Pe, de, Q, ae]), F = ee(() => {
1838
+ const f = nt(ae), g = (S) => {
1839
+ if (S < 0 || S >= c.length)
1840
+ return !1;
1841
+ const D = c[S];
1842
+ return D ? D.collapsed ? !0 : D.size <= f : !1;
1843
+ }, y = (S, D) => {
1844
+ if (!g(S))
1845
+ return 0;
1846
+ let Z = 0;
1847
+ for (let K = S; K >= 0 && K < c.length && g(K); K += D)
1848
+ Z += 1;
1849
+ return Z;
1850
+ }, I = se.left, N = se.right, v = I >= 0 ? y(I, -1) : 0, _ = N >= 0 ? y(N, 1) : 0;
1851
+ return {
1852
+ groupSize: v + _ + 1,
1853
+ overlapIndex: v
1854
+ };
1855
+ }, [se.left, se.right, c, ae]), $ = ee(() => {
1856
+ if (j)
1857
+ return !0;
1858
+ if (F.groupSize <= 1)
1859
+ return !1;
1860
+ const f = F.groupSize - 1;
1861
+ return F.overlapIndex > 0 && F.overlapIndex < f;
1862
+ }, [F, j]), le = ee(() => {
1863
+ if (F.groupSize <= 1 || $)
1864
+ return 0;
1865
+ const f = F.groupSize > 1 ? 2 : 1;
1866
+ if (f === 1)
1867
+ return 0;
1868
+ const g = F.overlapIndex === 0 ? 0 : f - 1, y = (f - 1) / 2;
1869
+ return (g - y) * _t;
1870
+ }, [F, $]), ve = ee(() => {
1871
+ if ($)
1872
+ return { display: "none" };
1873
+ if (le !== 0)
1874
+ return de ? { transform: `translateX(${le}px)` } : { transform: `translateY(${le}px)` };
1875
+ }, [le, de, $]), De = Ve(
1876
+ "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)]",
1877
+ "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)]",
1878
+ de ? "h-12 w-[6px] px-[2px]" : "h-[6px] w-20 py-[2px]",
1879
+ C && "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)]"
1880
+ ), Te = Ve(
1881
+ "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)]",
1882
+ de ? "h-8 w-[2px]" : "h-[2px] w-16",
1883
+ C && "bg-blue-500 dark:bg-blue-300",
1884
+ !te && "group-hover:bg-slate-700 dark:group-hover:bg-slate-100"
1885
+ ), d = fe(() => {
1886
+ const f = E.current;
1887
+ if (!f)
1888
+ return;
1889
+ let g = 0;
1890
+ if (!$) {
1891
+ const N = i === "horizontal" ? f.offsetWidth : f.offsetHeight;
1892
+ let v = 0, _ = 0;
1893
+ if (typeof window < "u") {
1894
+ const P = window.getComputedStyle(f);
1895
+ i === "horizontal" ? (v = Number.parseFloat(P.marginLeft || "0"), _ = Number.parseFloat(P.marginRight || "0")) : (v = Number.parseFloat(P.marginTop || "0"), _ = Number.parseFloat(P.marginBottom || "0"));
1896
+ }
1897
+ g = [N, v, _].reduce((P, S) => Number.isFinite(S) ? P + S : P, 0);
1898
+ }
1899
+ (!Number.isFinite(g) || g < 0) && (g = 0);
1900
+ const y = {
1901
+ id: k,
1902
+ thickness: g,
1903
+ direction: i,
1904
+ visible: !$ && g > Ht,
1905
+ startPanelId: T.left,
1906
+ endPanelId: T.right
1907
+ }, I = ce.current;
1908
+ I && Math.abs(I.thickness - y.thickness) <= 0.25 && I.visible === y.visible && I.direction === y.direction && I.startPanelId === y.startPanelId && I.endPanelId === y.endPanelId || (ce.current = y, o(k, y));
1909
+ }, [i, T.left, T.right, o, k, $]);
1910
+ q(() => {
1911
+ d();
1912
+ }, [d]), q(() => {
1913
+ const f = E.current;
1914
+ if (!f)
1915
+ return;
1916
+ if (typeof ResizeObserver > "u") {
1917
+ d();
1918
+ return;
1919
+ }
1920
+ const g = new ResizeObserver(() => {
1921
+ d();
1922
+ });
1923
+ return g.observe(f), () => {
1924
+ g.disconnect();
1925
+ };
1926
+ }, [d]);
1927
+ const x = ee(() => {
1928
+ const f = u ? { ...Me, ...u } : Me;
1929
+ return $ ? {
1930
+ ...f,
1931
+ display: "none",
1932
+ pointerEvents: "none",
1933
+ visibility: "hidden"
1934
+ } : f;
1935
+ }, [Me, $, u]);
1936
+ return /* @__PURE__ */ pe(
1937
+ "button",
1938
+ {
1939
+ type: "button",
1940
+ ref: E,
1941
+ className: xe,
1942
+ style: x,
1943
+ onPointerDown: Be,
1944
+ onKeyDown: me,
1945
+ disabled: te,
1946
+ "aria-hidden": $ || void 0,
1947
+ "aria-label": `Resize ${de ? "columns" : "rows"} - Drag or use arrow keys to resize, drag to the edge to collapse/expand panels`,
1948
+ "data-resize-handle-id": k,
1949
+ title: `ドラッグして${de ? "列" : "行"}をリサイズ、端まで移動して折りたたみ/展開`,
1950
+ children: r || /* @__PURE__ */ pe("div", { className: De, style: ve, children: /* @__PURE__ */ pe("span", { className: Te }) })
1951
+ }
1952
+ );
1953
+ }), lr = (e) => document.querySelector(`[data-panel-id="${e}"]`), cr = (e) => document.querySelector(`[data-panel-group-id="${e}"]`), dr = (e) => document.querySelector(`[data-resize-handle-id="${e}"]`);
1954
+ export {
1955
+ Tt as P,
1956
+ or as a,
1957
+ sr as b,
1958
+ Pt as c,
1959
+ ar as d,
1960
+ ge as e,
1961
+ Ge as f,
1962
+ W as g,
1963
+ lr as h,
1964
+ cr as i,
1965
+ dr as j,
1966
+ st as k,
1967
+ $t as l,
1968
+ Vt as m,
1969
+ Ut as n,
1970
+ jt as s,
1971
+ nr as u
1972
+ };