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