@aiquants/resize-panels 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1500 @@
1
+ import { createContext as ft, useContext as ht, useCallback as k, useMemo as P, useReducer as mt, useState as Ne, useRef as F, useLayoutEffect as Se, useEffect as Q, memo as pn, useId as fn, Suspense as gt, lazy as bt } from "react";
2
+ import { jsxs as he, jsx as ie } from "react/jsx-runtime";
3
+ import { twMerge as De } from "tailwind-merge";
4
+ import { flushSync as An } from "react-dom";
5
+ const xt = 12, L = 1e-6, St = 8, yt = 6, Et = 48, zt = 80, Pt = 2, wt = 32, vt = 64, Nt = 8, Rt = 8, It = 4, _n = 10, Hn = 0.05, Gn = 10, Lt = 0.05, At = 20, _t = 0.05, Ot = (e, n = 0) => {
6
+ if (!Number.isFinite(e))
7
+ return e;
8
+ const t = 10 ** n, r = e * t, o = Math.floor(r), i = r - o, s = Number.EPSILON * Math.max(1, Math.abs(r));
9
+ return i < 0.5 - s ? o / t : i > 0.5 + s ? (o + 1) / t : (o % 2 === 0 ? o : o + 1) / t;
10
+ }, Dt = 6, jn = (e, n) => n <= 0 ? 0 : Ot(e / n * 100, Dt), qr = (e, n) => n <= 0 ? 0 : e / 100 * n, Tt = (e, n = "percentage") => {
11
+ if (e !== void 0)
12
+ return typeof e == "number" ? { value: e, unit: n } : e;
13
+ }, tn = (e, n, t) => e === void 0 ? n : typeof e == "number" ? e / 100 * t : e.unit === "pixels" ? e.value : e.value / 100 * t, Te = (e, n, t) => Math.min(Math.max(e, n), t), Un = (e) => !Number.isFinite(e) || e <= 0 ? 0 : Math.max(0, Math.min(xt, Gn, e * Hn)), xe = (e) => {
14
+ if (!e)
15
+ return 0;
16
+ const n = Number.parseFloat(e);
17
+ return Number.isFinite(n) ? n : 0;
18
+ }, Ce = (e, n, t) => {
19
+ const r = n === "horizontal", o = typeof window < "u" ? window.getComputedStyle(e) : null, i = o ? r ? xe(o.paddingLeft) + xe(o.paddingRight) : xe(o.paddingTop) + xe(o.paddingBottom) : 0, s = o ? r ? xe(o.borderLeftWidth) + xe(o.borderRightWidth) : xe(o.borderTopWidth) + xe(o.borderBottomWidth) : 0, l = t?.contentBoxSize?.[0], c = l ? r ? l.inlineSize : l.blockSize : void 0, a = r ? e.clientWidth : e.clientHeight, g = a > 0 ? Math.max(0, a - i) : Math.max(0, (r ? e.offsetWidth : e.offsetHeight) - i - s), d = c ?? g;
20
+ return { content: Math.max(0, d), border: Math.max(0, d + i + s) };
21
+ }, Ct = "[data-panel-group-direction]", rn = "[data-panel-id], [data-resize-handle-anchor]", Mt = "[data-panel-id]", Be = (e) => e?.closest(Ct) ?? null, Wn = (e) => Array.from(e.querySelectorAll(rn)).filter((n) => {
22
+ if (Be(n) !== e)
23
+ return !1;
24
+ const t = n.parentElement?.closest(Mt);
25
+ return !(t && e.contains(t));
26
+ }), Ft = (e) => {
27
+ const n = (t) => {
28
+ for (const r of Array.from(t))
29
+ if (r instanceof Element && (r.matches(rn) || r.querySelector(rn) !== null))
30
+ return !0;
31
+ return !1;
32
+ };
33
+ return e.some((t) => n(t.addedNodes) || n(t.removedNodes));
34
+ }, kt = (e, n) => {
35
+ if (typeof window > "u")
36
+ return 1;
37
+ const t = n === "horizontal", r = e.getBoundingClientRect(), o = t ? r.width : r.height, i = window.getComputedStyle(e), s = t ? i.width : i.height;
38
+ if (!s.endsWith("px"))
39
+ return 1;
40
+ const l = Number.parseFloat(s);
41
+ return o > 0 && Number.isFinite(l) && l > 0 ? o / l : 1;
42
+ }, On = (e, n) => {
43
+ try {
44
+ localStorage.setItem(`panel-layout-${e}`, JSON.stringify(n));
45
+ } catch (t) {
46
+ console.warn("Failed to save panel layout:", t);
47
+ }
48
+ }, Bt = (e) => {
49
+ try {
50
+ const n = localStorage.getItem(`panel-layout-${e}`);
51
+ if (!n)
52
+ return null;
53
+ const t = JSON.parse(n);
54
+ if (!Array.isArray(t))
55
+ return null;
56
+ const r = (o) => typeof o == "object" && o !== null && typeof o.id == "string" && Number.isFinite(o.size);
57
+ return t.every(r) ? t : null;
58
+ } catch (n) {
59
+ return console.warn("Failed to load panel layout:", n), null;
60
+ }
61
+ }, on = 0, Vn = 1, $e = (e) => Number.isFinite(e) && e > 0 ? e : 0, te = (e) => e.sizeUnit === "pixels", Pe = (e, n) => {
62
+ const t = Math.max(0, $e(tn(e.minSize, 0, n))), r = Math.max(t, $e(tn(e.maxSize, n, n)));
63
+ return { min: t, max: r };
64
+ }, $t = (e, n) => {
65
+ const t = e.map((o) => o.min), r = e.map(() => !1);
66
+ for (; ; ) {
67
+ let o = 0, i = 0, s = 0;
68
+ for (let d = 0; d < e.length; d += 1) {
69
+ if (r[d]) {
70
+ i += t[d];
71
+ continue;
72
+ }
73
+ s += 1, o += e[d].weight;
74
+ }
75
+ if (s === 0)
76
+ return t;
77
+ const l = n - i;
78
+ if (o <= 0) {
79
+ for (let d = 0; d < e.length; d += 1)
80
+ r[d] || (t[d] = e[d].min);
81
+ return t;
82
+ }
83
+ const c = Math.max(0, l / o);
84
+ let a = 0;
85
+ for (let d = 0; d < e.length; d += 1) {
86
+ if (r[d])
87
+ continue;
88
+ const x = c * e[d].weight, h = Te(x, e[d].min, e[d].max);
89
+ t[d] = h, a += h - x;
90
+ }
91
+ let g = !1;
92
+ for (let d = 0; d < e.length; d += 1) {
93
+ if (r[d])
94
+ continue;
95
+ const x = c * e[d].weight;
96
+ a > L && t[d] > x + L ? (r[d] = !0, t[d] = e[d].min, g = !0) : a < -L && t[d] < x - L && (r[d] = !0, t[d] = e[d].max, g = !0);
97
+ }
98
+ if (!g)
99
+ return t;
100
+ }
101
+ }, Ht = (e, n, t) => {
102
+ const { min: r, max: o } = Pe(e, t);
103
+ if (te(e))
104
+ return {
105
+ index: n,
106
+ weight: 0,
107
+ target: Te($e(e.preferredPixelSize), r, o),
108
+ priority: e.pixelAdjustPriority ?? 0,
109
+ tier: on,
110
+ min: r,
111
+ max: o
112
+ };
113
+ const i = $e(e.preferredPercentageSize), s = e.flexAdjustPriority !== void 0;
114
+ return {
115
+ index: n,
116
+ weight: i,
117
+ target: s ? Te(i / 100 * t, r, o) : null,
118
+ priority: e.flexAdjustPriority ?? 0,
119
+ tier: Vn,
120
+ min: r,
121
+ max: o
122
+ };
123
+ }, Dn = (e, n, t, r) => {
124
+ let o = r;
125
+ for (const i of e) {
126
+ if (o <= L)
127
+ break;
128
+ const s = t(i) - n[i.index];
129
+ if (s <= 0)
130
+ continue;
131
+ const l = Math.min(s, o);
132
+ n[i.index] += l, o -= l;
133
+ }
134
+ return o;
135
+ }, sn = (e, n, t) => {
136
+ if (e.length === 0 || t <= L)
137
+ return t;
138
+ const r = e.map((s) => ({ ...s, min: n[s.index] })), o = $t(r, t + r.reduce((s, l) => s + l.min, 0));
139
+ let i = 0;
140
+ for (let s = 0; s < e.length; s += 1)
141
+ i += o[s] - n[e[s].index], n[e[s].index] = o[s];
142
+ return t - i;
143
+ }, Gt = (e, n, t) => sn(
144
+ e.map((r) => ({ ...r, weight: 1 })),
145
+ n,
146
+ t
147
+ ), jt = (e, n) => e.tier !== n.tier ? e.tier - n.tier : e.priority !== n.priority ? n.priority - e.priority : e.index - n.index, Ut = (e, n) => {
148
+ const t = e.map(() => 0);
149
+ if (!Number.isFinite(n) || n <= 0 || e.length === 0)
150
+ return { sizes: t, violation: null };
151
+ const r = [];
152
+ for (let h = 0; h < e.length; h += 1) {
153
+ const U = e[h];
154
+ U.collapsed || r.push(Ht(U, h, n));
155
+ }
156
+ if (r.length === 0)
157
+ return { sizes: t, violation: null };
158
+ let o = 0, i = 0;
159
+ for (const h of r)
160
+ t[h.index] = h.min, o += h.min, i += h.max;
161
+ const s = Wt(o, i, n);
162
+ let l = n - o;
163
+ if (l <= L)
164
+ return { sizes: t, violation: s };
165
+ const c = r.filter((h) => h.target !== null).sort(jt), a = r.filter((h) => h.target === null && h.weight > 0), g = r.filter((h) => h.tier !== on && h.weight <= 0), d = c.filter((h) => h.tier === Vn), x = c.filter((h) => h.tier === on);
166
+ return l = Dn(c, t, (h) => h.target ?? h.min, l), l = sn(a, t, l), l = sn(d, t, l), l = Dn(x, t, (h) => h.max, l), l = Gt(g, t, l), { sizes: t, violation: s };
167
+ }, Wt = (e, n, t) => e - t > L ? {
168
+ reason: "minimum-exceeded",
169
+ totalMinimumSize: e,
170
+ totalMaximumSize: n,
171
+ availableContainerSize: t
172
+ } : t - n > L ? {
173
+ reason: "maximum-insufficient",
174
+ totalMinimumSize: e,
175
+ totalMaximumSize: n,
176
+ availableContainerSize: t
177
+ } : null, Yn = ft(null), hn = () => {
178
+ const e = ht(Yn);
179
+ if (!e)
180
+ throw new Error("usePanelGroup must be used within a PanelGroup");
181
+ return e;
182
+ };
183
+ var je = /* @__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))(je || {});
184
+ const J = class J {
185
+ /**
186
+ * @constructor
187
+ * @param {LogLevel} [level=LogLevel.WARN] - The minimum log level to output.
188
+ * @param {string} [prefix="[resize-panels]"] - The prefix to add to all log messages.
189
+ * @param {ILogger} [impl=console] - The implementation to use for logging.
190
+ */
191
+ constructor(n = 2, t = "[resize-panels]", r = console) {
192
+ this.level = n, this.prefix = t, this.impl = r, J.instances.add(this);
193
+ }
194
+ /**
195
+ * @method setLevel
196
+ * @description Updates the log level for every constructed logger (module-level loggers included).
197
+ * @description 生成済みのすべてのロガー (モジュールレベルのロガーを含む) のログレベルを更新します。
198
+ * @param {LogLevel} level - The new log level.
199
+ */
200
+ static setLevel(n) {
201
+ for (const t of J.instances)
202
+ t.setLevel(n);
203
+ }
204
+ /**
205
+ * @method setLevel
206
+ * @description Updates the current log level.
207
+ * @description 現在のログレベルを更新します。
208
+ * @param {LogLevel} level - The new log level.
209
+ */
210
+ setLevel(n) {
211
+ this.level = n;
212
+ }
213
+ /**
214
+ * @method setImplementation
215
+ * @description Updates the logger implementation for every constructed logger.
216
+ * @description 生成済みのすべてのロガーの実装を更新します。
217
+ * @param {ILogger} impl - The new logger implementation.
218
+ */
219
+ static setImplementation(n) {
220
+ for (const t of J.instances)
221
+ t.setImplementation(n);
222
+ }
223
+ /**
224
+ * @method setImplementation
225
+ * @description Updates the logger implementation.
226
+ * @description ロガーの実装を更新します。
227
+ * @param {ILogger} impl - The new logger implementation.
228
+ */
229
+ setImplementation(n) {
230
+ this.impl = n;
231
+ }
232
+ /**
233
+ * @method setPrefix
234
+ * @description Updates the log prefix for every constructed logger.
235
+ * @description 生成済みのすべてのロガーのログのプレフィックスを更新します。
236
+ * @param {string} prefix - The new prefix.
237
+ */
238
+ static setPrefix(n) {
239
+ for (const t of J.instances)
240
+ t.setPrefix(n);
241
+ }
242
+ /**
243
+ * @method setPrefix
244
+ * @description Updates the log prefix.
245
+ * @description ログのプレフィックスを更新します。
246
+ * @param {string} prefix - The new prefix.
247
+ */
248
+ setPrefix(n) {
249
+ this.prefix = n;
250
+ }
251
+ /**
252
+ * @method enabledFor
253
+ * @description Returns whether messages at the given level would be emitted.
254
+ * @description 指定レベルのメッセージが出力対象かどうかを返します。
255
+ * 高コストなログ引数 (スナップショット等) の組み立てを抑制中に省略するために使用します。
256
+ * @param {LogLevel} level - The message level to test.
257
+ */
258
+ enabledFor(n) {
259
+ return this.level <= n;
260
+ }
261
+ formatMessage(n) {
262
+ return typeof n == "string" ? [`${this.prefix} ${n}`] : [this.prefix, n];
263
+ }
264
+ static debug(n, ...t) {
265
+ J.instance.debug(n, ...t);
266
+ }
267
+ debug(n, ...t) {
268
+ this.level <= 0 && this.impl.debug(...this.formatMessage(n), ...t);
269
+ }
270
+ static info(n, ...t) {
271
+ J.instance.info(n, ...t);
272
+ }
273
+ info(n, ...t) {
274
+ this.level <= 1 && this.impl.info(...this.formatMessage(n), ...t);
275
+ }
276
+ static warn(n, ...t) {
277
+ J.instance.warn(n, ...t);
278
+ }
279
+ warn(n, ...t) {
280
+ this.level <= 2 && this.impl.warn(...this.formatMessage(n), ...t);
281
+ }
282
+ static error(n, ...t) {
283
+ J.instance.error(n, ...t);
284
+ }
285
+ error(n, ...t) {
286
+ this.level <= 3 && this.impl.error(...this.formatMessage(n), ...t);
287
+ }
288
+ };
289
+ J.instances = /* @__PURE__ */ new Set(), J.instance = new J(2, "[resize-panels]");
290
+ let Me = J;
291
+ const Kn = new Me(je.INFO, "[resize-panels]"), Vt = {
292
+ containerSize: 0,
293
+ panels: [],
294
+ violation: null
295
+ }, Tn = (e, n) => e === null || n === null ? e === n : e.reason === n.reason && Math.abs(e.totalMinimumSize - n.totalMinimumSize) <= L && Math.abs(e.totalMaximumSize - n.totalMaximumSize) <= L && Math.abs(e.availableContainerSize - n.availableContainerSize) <= L, pe = (e, n) => {
296
+ const { sizes: t, violation: r } = Ut(e, n);
297
+ let o = !1;
298
+ const i = e.map((l, c) => {
299
+ const a = l.collapsed ? 0 : t[c];
300
+ return Math.abs(l.size - a) <= L ? l : (o = !0, { ...l, size: a });
301
+ }), s = { containerSize: n, panels: o ? i : e, violation: r };
302
+ return Kt(s), s;
303
+ }, Yt = (e) => {
304
+ if (e.containerSize <= 0 || e.violation !== null)
305
+ return null;
306
+ let n = 0, t = 0;
307
+ for (const o of e.panels)
308
+ o.collapsed || (n += o.size, t += 1);
309
+ if (t === 0)
310
+ return null;
311
+ const r = L * Math.max(1, e.containerSize);
312
+ return !Number.isFinite(n) || Math.abs(n - e.containerSize) > r ? { allocatedTotal: n, containerSize: e.containerSize } : null;
313
+ }, Kt = (e) => {
314
+ const n = Yt(e);
315
+ n && Kn.error("Allocated sizes do not fill the container.", {
316
+ ...n,
317
+ panels: e.panels.map((t) => ({ id: t.id, size: t.size, collapsed: t.collapsed }))
318
+ });
319
+ }, fe = (e, n) => e.panels === n.panels && e.containerSize === n.containerSize && Tn(e.violation, n.violation) ? e : {
320
+ containerSize: n.containerSize,
321
+ panels: n.panels,
322
+ violation: Tn(e.violation, n.violation) ? e.violation : n.violation
323
+ }, qt = (e, n) => {
324
+ const t = e.sizeUnit === "pixels" ? e.preferredPixelSize : e.preferredPercentageSize;
325
+ return {
326
+ ...e,
327
+ size: 0,
328
+ collapsed: e.collapsed,
329
+ collapsedByDirection: e.collapsed ? n : null,
330
+ preferenceBeforeCollapse: t,
331
+ authoredPreference: t
332
+ };
333
+ }, Je = (e) => e.collapseFromStart ? "start" : e.collapseFromEnd ? "end" : null, Xt = (e, n) => {
334
+ if (n <= 0)
335
+ return e;
336
+ const t = Un(n);
337
+ return e.map((r) => {
338
+ if (r.collapsed)
339
+ return r;
340
+ const o = te(r) ? r.size : r.size / n * 100, i = te(r) ? r.preferredPixelSize : r.preferredPercentageSize, s = r.size > t ? o : r.preferenceBeforeCollapse;
341
+ return i === o && s === r.preferenceBeforeCollapse ? r : te(r) ? { ...r, preferredPixelSize: o, preferenceBeforeCollapse: s } : { ...r, preferredPercentageSize: o, preferenceBeforeCollapse: s };
342
+ });
343
+ }, ln = (e, n, t) => {
344
+ if (te(e)) {
345
+ const o = Math.max(0, n);
346
+ return { ...e, preferredPixelSize: o, preferenceBeforeCollapse: o };
347
+ }
348
+ if (t <= 0)
349
+ return e;
350
+ const r = Math.max(0, n / t * 100);
351
+ return { ...e, preferredPercentageSize: r, preferenceBeforeCollapse: r };
352
+ }, Zt = (e, n) => {
353
+ const t = e.collapsed ? e.preferenceBeforeCollapse : te(e) ? e.preferredPixelSize : e.preferredPercentageSize;
354
+ return te(e) ? t : t / 100 * n;
355
+ }, Jt = (e, n, t, r) => {
356
+ const o = Math.max(0, Math.min(t, r)), i = e.filter((a) => a.id !== n && !a.collapsed && !te(a)), s = e.reduce((a, g) => g.id !== n && !g.collapsed && te(g) ? a + g.size : a, 0), l = i.reduce((a, g) => a + g.size, 0), c = Math.max(0, r - o - s);
357
+ return e.map((a) => {
358
+ if (a.id === n)
359
+ return ln(a, o, r);
360
+ if (a.collapsed || te(a) || i.length === 0)
361
+ return a;
362
+ const g = l > 0 ? a.size / l * c : c / i.length;
363
+ return ln(a, g, r);
364
+ });
365
+ }, Qt = (e, n) => {
366
+ switch (n.type) {
367
+ case "SET_CONTAINER_SIZE":
368
+ return !Number.isFinite(n.containerSize) || n.containerSize < 0 || n.containerSize === e.containerSize ? e : fe(e, pe(e.panels, n.containerSize));
369
+ case "REGISTER_PANEL": {
370
+ const t = e.panels.findIndex((d) => d.id === n.panel.id);
371
+ if (t === -1) {
372
+ const d = [...e.panels, qt(n.panel, Je(n.panel))];
373
+ return fe(e, pe(d, e.containerSize));
374
+ }
375
+ const r = e.panels[t], o = n.panel.sizeUnit === "pixels" ? n.panel.preferredPixelSize : n.panel.preferredPercentageSize, i = o !== r.authoredPreference || n.panel.sizeUnit !== r.sizeUnit, s = r.collapsedByDirection === "start" ? n.panel.collapseFromStart : r.collapsedByDirection === "end" ? n.panel.collapseFromEnd : !1, l = n.panel.collapseFromStart || n.panel.collapseFromEnd, c = r.collapsed && l, a = {
376
+ ...r,
377
+ ...n.panel,
378
+ collapsed: c,
379
+ collapsedByDirection: c ? s ? r.collapsedByDirection : Je(n.panel) : null,
380
+ preferredPercentageSize: i ? n.panel.preferredPercentageSize : r.preferredPercentageSize,
381
+ preferredPixelSize: i ? n.panel.preferredPixelSize : r.preferredPixelSize,
382
+ preferenceBeforeCollapse: i ? o : r.preferenceBeforeCollapse,
383
+ authoredPreference: o
384
+ }, g = [...e.panels];
385
+ return g[t] = a, fe(e, pe(g, e.containerSize));
386
+ }
387
+ case "UNREGISTER_PANEL": {
388
+ const t = e.panels.filter((r) => r.id !== n.id);
389
+ return t.length === e.panels.length ? e : fe(e, pe(t, e.containerSize));
390
+ }
391
+ case "REORDER_PANELS": {
392
+ if (n.ids.length !== e.panels.length || new Set(n.ids).size !== n.ids.length)
393
+ return e;
394
+ const t = new Map(e.panels.map((o) => [o.id, o])), r = [];
395
+ for (const o of n.ids) {
396
+ const i = t.get(o);
397
+ if (!i)
398
+ return e;
399
+ r.push(i);
400
+ }
401
+ return r.every((o, i) => o === e.panels[i]) ? e : fe(e, pe(r, e.containerSize));
402
+ }
403
+ case "RESIZE_PANELS": {
404
+ const t = e.panels.findIndex((U) => U.id === n.startId), r = e.panels.findIndex((U) => U.id === n.endId);
405
+ if (t === -1 || r === -1)
406
+ return e;
407
+ const o = e.panels[t], i = e.panels[r];
408
+ if (o.collapsed || i.collapsed || e.containerSize <= 0 || !Number.isFinite(n.startSize))
409
+ return e;
410
+ const s = o.size + i.size, l = Pe(o, e.containerSize), c = Pe(i, e.containerSize), a = Math.max(l.min, s - c.max), g = Math.min(l.max, s - c.min);
411
+ if (a - g > L)
412
+ return e;
413
+ const d = Te(n.startSize, a, Math.max(a, g)), x = s - d;
414
+ if (Math.abs(d - o.size) <= L)
415
+ return e;
416
+ const h = [...e.panels];
417
+ return h[t] = { ...o, size: d }, h[r] = { ...i, size: x }, fe(e, pe(Xt(h, e.containerSize), e.containerSize));
418
+ }
419
+ case "COLLAPSE_PANEL": {
420
+ const t = e.panels.findIndex((s) => s.id === n.id);
421
+ if (t === -1)
422
+ return e;
423
+ const r = e.panels[t];
424
+ if (!(n.from === "start" ? r.collapseFromStart : r.collapseFromEnd) || r.collapsed)
425
+ return e;
426
+ const i = [...e.panels];
427
+ return i[t] = {
428
+ ...r,
429
+ collapsed: !0,
430
+ collapsedByDirection: n.from
431
+ }, fe(e, pe(i, e.containerSize));
432
+ }
433
+ case "EXPAND_PANEL": {
434
+ const t = e.panels.findIndex((c) => c.id === n.id);
435
+ if (t === -1 || n.targetSize !== void 0 && e.containerSize <= 0)
436
+ return e;
437
+ const r = e.panels[t];
438
+ if (!((n.from === "start" ? r.collapseFromStart : r.collapseFromEnd) && r.collapsed) || r.collapsedByDirection !== null && r.collapsedByDirection !== n.from)
439
+ return e;
440
+ const i = {
441
+ ...r,
442
+ collapsed: !1,
443
+ collapsedByDirection: null,
444
+ preferredPixelSize: te(r) ? r.preferenceBeforeCollapse : r.preferredPixelSize,
445
+ preferredPercentageSize: te(r) ? r.preferredPercentageSize : r.preferenceBeforeCollapse
446
+ }, s = [...e.panels];
447
+ s[t] = i;
448
+ const l = n.targetSize === void 0 ? s : Jt(s, n.id, n.targetSize, e.containerSize);
449
+ return fe(e, pe(l, e.containerSize));
450
+ }
451
+ case "RESTORE_LAYOUT": {
452
+ if (n.entries.length !== e.panels.length || e.containerSize <= 0)
453
+ return e;
454
+ const t = new Map(n.entries.map((o) => [o.id, o]));
455
+ if (e.panels.some((o) => !t.has(o.id)))
456
+ return e;
457
+ const r = e.panels.map((o) => {
458
+ const i = t.get(o.id);
459
+ if (!i)
460
+ return o;
461
+ const s = ln(o, i.size, e.containerSize), l = o.collapseFromStart || o.collapseFromEnd;
462
+ return i.collapsed && l ? { ...s, collapsed: !0, collapsedByDirection: o.collapsedByDirection ?? Je(o) } : s.collapsed ? { ...s, collapsed: !1, collapsedByDirection: null } : s;
463
+ });
464
+ return Kn.debug("restore layout", { containerSize: e.containerSize, entries: n.entries }), fe(e, pe(r, e.containerSize));
465
+ }
466
+ default:
467
+ return e;
468
+ }
469
+ }, er = {
470
+ layout: Vt,
471
+ source: null
472
+ }, nr = (e) => {
473
+ switch (e.type) {
474
+ case "SET_CONTAINER_SIZE":
475
+ return "container";
476
+ case "REGISTER_PANEL":
477
+ case "UNREGISTER_PANEL":
478
+ case "REORDER_PANELS":
479
+ return "panels";
480
+ case "RESTORE_LAYOUT":
481
+ return "restore";
482
+ case "RESIZE_PANELS":
483
+ case "COLLAPSE_PANEL":
484
+ case "EXPAND_PANEL":
485
+ return e.source;
486
+ }
487
+ }, tr = (e, n) => {
488
+ const t = Qt(e.layout, n);
489
+ if (t === e.layout)
490
+ return e;
491
+ const r = t.panels !== e.layout.panels || t.containerSize > 0 != e.layout.containerSize > 0;
492
+ return { layout: t, source: r ? nr(n) : e.source };
493
+ }, rr = new Me(je.INFO, "[resize-panels]"), or = { pointer: !0, keyboard: !0, api: !0 }, ir = (e) => typeof e == "string" && Object.hasOwn(or, e), Qe = (e) => {
494
+ if (!ir(e))
495
+ throw new RangeError(`[resize-panels] A request source must be "pointer", "keyboard" or "api"; received ${typeof e == "string" ? JSON.stringify(e) : String(e)}.`);
496
+ return e;
497
+ }, sr = 200, lr = "\0handle", ar = ({ direction: e, style: n, onLayout: t, autoSaveId: r, showDebugInfo: o = !1 }) => {
498
+ const [{ layout: i, source: s }, l] = mt(tr, er), [c, a] = Ne({}), [g, d] = Ne({}), x = F(null), [h, U] = Ne(""), X = F({}), se = F(t);
499
+ se.current = t, Se(() => {
500
+ const u = x.current;
501
+ if (!u || typeof ResizeObserver > "u")
502
+ return;
503
+ let p = Number.NaN;
504
+ const f = (I) => {
505
+ I !== p && (p = I, l({ type: "SET_CONTAINER_SIZE", containerSize: I }));
506
+ }, b = new ResizeObserver((I) => {
507
+ f(Ce(u, e, I[0]).content);
508
+ });
509
+ return b.observe(u), f(Ce(u, e).content), () => {
510
+ b.disconnect(), l({ type: "SET_CONTAINER_SIZE", containerSize: 0 });
511
+ };
512
+ }, [e]);
513
+ const E = i.panels, G = F(E);
514
+ G.current = E;
515
+ const B = k(() => {
516
+ const u = x.current, p = G.current;
517
+ if (!u)
518
+ return;
519
+ const f = Wn(u);
520
+ if (U((I) => {
521
+ const le = f.map((Ue) => Ue.dataset.panelId ?? lr).join("\0");
522
+ return I === le ? I : le;
523
+ }), p.length === 0)
524
+ return;
525
+ const b = [];
526
+ for (const I of f) {
527
+ const le = I.dataset.panelId;
528
+ le !== void 0 && b.push(le);
529
+ }
530
+ if (new Set(b).size !== b.length) {
531
+ rr.error("Duplicate panel id in one group.", { ids: b });
532
+ return;
533
+ }
534
+ b.length !== p.length || b.every((I, le) => I === p[le].id) || l({ type: "REORDER_PANELS", ids: b });
535
+ }, []);
536
+ Se(() => {
537
+ const u = x.current;
538
+ if (!u || (B(), typeof MutationObserver > "u"))
539
+ return;
540
+ const p = new MutationObserver((f) => {
541
+ Ft(f) && B();
542
+ });
543
+ return p.observe(u, { childList: !0, subtree: !0 }), () => {
544
+ p.disconnect();
545
+ };
546
+ }, [B]), Se(() => {
547
+ B();
548
+ }, [B, E]);
549
+ const T = P(() => E.map((u) => u.size), [E]), C = i.containerSize > 0;
550
+ Se(() => {
551
+ !C || T.length === 0 || s === null || se.current?.(T, { source: s });
552
+ }, [T, C, s]);
553
+ const $ = F(null);
554
+ Q(() => {
555
+ if (!r || $.current === r || !C || E.length === 0)
556
+ return;
557
+ $.current = r;
558
+ const u = Bt(r);
559
+ u && l({ type: "RESTORE_LAYOUT", entries: u });
560
+ }, [r, C, E.length]);
561
+ const M = F(null);
562
+ Q(() => {
563
+ if (!(r && $.current === r && C) || E.length === 0)
564
+ return;
565
+ const u = E.map((f) => ({ id: f.id, size: Zt(f, i.containerSize), collapsed: f.collapsed }));
566
+ M.current = { id: r, entries: u };
567
+ const p = setTimeout(() => {
568
+ M.current = null, On(r, u);
569
+ }, sr);
570
+ return () => {
571
+ clearTimeout(p);
572
+ };
573
+ }, [r, E, i.containerSize, C]), Q(() => () => {
574
+ const u = M.current;
575
+ u && (M.current = null, On(u.id, u.entries));
576
+ }, []);
577
+ const v = k((u) => {
578
+ const p = JSON.stringify(u);
579
+ X.current[u.id] !== p && (X.current[u.id] = p, l({ type: "REGISTER_PANEL", panel: u }));
580
+ }, []), S = k((u) => {
581
+ delete X.current[u], l({ type: "UNREGISTER_PANEL", id: u }), a((p) => {
582
+ if (!(u in p))
583
+ return p;
584
+ const f = { ...p };
585
+ return delete f[u], f;
586
+ });
587
+ }, []), A = k((u, p, f, b = "api") => {
588
+ l({ type: "RESIZE_PANELS", startId: u, endId: p, startSize: f, source: Qe(b) });
589
+ }, []), ee = k((u, p, f = "api") => {
590
+ l({ type: "COLLAPSE_PANEL", id: u, from: p, source: Qe(f) });
591
+ }, []), j = k((u, p, f, b = "api") => {
592
+ l({ type: "EXPAND_PANEL", id: u, from: p, targetSize: f, source: Qe(b) });
593
+ }, []), W = k((u) => E.find((p) => p.id === u), [E]), K = k((u, p) => {
594
+ a((f) => {
595
+ if (p === null) {
596
+ if (!(u in f))
597
+ return f;
598
+ const I = { ...f };
599
+ return delete I[u], I;
600
+ }
601
+ const b = f[u];
602
+ return b && b.pixelSize === p.pixelSize && b.percentageSize === p.percentageSize ? f : { ...f, [u]: p };
603
+ });
604
+ }, []), R = k((u, p) => {
605
+ d((f) => {
606
+ if (p === null) {
607
+ if (!(u in f))
608
+ return f;
609
+ const I = { ...f };
610
+ return delete I[u], I;
611
+ }
612
+ const b = f[u];
613
+ return b && b.thickness === p.thickness && b.visible === p.visible && b.direction === p.direction && b.startPanelId === p.startPanelId && b.endPanelId === p.endPanelId ? f : { ...f, [u]: p };
614
+ });
615
+ }, []), z = P(
616
+ () => ({
617
+ direction: e,
618
+ panels: E,
619
+ containerSize: i.containerSize,
620
+ layoutOrderKey: h,
621
+ showDebugInfo: o,
622
+ registerPanel: v,
623
+ unregisterPanel: S,
624
+ resizePanels: A,
625
+ collapsePanel: ee,
626
+ expandPanel: j,
627
+ getPanel: W,
628
+ reportPanelMeasurement: K,
629
+ panelMeasurements: c,
630
+ reportHandleMeasurement: R,
631
+ handleMeasurements: g,
632
+ layoutConstraintViolation: i.violation
633
+ }),
634
+ [e, E, i.containerSize, h, i.violation, o, v, S, A, ee, j, W, K, c, R, g]
635
+ ), _ = P(
636
+ () => ({
637
+ // 見た目に関わる既定値は利用者が上書きできる
638
+ width: "100%",
639
+ height: "100%",
640
+ minWidth: "0px",
641
+ minHeight: "0px",
642
+ // ハンドルは境界をまたいで描かれるため、その張り出しでスクロールバーを出さない
643
+ overflow: "hidden",
644
+ ...n,
645
+ // ここから下はレイアウトの前提そのもの。利用者のスタイルやクラスで変わると
646
+ // 配分結果と描画が一致しなくなるため、最後に適用して上書きを受け付けない:
647
+ // gap はパネルの合計に含まれない隙間を作り、flex-direction の反転は DOM 順と視覚順をずらし、
648
+ // writing-mode は主軸の向きそのものを変えてしまう
649
+ display: "flex",
650
+ flexDirection: e === "horizontal" ? "row" : "column",
651
+ alignItems: "stretch",
652
+ gap: "0px",
653
+ position: "relative",
654
+ boxSizing: "border-box",
655
+ writingMode: "horizontal-tb"
656
+ }),
657
+ [e, n]
658
+ );
659
+ return { groupRef: x, contextValue: z, groupStyle: _ };
660
+ }, Xr = (e) => {
661
+ const { getPanel: n, collapsePanel: t, expandPanel: r } = hn(), o = n(e), i = k(
662
+ (c) => {
663
+ t(e, c, "api");
664
+ },
665
+ [t, e]
666
+ ), s = k(
667
+ (c, a) => {
668
+ r(e, c, a, "api");
669
+ },
670
+ [r, e]
671
+ ), l = k(
672
+ (c, a) => {
673
+ o?.collapsed ? s(c, a) : i(c);
674
+ },
675
+ [o?.collapsed, i, s]
676
+ );
677
+ return P(
678
+ () => ({
679
+ panel: o,
680
+ isCollapsed: o?.collapsed ?? !1,
681
+ canCollapseFromStart: o?.collapseFromStart ?? !1,
682
+ canCollapseFromEnd: o?.collapseFromEnd ?? !1,
683
+ collapse: i,
684
+ expand: s,
685
+ toggle: l
686
+ }),
687
+ [o, i, s, l]
688
+ );
689
+ }, cr = "en", an = Object.freeze({
690
+ minimumExceededSummary: "Layout unavailable: minimum panel sizes exceed the container.",
691
+ minimumExceededDetail: "Min required: {required}px | Available: {available}px",
692
+ maximumInsufficientSummary: "Layout unavailable: panels cannot fill the container with their maximum sizes.",
693
+ maximumInsufficientDetail: "Max total: {total}px | Needed: {needed}px"
694
+ }), ur = Object.freeze({
695
+ minimumExceededDetail: Object.freeze(["required", "available"]),
696
+ maximumInsufficientDetail: Object.freeze(["total", "needed"])
697
+ }), en = Object.freeze(Object.keys(an)), Cn = Object.freeze({
698
+ "minimum-exceeded": Object.freeze({ summary: "minimumExceededSummary", detail: "minimumExceededDetail" }),
699
+ "maximum-insufficient": Object.freeze({ summary: "maximumInsufficientSummary", detail: "maximumInsufficientDetail" })
700
+ }), dr = /\{(\w+)\}/g, pr = /\{(\w+)\}|[{}]/g, fr = (e) => {
701
+ if (e !== void 0) {
702
+ const o = e, i = o !== null && typeof o == "object" ? Object.getPrototypeOf(o) : void 0;
703
+ if (i !== Object.prototype && i !== null)
704
+ throw new TypeError(`[resize-panels] Labels must be a plain object; received ${Mn(o)}.`);
705
+ for (const s of Object.keys(o))
706
+ if (!en.includes(s))
707
+ throw new RangeError(`[resize-panels] Labels hold the unknown key ${JSON.stringify(s)}; the labels are ${en.join(", ")}.`);
708
+ }
709
+ const n = e ?? {}, t = {};
710
+ for (const o of en) {
711
+ const i = n[o];
712
+ if (i === void 0)
713
+ continue;
714
+ if (typeof i != "string")
715
+ throw new TypeError(`[resize-panels] The label "${o}" must be a string; received ${Mn(i)}.`);
716
+ if (i.trim() === "")
717
+ throw new RangeError(`[resize-panels] The label "${o}" must not be blank.`);
718
+ const s = ur[o];
719
+ if (s !== void 0) {
720
+ const l = s.map((c) => `{${c}}`).join(", ");
721
+ for (const c of i.matchAll(pr)) {
722
+ const a = c[1];
723
+ if (a === void 0)
724
+ throw new RangeError(`[resize-panels] The label "${o}" holds a brace outside a placeholder at index ${c.index}; it accepts ${l}, and no other braces.`);
725
+ if (!s.includes(a))
726
+ throw new RangeError(`[resize-panels] The label "${o}" uses the unknown placeholder {${a}}; it accepts ${l}.`);
727
+ }
728
+ }
729
+ t[o] = i;
730
+ }
731
+ const r = {};
732
+ for (const o of Object.keys(Cn))
733
+ r[o] = hr(t, Cn[o]);
734
+ return Object.freeze(r);
735
+ }, hr = (e, n) => {
736
+ const t = e[n.summary], r = e[n.detail];
737
+ if (t === void 0 && r === void 0)
738
+ return Object.freeze({ summary: an[n.summary], detail: an[n.detail], lang: cr });
739
+ if (t === void 0 || r === void 0) {
740
+ const [o, i] = t === void 0 ? [n.detail, n.summary] : [n.summary, n.detail];
741
+ throw new RangeError(`[resize-panels] The labels "${n.summary}" and "${n.detail}" go together: pass both or neither; received "${o}" without "${i}".`);
742
+ }
743
+ return Object.freeze({ summary: t, detail: r, lang: void 0 });
744
+ }, mr = (e, n) => e.replace(dr, (t, r) => {
745
+ if (!Object.hasOwn(n, r))
746
+ throw new RangeError(`[resize-panels] No value for the placeholder {${r}} of ${JSON.stringify(e)}.`);
747
+ return String(n[r]);
748
+ }), gr = (e, n) => {
749
+ const t = e[n.reason], r = n.reason === "minimum-exceeded" ? { required: Math.ceil(n.totalMinimumSize), available: Math.floor(n.availableContainerSize) } : { total: Math.floor(n.totalMaximumSize), needed: Math.ceil(n.availableContainerSize) };
750
+ return Object.freeze({ summary: t.summary, detail: mr(t.detail, r), lang: t.lang });
751
+ }, Mn = (e) => e === null ? "null" : Array.isArray(e) ? "an array" : typeof e, br = ({ panel: e, containerAxisSize: n, containerLabel: t }) => {
752
+ if (!e)
753
+ return { sizeDisplay: "-", preferenceDisplay: "-", boundsDisplay: "-", containerDisplay: "-", headlineLabel: "Unregistered", titleText: "Unregistered" };
754
+ const r = e.sizeUnit === "pixels", o = `${e.size.toFixed(3)}px / ${jn(e.size, n).toFixed(3)}%`, i = r ? `${e.preferredPixelSize.toFixed(3)}px` : `${e.preferredPercentageSize.toFixed(3)}%`, s = Pe(e, n), l = `${s.min.toFixed(1)} - ${s.max.toFixed(1)}px`, c = Number.isFinite(n) ? `${n.toFixed(3)}px` : "-", a = r ? "Fixed" : "Flexible", g = [a, `${t}: ${c}`, `size: ${o}`, `preference: ${i}`, `bounds: ${l}`].join(`
755
+ `);
756
+ return { sizeDisplay: o, preferenceDisplay: i, boundsDisplay: l, containerDisplay: c, headlineLabel: a, titleText: g };
757
+ }, xr = pn(({ panel: e, containerAxisSize: n, direction: t }) => {
758
+ const r = t === "horizontal" ? "container width" : "container height", { sizeDisplay: o, preferenceDisplay: i, boundsDisplay: s, containerDisplay: l, headlineLabel: c, titleText: a } = P(() => br({ panel: e, containerAxisSize: n, containerLabel: r }), [e, n, r]);
759
+ return /* @__PURE__ */ he("div", { style: {
760
+ position: "absolute",
761
+ top: 2,
762
+ left: 2,
763
+ zIndex: 30,
764
+ pointerEvents: "none",
765
+ maxWidth: "calc(100% - 4px)",
766
+ padding: "2px 4px",
767
+ borderRadius: 4,
768
+ border: "1px solid rgba(255,255,255,0.1)",
769
+ backgroundColor: "rgba(15, 23, 42, 0.78)",
770
+ color: "#e2e8f0",
771
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
772
+ fontSize: 10,
773
+ lineHeight: 1.35,
774
+ whiteSpace: "pre",
775
+ overflow: "hidden",
776
+ textOverflow: "ellipsis"
777
+ }, title: a, "data-panel-debug-info": "", children: [
778
+ /* @__PURE__ */ he("div", { children: [
779
+ c,
780
+ " · ",
781
+ r,
782
+ ": ",
783
+ l
784
+ ] }),
785
+ /* @__PURE__ */ he("div", { children: [
786
+ "size: ",
787
+ o
788
+ ] }),
789
+ /* @__PURE__ */ he("div", { children: [
790
+ "preference: ",
791
+ i
792
+ ] }),
793
+ /* @__PURE__ */ he("div", { children: [
794
+ "bounds: ",
795
+ s
796
+ ] })
797
+ ] });
798
+ }), Fn = new Me(je.INFO, "[resize-panels]"), Sr = {
799
+ both: { collapseFromStart: !0, collapseFromEnd: !0 },
800
+ start: { collapseFromStart: !0, collapseFromEnd: !1 },
801
+ end: { collapseFromStart: !1, collapseFromEnd: !0 }
802
+ }, yr = (e) => {
803
+ if (!e)
804
+ return { collapseFromStart: !1, collapseFromEnd: !1 };
805
+ const n = Sr[e.from];
806
+ if (!n)
807
+ throw new Error("Invalid collapsible configuration: unsupported 'from' value");
808
+ return n;
809
+ }, Er = (e) => {
810
+ const n = Math.max(0, e.value);
811
+ return e.unit === "pixels" ? { sizeUnit: "pixels", preferredPixelSize: n, preferredPercentageSize: 0 } : { sizeUnit: "percentage", preferredPercentageSize: n, preferredPixelSize: 0 };
812
+ }, zr = ({ size: e, panel: n, registration: t, containerSize: r, isCollapsed: o }) => {
813
+ if (o)
814
+ return { flexBasis: "0px", flexGrow: 0, flexShrink: 0 };
815
+ if (!n || r <= 0) {
816
+ const c = t.sizeUnit === "pixels";
817
+ return {
818
+ flexBasis: c ? `${t.preferredPixelSize}px` : `${t.preferredPercentageSize}%`,
819
+ flexGrow: c ? 0 : t.preferredPercentageSize,
820
+ flexShrink: c ? 0 : 1
821
+ };
822
+ }
823
+ if (n.sizeUnit === "pixels")
824
+ return { flexBasis: `${e}px`, flexGrow: 0, flexShrink: 0 };
825
+ const i = Pe(n, r), s = e < i.max - L, l = s && e > i.min + L;
826
+ return { flexBasis: `${e}px`, flexGrow: s ? n.preferredPercentageSize : 0, flexShrink: l ? 1 : 0 };
827
+ }, Zr = pn(
828
+ ({ id: e, defaultSize: n = { value: 50, unit: "percentage" }, minSize: t, maxSize: r, className: o, style: i, children: s, collapsible: l, defaultCollapsed: c = !1, pixelAdjustPriority: a, flexAdjustPriority: g, contentOverflow: d = "auto", ...x }) => {
829
+ const { direction: h, registerPanel: U, unregisterPanel: X, getPanel: se, containerSize: E, showDebugInfo: G, reportPanelMeasurement: B, layoutConstraintViolation: T } = hn(), C = F(null), $ = fn(), v = F(e || `panel-${$}`).current;
830
+ Q(() => {
831
+ e && e !== v && Fn.warn("Panel id prop change after mount is ignored.", { currentId: v, attemptedId: e });
832
+ }, [e, v]);
833
+ const S = P(() => yr(l), [l]), A = S.collapseFromStart || S.collapseFromEnd;
834
+ Q(() => {
835
+ c && !A && Fn.warn("Panel defaultCollapsed is ignored because collapsible configuration is not provided.", { panelId: v });
836
+ }, [c, A, v]);
837
+ const ee = P(() => {
838
+ const p = Tt(n) ?? { value: 50, unit: "percentage" };
839
+ return {
840
+ id: v,
841
+ ...Er(p),
842
+ minSize: t,
843
+ maxSize: r,
844
+ ...S,
845
+ collapsed: A && c,
846
+ pixelAdjustPriority: a,
847
+ flexAdjustPriority: g
848
+ };
849
+ }, [v, n, t, r, S, A, c, a, g]);
850
+ Se(() => {
851
+ U(ee);
852
+ }, [U, ee]), Se(() => () => {
853
+ X(v);
854
+ }, [X, v]);
855
+ const j = se(v), W = j?.size ?? 0, K = j?.collapsed ?? !1, R = F(E);
856
+ R.current = E;
857
+ const z = k(() => {
858
+ const p = C.current;
859
+ if (!p)
860
+ return;
861
+ const f = Ce(p, h).border;
862
+ B(v, { pixelSize: f, percentageSize: jn(f, R.current) });
863
+ }, [h, v, B]);
864
+ Q(() => {
865
+ if (!G) {
866
+ B(v, null);
867
+ return;
868
+ }
869
+ const p = C.current;
870
+ if (!p || typeof ResizeObserver > "u") {
871
+ z();
872
+ return;
873
+ }
874
+ const f = new ResizeObserver(z);
875
+ return f.observe(p), z(), () => {
876
+ f.disconnect(), B(v, null);
877
+ };
878
+ }, [G, z, v, B]);
879
+ const _ = P(() => {
880
+ const p = { overflow: "hidden", isolation: "isolate" }, f = K ? { ...h === "horizontal" ? { width: "0px" } : { height: "0px" }, pointerEvents: "none", visibility: "hidden", display: "none" } : {};
881
+ return {
882
+ ...p,
883
+ ...i,
884
+ // ここから下はレイアウトの前提そのもの。利用者のスタイルやクラスで変わると配分結果と
885
+ // 描画が一致しなくなるため、最後に適用して上書きを受け付けない:
886
+ // flex の三つ組は配分器が決めた長さそのもの、margin はパネルの合計に含まれない隙間を作り、
887
+ // order は DOM 順と視覚順をずらす
888
+ ...zr({ size: W, panel: j, registration: ee, containerSize: E, isCollapsed: K }),
889
+ order: 0,
890
+ margin: 0,
891
+ // 内容を通常フローで内容ボックスいっぱいに伸ばすための入れ物 (パディングを効かせる唯一の形)
892
+ display: "flex",
893
+ flexDirection: "column",
894
+ position: "relative",
895
+ boxSizing: "border-box",
896
+ // 主軸の縮小をコンテンツの固有幅に妨げられないようにし、
897
+ // 上限側のクランプ (max-w-* のようなユーティリティクラスを含む) も受け付けない。
898
+ // 配分器が配った長さより短く描くと、状態と描画が食い違ったままハンドルが動かなくなる
899
+ minWidth: 0,
900
+ minHeight: 0,
901
+ maxWidth: "none",
902
+ maxHeight: "none",
903
+ ...h === "horizontal" ? { height: "100%" } : { width: "100%" },
904
+ ...f
905
+ };
906
+ }, [W, h, K, j, ee, E, i]), u = P(
907
+ () => ({
908
+ // 内容は通常フローの伸縮子として置く。絶対配置にするとパディングボックスを基準にしてしまい、
909
+ // 利用者がパネルへ与えたパディングが何の効果も持たなくなる
910
+ flex: "1 1 auto",
911
+ position: "relative",
912
+ overflow: d,
913
+ display: "flex",
914
+ flexDirection: "column",
915
+ minWidth: "0px",
916
+ minHeight: "0px"
917
+ }),
918
+ [d]
919
+ );
920
+ return /* @__PURE__ */ he(
921
+ "div",
922
+ {
923
+ ...x,
924
+ ref: C,
925
+ className: De("panel", o),
926
+ style: _,
927
+ "data-panel-id": v,
928
+ "data-panel-size": W,
929
+ "data-panel-size-unit": j?.sizeUnit ?? "percentage",
930
+ "data-panel-collapsible": A,
931
+ "data-panel-collapse-start": S.collapseFromStart,
932
+ "data-panel-collapse-end": S.collapseFromEnd,
933
+ "data-panel-collapsed": K,
934
+ "aria-hidden": K,
935
+ inert: T !== null ? !0 : x.inert,
936
+ children: [
937
+ /* @__PURE__ */ ie("div", { style: u, children: s }),
938
+ G && /* @__PURE__ */ ie(xr, { panel: j, containerAxisSize: E, direction: h })
939
+ ]
940
+ }
941
+ );
942
+ }
943
+ ), He = /* @__PURE__ */ new WeakMap(), cn = /* @__PURE__ */ new WeakMap(), Pr = (e) => typeof e.focus == "function", qn = (e) => "activeElement" in e, wr = (e) => e.nodeType === Node.DOCUMENT_FRAGMENT_NODE && "host" in e, un = (e) => e.parentNode !== null ? e.parentNode : wr(e) ? e.host : null, vr = (e, n) => {
944
+ for (let t = e; t !== null; t = un(t))
945
+ if (t === n)
946
+ return !0;
947
+ return !1;
948
+ }, Nr = (e) => {
949
+ if (!qn(e))
950
+ return null;
951
+ let n = e.activeElement;
952
+ for (; n !== null && n.shadowRoot !== null && n.shadowRoot.activeElement !== null; )
953
+ n = n.shadowRoot.activeElement;
954
+ return n;
955
+ }, Xn = (e) => {
956
+ const n = e.getRootNode();
957
+ return qn(n) && n.activeElement === e;
958
+ }, Rr = (e) => {
959
+ const n = e.activeElement;
960
+ return n === null || n === e.body || n === e.documentElement;
961
+ }, dn = (e) => (e.focus({ preventScroll: !0 }), Xn(e)), Ir = (e) => {
962
+ const n = He.get(e);
963
+ return n === void 0 ? e : n;
964
+ }, Lr = (e) => {
965
+ if (!dn(e))
966
+ for (let n = un(e); n !== null; n = un(n)) {
967
+ const t = cn.get(n);
968
+ if (t !== void 0 && dn(t)) {
969
+ He.set(t, e);
970
+ return;
971
+ }
972
+ }
973
+ }, Ar = (e, n) => {
974
+ const t = F(null), r = F(!1), o = k((i) => (t.current = i, r.current = !1, () => {
975
+ r.current = Xn(i), t.current = null;
976
+ }), []);
977
+ return Se(() => {
978
+ if (!n)
979
+ return;
980
+ const i = e.current, s = t.current;
981
+ if (i === null || s === null)
982
+ return;
983
+ cn.set(i, s);
984
+ const l = Nr(i.getRootNode());
985
+ if (l !== null && Pr(l) && vr(l, i)) {
986
+ const c = Ir(l);
987
+ dn(s) && He.set(s, c);
988
+ }
989
+ return () => {
990
+ if (cn.delete(i), s.isConnected)
991
+ return;
992
+ const c = He.get(s);
993
+ c === void 0 || !r.current || !Rr(i.ownerDocument) || Lr(c);
994
+ };
995
+ }, [n, e]), o;
996
+ }, _r = bt(() => import("./GlobalDebugOverlay-CbqXJA1A.js").then((e) => ({ default: e.GlobalDebugOverlayGate }))), Or = [], Dr = {};
997
+ let kn = 0;
998
+ const Tr = () => (kn += 1, `panel-group-${kn}`), Cr = Object.freeze({
999
+ position: "absolute",
1000
+ inset: 0,
1001
+ zIndex: 60,
1002
+ display: "flex",
1003
+ flexDirection: "column",
1004
+ alignItems: "center",
1005
+ justifyContent: "center",
1006
+ backdropFilter: "blur(2px)"
1007
+ }), Mr = Object.freeze({
1008
+ display: "flex",
1009
+ flexDirection: "column",
1010
+ flex: "1 1 0%",
1011
+ width: "100%",
1012
+ minHeight: 0,
1013
+ overflow: "auto",
1014
+ alignItems: "safe center",
1015
+ justifyContent: "safe center",
1016
+ overflowWrap: "anywhere"
1017
+ }), Fr = (e, n) => e.map((t) => {
1018
+ const r = n[t.id];
1019
+ return r ? { ...t, measuredPixelSize: r.pixelSize, measuredPercentageSize: r.percentageSize } : t;
1020
+ }), Bn = (e, n, t) => {
1021
+ const r = Ce(e, "horizontal"), o = Ce(e, "vertical"), i = e.getBoundingClientRect(), s = r.content > 0 ? r.content : n ?? i.width, l = o.content > 0 ? o.content : t ?? i.height;
1022
+ return { width: s, height: l };
1023
+ }, Jr = (e) => {
1024
+ const { id: n, className: t, style: r, children: o, direction: i, onLayout: s, autoSaveId: l, showDebugInfo: c, labels: a, ...g } = e, { groupRef: d, contextValue: x, groupStyle: h } = ar(e), U = P(() => fr(a), [a]), X = fn(), [se, E] = Ne({ width: 0, height: 0 }), G = x.layoutConstraintViolation, T = Ar(d, G !== null), C = P(() => {
1025
+ if (G === null)
1026
+ return null;
1027
+ const { summary: z, detail: _, lang: u } = gr(U, G);
1028
+ return /* @__PURE__ */ he(
1029
+ "section",
1030
+ {
1031
+ ref: T,
1032
+ "aria-labelledby": X,
1033
+ lang: u,
1034
+ tabIndex: 0,
1035
+ className: "gap-2 rounded-lg border border-slate-300 border-dashed bg-slate-100 px-6 py-8 text-center text-slate-800 text-sm focus-visible:outline-2 focus-visible:outline-slate-900 focus-visible:-outline-offset-2 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200 dark:focus-visible:outline-slate-100",
1036
+ style: Mr,
1037
+ "data-panel-group-placeholder": "constraint-violation",
1038
+ children: [
1039
+ /* @__PURE__ */ ie("span", { id: X, className: "max-w-[40ic] leading-normal", children: z }),
1040
+ /* @__PURE__ */ ie("span", { className: "max-w-[40ic] text-slate-700 text-xs leading-normal dark:text-slate-300", children: _ })
1041
+ ]
1042
+ }
1043
+ );
1044
+ }, [G, U, X, T]), $ = F(null);
1045
+ $.current === null && ($.current = n ?? Tr());
1046
+ const M = $.current, v = n ?? M, S = x.showDebugInfo && x.panels.length > 0, A = S ? x.panels : Or, ee = S ? x.panelMeasurements : Dr, j = P(() => {
1047
+ if (!S)
1048
+ return [];
1049
+ const z = Object.values(x.handleMeasurements);
1050
+ return z.length <= 1 ? z : z.slice().sort((_, u) => _.id.localeCompare(u.id));
1051
+ }, [x.handleMeasurements, S]), W = se.width, K = se.height;
1052
+ Se(() => {
1053
+ if (!S) {
1054
+ E({ width: 0, height: 0 });
1055
+ return;
1056
+ }
1057
+ if (typeof window > "u" || typeof ResizeObserver > "u")
1058
+ return;
1059
+ const z = d.current;
1060
+ if (!z)
1061
+ return;
1062
+ const _ = (p) => {
1063
+ E((f) => f.width === p.width && f.height === p.height ? f : p);
1064
+ }, u = new ResizeObserver((p) => {
1065
+ for (const f of p) {
1066
+ if (f.target !== z)
1067
+ continue;
1068
+ const b = Bn(z, f.contentRect.width, f.contentRect.height);
1069
+ _(b);
1070
+ }
1071
+ });
1072
+ return u.observe(z), _(Bn(z)), () => {
1073
+ u.disconnect();
1074
+ };
1075
+ }, [d, S]);
1076
+ const R = P(() => Fr(A, ee), [A, ee]);
1077
+ return Q(() => {
1078
+ if (!S)
1079
+ return;
1080
+ let z = !1, _ = null;
1081
+ return import("./debugOverlayStore-D7FT6zPE.js").then((u) => {
1082
+ z || (_ = u, u.enableDebugOverlayGroup(M));
1083
+ }), () => {
1084
+ z = !0, _ && (_.disableDebugOverlayGroup(M), _.removeDebugOverlayGroup(M));
1085
+ };
1086
+ }, [S, M]), Q(() => {
1087
+ if (!S)
1088
+ return;
1089
+ let z = !1;
1090
+ return import("./debugOverlayStore-D7FT6zPE.js").then((_) => {
1091
+ z || _.updateDebugOverlayGroup(M, {
1092
+ displayName: v,
1093
+ direction: i,
1094
+ containerSize: {
1095
+ width: W,
1096
+ height: K
1097
+ },
1098
+ panels: R,
1099
+ handles: j
1100
+ });
1101
+ }), () => {
1102
+ z = !0;
1103
+ };
1104
+ }, [S, M, v, i, W, K, R, j]), /* @__PURE__ */ he(Yn.Provider, { value: x, children: [
1105
+ /* @__PURE__ */ he("div", { ...g, ref: d, className: De("panel-group", i === "horizontal" ? "flex-row" : "flex-col", t), style: h, "data-panel-group-id": n, "data-panel-group-direction": i, children: [
1106
+ o,
1107
+ C !== null ? /* @__PURE__ */ ie("div", { className: "pointer-events-auto bg-slate-50/82 dark:bg-slate-950/82", style: Cr, children: C }) : null
1108
+ ] }),
1109
+ S && /* @__PURE__ */ ie(gt, { fallback: null, children: /* @__PURE__ */ ie(_r, { groupId: M }) })
1110
+ ] });
1111
+ }, kr = {
1112
+ display: "none",
1113
+ pointerEvents: "none",
1114
+ visibility: "hidden"
1115
+ }, Br = {
1116
+ display: "none"
1117
+ }, Oe = (e, n) => typeof e != "number" || !Number.isFinite(e) || e <= 0 ? n : e, $r = (e) => {
1118
+ const n = Math.round(e);
1119
+ return n % 2 === 0 ? n : n + 1;
1120
+ }, $n = (e) => !e || typeof window > "u" ? !1 : window.getComputedStyle(e).direction === "rtl", nn = (e, n, t) => {
1121
+ const r = e.collapsed ? 0 : e.size, o = n.collapsed ? 0 : n.size, i = r + o;
1122
+ if (i <= 0)
1123
+ return;
1124
+ const s = Pe(e, t), l = Pe(n, t), c = Math.max(s.min, i - l.max), a = Math.max(c, Math.min(s.max, i - l.min));
1125
+ if (e.collapsed)
1126
+ return { position: 0, lower: 0, upper: e.collapsedByDirection === "end" ? Math.max(0, a) : 0, resizeLower: c, resizeUpper: a };
1127
+ if (n.collapsed) {
1128
+ const x = n.collapsedByDirection === "start";
1129
+ return { position: i, lower: x ? Math.min(i, c) : i, upper: i, resizeLower: c, resizeUpper: a };
1130
+ }
1131
+ const g = Math.min(r, e.collapseFromEnd ? 0 : c), d = Math.max(r, g, n.collapseFromStart ? i : a);
1132
+ return { position: r, lower: g, upper: d, resizeLower: c, resizeUpper: a };
1133
+ }, Hr = Object.freeze([]), Gr = (e) => {
1134
+ if (typeof e == "number")
1135
+ return Number.isFinite(e) && e >= 0;
1136
+ if (typeof e != "object" || e === null)
1137
+ return !1;
1138
+ const { value: n, unit: t } = e;
1139
+ return (t === "pixels" || t === "percentage") && typeof n == "number" && Number.isFinite(n) && n >= 0;
1140
+ }, Ge = (e) => {
1141
+ if (typeof e == "string")
1142
+ return JSON.stringify(e);
1143
+ if (typeof e != "object" || e === null || Array.isArray(e))
1144
+ return String(e);
1145
+ const { value: n, unit: t } = e;
1146
+ return `{ value: ${Ge(n)}, unit: ${Ge(t)} }`;
1147
+ }, jr = (e) => {
1148
+ if (e === void 0)
1149
+ return Hr;
1150
+ if (!Array.isArray(e))
1151
+ throw new RangeError(`[resize-panels] activationSizes must be an array of sizes; received ${Ge(e)}.`);
1152
+ for (const [n, t] of e.entries())
1153
+ if (!Gr(t))
1154
+ throw new RangeError(`[resize-panels] activationSizes[${n}] must be a non-negative finite percentage or { value, unit: "pixels" | "percentage" } with a non-negative finite value; received ${Ge(t)}.`);
1155
+ return e;
1156
+ }, Ur = (e, n, t) => {
1157
+ let r, o;
1158
+ for (const i of e) {
1159
+ const s = Te(tn(i, 0, t), n.resizeLower, n.resizeUpper);
1160
+ Math.abs(s - n.position) <= L || ((o === void 0 || s < o) && (o = s), s > n.position && (r === void 0 || s < r) && (r = s));
1161
+ }
1162
+ return r === void 0 ? o : r;
1163
+ }, Qr = pn((e) => {
1164
+ const { id: n, disabled: t = !1, className: r, style: o, children: i, onDragging: s, activationSizes: l, thickness: c, indicator: a = !0, indicatorThickness: g, indicatorLength: d, indicatorBarThickness: x, indicatorBarLength: h, title: U, onPointerDown: X, onKeyDown: se, ...E } = e, { direction: G, resizePanels: B, getPanel: T, collapsePanel: C, expandPanel: $, panels: M, layoutOrderKey: v, reportHandleMeasurement: S, containerSize: A, layoutConstraintViolation: ee } = hn(), j = P(() => jr(l), [l]), [W, K] = Ne(!1), [R, z] = Ne({ start: null, end: null }), _ = F(null), u = F(null), p = F({ getPanel: T, containerSize: A });
1165
+ p.current = { getPanel: T, containerSize: A };
1166
+ const f = F(""), b = F(""), I = F(null), le = F(null), Ue = fn(), Re = F(n ?? `resize-handle-${Ue}`), ye = n ?? Re.current, w = G === "horizontal", We = !!ee, ne = t || We, gn = k(() => {
1167
+ const m = _.current, Z = Be(m);
1168
+ if (!(m && Z))
1169
+ return;
1170
+ const H = Wn(Z), O = H.indexOf(m);
1171
+ let D = "", Y = "";
1172
+ for (let V = O - 1; V >= 0; V -= 1) {
1173
+ const N = H[V].dataset.panelId;
1174
+ if (N !== void 0) {
1175
+ D = N;
1176
+ break;
1177
+ }
1178
+ }
1179
+ for (let V = O + 1; V < H.length; V += 1) {
1180
+ const N = H[V].dataset.panelId;
1181
+ if (N !== void 0) {
1182
+ Y = N;
1183
+ break;
1184
+ }
1185
+ }
1186
+ D === f.current && Y === b.current || (f.current = D, b.current = Y, z({ start: D || null, end: Y || null }));
1187
+ }, []);
1188
+ Q(() => {
1189
+ gn();
1190
+ }, [gn, v]), Q(() => () => {
1191
+ I.current?.();
1192
+ }, []);
1193
+ const bn = k(
1194
+ (m) => {
1195
+ if (ne || I.current || m.button !== 0)
1196
+ return;
1197
+ const Z = T(f.current), H = T(b.current);
1198
+ if (!(Z && H))
1199
+ return;
1200
+ m.preventDefault(), m.stopPropagation();
1201
+ const O = f.current, D = b.current, Y = Z.size, V = Z.size + H.size, N = m.clientX, oe = m.clientY, ve = w ? N : oe, q = Be(_.current), ct = w && $n(q) ? -1 : 1, ut = q ? kt(q, G) : 1, Ee = m.pointerId, Ae = m.currentTarget;
1202
+ Ae.setPointerCapture?.(Ee), K(!0), s?.(!0);
1203
+ let En = 0, _e = null, Ke = j.length > 0;
1204
+ const zn = (y) => Math.hypot(y.clientX - N, y.clientY - oe) >= It, dt = (y) => {
1205
+ const ce = ((w ? y.clientX : y.clientY) - ve) * ct / ut, de = Y + ce, be = V - de, ze = p.current, Xe = ze.getPanel(O), Ze = ze.getPanel(D);
1206
+ if (!(Xe && Ze))
1207
+ return;
1208
+ const In = Math.min(ze.containerSize * Hn, Gn), Ln = Math.min(ze.containerSize * Lt, At);
1209
+ if (Ze.collapsed) {
1210
+ be > Ln && $(D, "start", be, "pointer");
1211
+ return;
1212
+ }
1213
+ if (Xe.collapsed) {
1214
+ de > Ln && $(O, "end", de, "pointer");
1215
+ return;
1216
+ }
1217
+ if (Ze.collapseFromStart && be <= In) {
1218
+ C(D, "start", "pointer");
1219
+ return;
1220
+ }
1221
+ if (Xe.collapseFromEnd && de <= In) {
1222
+ C(O, "end", "pointer");
1223
+ return;
1224
+ }
1225
+ B(O, D, de, "pointer");
1226
+ }, qe = (y) => {
1227
+ An(() => {
1228
+ dt(y);
1229
+ });
1230
+ }, pt = () => {
1231
+ const y = p.current, ce = y.getPanel(O), de = y.getPanel(D);
1232
+ if (!(ce && de))
1233
+ return;
1234
+ const be = nn(ce, de, y.containerSize);
1235
+ if (!be || be.upper - be.lower <= L)
1236
+ return;
1237
+ const ze = Ur(j, be, y.containerSize);
1238
+ ze !== void 0 && An(() => {
1239
+ ce.collapsed ? $(O, "end", void 0, "pointer") : de.collapsed && $(D, "start", void 0, "pointer"), B(O, D, ze, "pointer");
1240
+ });
1241
+ }, Pn = (y) => {
1242
+ if (y.pointerId !== Ee)
1243
+ return;
1244
+ if (y.preventDefault(), y.stopPropagation(), Ke) {
1245
+ if (!zn(y))
1246
+ return;
1247
+ Ke = !1;
1248
+ }
1249
+ const ce = performance.now();
1250
+ if (ce - En < Rt) {
1251
+ _e = y;
1252
+ return;
1253
+ }
1254
+ En = ce, _e = null, qe(y);
1255
+ };
1256
+ let wn = !0;
1257
+ const ke = () => {
1258
+ wn && (wn = !1, I.current = null, K(!1), s?.(!1), document.removeEventListener("pointermove", Pn), document.removeEventListener("pointerup", vn), document.removeEventListener("pointercancel", Nn), Ae.removeEventListener("lostpointercapture", Rn), Ae.hasPointerCapture?.(Ee) && Ae.releasePointerCapture(Ee));
1259
+ }, vn = (y) => {
1260
+ if (y.pointerId === Ee) {
1261
+ if (Ke)
1262
+ zn(y) ? qe(y) : pt();
1263
+ else if (_e) {
1264
+ const ce = _e;
1265
+ _e = null, qe(ce);
1266
+ }
1267
+ ke();
1268
+ }
1269
+ }, Nn = (y) => {
1270
+ y.pointerId === Ee && ke();
1271
+ }, Rn = (y) => {
1272
+ y.pointerId === Ee && ke();
1273
+ };
1274
+ document.addEventListener("pointermove", Pn), document.addEventListener("pointerup", vn), document.addEventListener("pointercancel", Nn), Ae.addEventListener("lostpointercapture", Rn), I.current = ke;
1275
+ },
1276
+ [ne, w, G, T, B, C, $, s, j]
1277
+ ), xn = k(
1278
+ (m) => {
1279
+ if (ne)
1280
+ return;
1281
+ const Z = w ? "ArrowLeft" : "ArrowUp", H = w ? "ArrowRight" : "ArrowDown";
1282
+ if (m.key !== Z && m.key !== H)
1283
+ return;
1284
+ const O = f.current, D = b.current, Y = T(O), V = T(D);
1285
+ if (!(Y && V))
1286
+ return;
1287
+ const N = nn(Y, V, A);
1288
+ if (!N || N.upper - N.lower <= L)
1289
+ return;
1290
+ m.preventDefault(), m.stopPropagation();
1291
+ const oe = m.shiftKey ? _n * 5 : _n, ve = w && $n(Be(_.current)) ? -1 : 1, q = (m.key === H ? oe : -oe) * ve;
1292
+ if (Y.collapsed) {
1293
+ q > 0 && $(O, "end", void 0, "keyboard");
1294
+ return;
1295
+ }
1296
+ if (V.collapsed) {
1297
+ q < 0 && $(D, "start", void 0, "keyboard");
1298
+ return;
1299
+ }
1300
+ if (q < 0 && Y.collapseFromEnd && N.position <= N.resizeLower + L) {
1301
+ C(O, "end", "keyboard");
1302
+ return;
1303
+ }
1304
+ if (q > 0 && V.collapseFromStart && N.position >= N.resizeUpper - L) {
1305
+ C(D, "start", "keyboard");
1306
+ return;
1307
+ }
1308
+ B(O, D, Y.size + q, "keyboard");
1309
+ },
1310
+ [ne, w, T, B, C, $, A]
1311
+ ), ue = typeof a == "object" && a !== null ? a : void 0, Ve = a === !1 || ue?.visible === !1, re = Math.max(1, Oe(c, St)), Zn = w ? Et : zt, Jn = w ? wt : vt, me = Math.min(re, Math.max(1, Oe(g ?? ue?.thickness, yt))), we = Math.max(1, Oe(d ?? ue?.length, Zn)), Ie = Math.min(me, Math.max(1, Oe(x ?? ue?.barThickness, Pt))), Le = Math.min(we, Math.max(1, Oe(h ?? ue?.barLength, Jn))), ge = P(() => {
1312
+ const m = Un(A), Z = (N) => {
1313
+ const oe = M[N];
1314
+ return oe ? oe.collapsed || oe.size <= m : !1;
1315
+ }, H = (N, oe) => {
1316
+ let ve = 0;
1317
+ for (let q = N; q >= 0 && q < M.length && Z(q); q += oe)
1318
+ ve += 1;
1319
+ return ve;
1320
+ }, O = M.findIndex((N) => N.id === R.start), D = M.findIndex((N) => N.id === R.end), Y = O >= 0 ? H(O, -1) : 0, V = D >= 0 ? H(D, 1) : 0;
1321
+ return { groupSize: Y + V + 1, overlapIndex: Y };
1322
+ }, [R.start, R.end, M, A]), ae = P(() => We ? !0 : ge.groupSize <= 1 ? !1 : ge.overlapIndex > 0 && ge.overlapIndex < ge.groupSize - 1, [ge, We]), Fe = P(() => {
1323
+ if (ge.groupSize <= 1 || ae)
1324
+ return 0;
1325
+ const m = $r(Math.max(Nt, me + 4));
1326
+ return (ge.overlapIndex === 0 ? -0.5 : 0.5) * m;
1327
+ }, [ge, ae, me]), Qn = P(() => {
1328
+ const m = {
1329
+ // 長さ 0 のフレックスアイテム: フレックスレイアウトがこれを境界そのものへ配置する
1330
+ position: "relative",
1331
+ flex: "0 0 0px",
1332
+ alignSelf: "stretch",
1333
+ // DOM 順を配置順の真実として扱うため、クラス由来の order で並びが変わらないようにする
1334
+ order: 0,
1335
+ margin: 0,
1336
+ overflow: "visible",
1337
+ ...w ? { width: 0, minWidth: 0 } : { height: 0, minHeight: 0 }
1338
+ };
1339
+ return ae ? { ...m, ...kr } : m;
1340
+ }, [w, ae]), Sn = P(
1341
+ () => ({
1342
+ "--rp-handle-thickness": `${re}px`,
1343
+ "--rp-indicator-thickness": `${me}px`,
1344
+ "--rp-indicator-length": `${we}px`,
1345
+ "--rp-indicator-bar-thickness": `${Ie}px`,
1346
+ "--rp-indicator-bar-length": `${Le}px`
1347
+ }),
1348
+ [re, me, we, Ie, Le]
1349
+ ), et = P(() => ({
1350
+ ...Sn,
1351
+ ...o,
1352
+ // ここから下は境界に載るという前提そのもの。利用者のスタイルやクラスで変わると
1353
+ // 操作領域の中心が境界から外れ、touch-action が戻るとタッチではスクロールが優先されてしまう
1354
+ position: "absolute",
1355
+ zIndex: 20,
1356
+ touchAction: "none",
1357
+ // 位置は論理プロパティで与える。アンカーは寸法 0 なので RTL でも同じ点に重なるが、
1358
+ // 「境界からの距離」という意図をそのまま表せる
1359
+ ...w ? { insetBlockStart: 0, insetInlineStart: `${-re / 2}px`, width: `${re}px`, height: "100%" } : { insetInlineStart: 0, insetBlockStart: `${-re / 2}px`, height: `${re}px`, width: "100%" }
1360
+ }), [w, re, Sn, o]), nt = P(() => {
1361
+ if (ae || Ve)
1362
+ return Br;
1363
+ const m = {
1364
+ width: `${w ? me : we}px`,
1365
+ height: `${w ? we : me}px`,
1366
+ flexShrink: 0
1367
+ };
1368
+ return Fe !== 0 && (m.position = "relative", w ? m.insetInlineStart = `${Fe}px` : m.insetBlockStart = `${Fe}px`), m;
1369
+ }, [ae, Ve, w, me, we, Fe]), tt = P(
1370
+ () => ({
1371
+ width: `${w ? Ie : Le}px`,
1372
+ height: `${w ? Le : Ie}px`,
1373
+ flexShrink: 0
1374
+ }),
1375
+ [w, Ie, Le]
1376
+ ), rt = P(
1377
+ () => De(
1378
+ "group absolute z-20 flex select-none items-center justify-center border-none bg-transparent transition-colors duration-150 overflow-visible",
1379
+ w ? "cursor-col-resize h-full" : "cursor-row-resize w-full",
1380
+ !ne && "hover:bg-gray-200/70 dark:hover:bg-gray-700/70",
1381
+ !ne && "active:bg-blue-300/60 dark:active:bg-blue-700/60",
1382
+ W && "bg-blue-200/80 dark:bg-blue-800/60",
1383
+ ne && "cursor-not-allowed opacity-50",
1384
+ "focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50",
1385
+ r
1386
+ ),
1387
+ [w, ne, W, r]
1388
+ ), ot = P(
1389
+ () => De(
1390
+ "pointer-events-none flex items-center justify-center rounded-full bg-white text-slate-700 ring-1 ring-inset ring-white/80 backdrop-blur-sm transition-colors duration-150 shadow-[0_0_0_1px_rgba(255,255,255,0.85),0_1px_3px_rgba(15,23,42,0.18)]",
1391
+ "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)]",
1392
+ W && "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)]",
1393
+ ue?.className
1394
+ ),
1395
+ [W, ue?.className]
1396
+ ), it = P(
1397
+ () => De(
1398
+ "pointer-events-none rounded-full bg-slate-600 transition-colors duration-150 shadow-[0_0_0_1px_rgba(255,255,255,0.9)] dark:bg-slate-200 dark:shadow-[0_0_0_1px_rgba(15,23,42,0.55)]",
1399
+ W && "bg-blue-500 dark:bg-blue-300",
1400
+ !ne && "group-hover:bg-slate-700 dark:group-hover:bg-slate-100",
1401
+ ue?.barClassName
1402
+ ),
1403
+ [W, ne, ue?.barClassName]
1404
+ );
1405
+ Q(() => {
1406
+ if (ye === Re.current)
1407
+ return;
1408
+ const m = Re.current;
1409
+ Re.current = ye, le.current = null, S(m, null);
1410
+ }, [S, ye]), Q(() => {
1411
+ const m = {
1412
+ id: ye,
1413
+ thickness: ae ? 0 : re,
1414
+ direction: G,
1415
+ visible: !ae && re > _t,
1416
+ startPanelId: R.start,
1417
+ endPanelId: R.end
1418
+ };
1419
+ le.current = m, S(ye, m);
1420
+ }, [ye, re, ae, G, R.start, R.end, S]), Q(() => () => {
1421
+ S(Re.current, null);
1422
+ }, [S]);
1423
+ const st = k(
1424
+ (m) => {
1425
+ X?.(m), m.defaultPrevented || bn(m);
1426
+ },
1427
+ [X, bn]
1428
+ ), lt = k(
1429
+ (m) => {
1430
+ se?.(m), m.defaultPrevented || xn(m);
1431
+ },
1432
+ [se, xn]
1433
+ ), at = j.length > 0 ? "click to cycle through preset sizes, " : "", yn = `Resize ${w ? "columns" : "rows"} - Drag or use arrow keys to resize, ${at}drag to the edge to collapse/expand panels`, Ye = P(() => {
1434
+ const m = R.start === null ? void 0 : T(R.start), Z = R.end === null ? void 0 : T(R.end);
1435
+ if (!(m && Z) || A <= 0)
1436
+ return;
1437
+ const H = nn(m, Z, A);
1438
+ if (!H)
1439
+ return;
1440
+ const O = (D) => Math.round(D / A * 100);
1441
+ return { now: O(H.position), min: O(H.lower), max: O(H.upper) };
1442
+ }, [R.start, R.end, T, A]);
1443
+ return /* @__PURE__ */ ie("div", { ref: _, style: Qn, "data-resize-handle-anchor": "", children: /* @__PURE__ */ ie(
1444
+ "button",
1445
+ {
1446
+ ...E,
1447
+ type: "button",
1448
+ ref: u,
1449
+ className: rt,
1450
+ style: et,
1451
+ onPointerDown: st,
1452
+ onKeyDown: lt,
1453
+ disabled: ne,
1454
+ role: "separator",
1455
+ "aria-orientation": w ? "vertical" : "horizontal",
1456
+ "aria-valuenow": Ye?.now,
1457
+ "aria-valuemin": Ye?.min,
1458
+ "aria-valuemax": Ye?.max,
1459
+ "aria-disabled": ne || void 0,
1460
+ "aria-hidden": ae || void 0,
1461
+ "aria-label": E["aria-label"] ?? yn,
1462
+ "data-resize-handle-id": ye,
1463
+ title: U ?? yn,
1464
+ children: i || !Ve && /* @__PURE__ */ ie("div", { className: ot, style: nt, "data-resize-handle-indicator": "", "aria-hidden": "true", children: /* @__PURE__ */ ie("span", { className: it, style: tt, "data-resize-handle-indicator-bar": "", "aria-hidden": "true" }) })
1465
+ }
1466
+ ) });
1467
+ }), mn = (e) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&"), eo = (e) => typeof document > "u" ? null : document.querySelector(`[data-panel-id="${mn(e)}"]`), no = (e) => typeof document > "u" ? null : document.querySelector(`[data-panel-group-id="${mn(e)}"]`), to = (e) => typeof document > "u" ? null : document.querySelector(`[data-resize-handle-id="${mn(e)}"]`);
1468
+ export {
1469
+ Xr as A,
1470
+ hn as B,
1471
+ ar as C,
1472
+ an as D,
1473
+ xt as P,
1474
+ ur as a,
1475
+ Zr as b,
1476
+ Jr as c,
1477
+ Yn as d,
1478
+ Qr as e,
1479
+ Ut as f,
1480
+ Un as g,
1481
+ Te as h,
1482
+ Yt as i,
1483
+ Be as j,
1484
+ tn as k,
1485
+ Ce as l,
1486
+ Wn as m,
1487
+ eo as n,
1488
+ no as o,
1489
+ Zt as p,
1490
+ to as q,
1491
+ Vt as r,
1492
+ te as s,
1493
+ Bt as t,
1494
+ Tt as u,
1495
+ Qt as v,
1496
+ qr as w,
1497
+ Pe as x,
1498
+ On as y,
1499
+ jn as z
1500
+ };