react-resizable-panels 4.12.4 → 4.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,21 @@
1
1
  "use client";
2
- import { jsx as se } from "react/jsx-runtime";
3
- import { useState as Q, useCallback as ie, useId as mt, useLayoutEffect as Ke, useEffect as ge, useRef as O, createContext as gt, useImperativeHandle as Xe, useMemo as ve, useSyncExternalStore as qe, useContext as yt } from "react";
4
- function St(e, t) {
2
+ import { jsx as U, jsxs as wt } from "react/jsx-runtime";
3
+ import { useState as Z, useCallback as ce, useId as Pt, useLayoutEffect as Qe, useEffect as Se, useRef as O, createContext as Lt, useContext as Ct, isValidElement as Rt, useImperativeHandle as et, useMemo as Pe, useSyncExternalStore as tt } from "react";
4
+ function Mt(e, t) {
5
5
  const n = getComputedStyle(e), o = parseFloat(n.fontSize);
6
6
  return t * o;
7
7
  }
8
- function vt(e, t) {
8
+ function Et(e, t) {
9
9
  const n = getComputedStyle(e.ownerDocument.documentElement), o = parseFloat(n.fontSize);
10
10
  return t * o;
11
11
  }
12
- function bt(e) {
12
+ function It(e) {
13
13
  return e / 100 * window.innerHeight;
14
14
  }
15
- function zt(e) {
15
+ function kt(e) {
16
16
  return e / 100 * window.innerWidth;
17
17
  }
18
- function xt(e) {
18
+ function Tt(e) {
19
19
  switch (typeof e) {
20
20
  case "number":
21
21
  return [e, "px"];
@@ -25,52 +25,52 @@ function xt(e) {
25
25
  }
26
26
  }
27
27
  }
28
- function oe({
28
+ function ie({
29
29
  groupSize: e,
30
30
  panelElement: t,
31
31
  styleProp: n
32
32
  }) {
33
33
  let o;
34
- const [i, s] = xt(n);
34
+ const [r, s] = Tt(n);
35
35
  switch (s) {
36
36
  case "%": {
37
- o = i / 100 * e;
37
+ o = r / 100 * e;
38
38
  break;
39
39
  }
40
40
  case "px": {
41
- o = i;
41
+ o = r;
42
42
  break;
43
43
  }
44
44
  case "rem": {
45
- o = vt(t, i);
45
+ o = Et(t, r);
46
46
  break;
47
47
  }
48
48
  case "em": {
49
- o = St(t, i);
49
+ o = Mt(t, r);
50
50
  break;
51
51
  }
52
52
  case "vh": {
53
- o = bt(i);
53
+ o = It(r);
54
54
  break;
55
55
  }
56
56
  case "vw": {
57
- o = zt(i);
57
+ o = kt(r);
58
58
  break;
59
59
  }
60
60
  }
61
61
  return o;
62
62
  }
63
- function T(e) {
63
+ function A(e) {
64
64
  return parseFloat(e.toFixed(3));
65
65
  }
66
- function ne({
66
+ function ae({
67
67
  group: e
68
68
  }) {
69
69
  const { orientation: t, panels: n } = e;
70
- return n.reduce((o, i) => (o += t === "horizontal" ? i.element.offsetWidth : i.element.offsetHeight, o), 0);
70
+ return n.reduce((o, r) => (o += t === "horizontal" ? r.element.offsetWidth : r.element.offsetHeight, o), 0);
71
71
  }
72
- function be(e) {
73
- const { panels: t } = e, n = ne({ group: e });
72
+ function Le(e) {
73
+ const { panels: t } = e, n = ae({ group: e });
74
74
  return n === 0 ? t.map((o) => ({
75
75
  groupResizeBehavior: o.panelConstraints.groupResizeBehavior,
76
76
  collapsedSize: 0,
@@ -81,226 +81,66 @@ function be(e) {
81
81
  maxSize: 100,
82
82
  panelId: o.id
83
83
  })) : t.map((o) => {
84
- const { element: i, panelConstraints: s } = o;
85
- let u = 0;
84
+ const { element: r, panelConstraints: s } = o;
85
+ let i = 0;
86
86
  if (s.collapsedSize !== void 0) {
87
- const c = oe({
87
+ const f = ie({
88
88
  groupSize: n,
89
- panelElement: i,
89
+ panelElement: r,
90
90
  styleProp: s.collapsedSize
91
91
  });
92
- u = T(c / n * 100);
92
+ i = A(f / n * 100);
93
93
  }
94
- let a;
94
+ let u;
95
+ if (s.collapsedThreshold !== void 0) {
96
+ const f = ie({
97
+ groupSize: n,
98
+ panelElement: r,
99
+ styleProp: s.collapsedThreshold
100
+ });
101
+ u = A(f / n * 100);
102
+ }
103
+ let c;
95
104
  if (s.defaultSize !== void 0) {
96
- const c = oe({
105
+ const f = ie({
97
106
  groupSize: n,
98
- panelElement: i,
107
+ panelElement: r,
99
108
  styleProp: s.defaultSize
100
109
  });
101
- a = T(c / n * 100);
110
+ c = A(f / n * 100);
102
111
  }
103
- let r = 0;
112
+ let a = 0;
104
113
  if (s.minSize !== void 0) {
105
- const c = oe({
114
+ const f = ie({
106
115
  groupSize: n,
107
- panelElement: i,
116
+ panelElement: r,
108
117
  styleProp: s.minSize
109
118
  });
110
- r = T(c / n * 100);
119
+ a = A(f / n * 100);
111
120
  }
112
121
  let l = 100;
113
122
  if (s.maxSize !== void 0) {
114
- const c = oe({
123
+ const f = ie({
115
124
  groupSize: n,
116
- panelElement: i,
125
+ panelElement: r,
117
126
  styleProp: s.maxSize
118
127
  });
119
- l = T(c / n * 100);
128
+ l = A(f / n * 100);
120
129
  }
121
130
  return {
122
131
  groupResizeBehavior: s.groupResizeBehavior,
123
- collapsedSize: u,
132
+ collapsedSize: i,
133
+ collapsedThreshold: u,
124
134
  collapsible: s.collapsible === !0,
125
- defaultSize: a,
135
+ defaultSize: c,
126
136
  disabled: s.disabled,
127
- minSize: r,
137
+ minSize: a,
128
138
  maxSize: l,
129
139
  panelId: o.id
130
140
  };
131
141
  });
132
142
  }
133
- function C(e, t = "Assertion error") {
134
- if (!e)
135
- throw Error(t);
136
- }
137
- function ze(e, t) {
138
- return Array.from(t).sort(
139
- e === "horizontal" ? Pt : wt
140
- );
141
- }
142
- function Pt(e, t) {
143
- const n = e.element.offsetLeft - t.element.offsetLeft;
144
- return n !== 0 ? n : e.element.offsetWidth - t.element.offsetWidth;
145
- }
146
- function wt(e, t) {
147
- const n = e.element.offsetTop - t.element.offsetTop;
148
- return n !== 0 ? n : e.element.offsetHeight - t.element.offsetHeight;
149
- }
150
- function Ye(e) {
151
- return e !== null && typeof e == "object" && "nodeType" in e && e.nodeType === Node.ELEMENT_NODE;
152
- }
153
- function Je(e, t) {
154
- return {
155
- x: e.x >= t.left && e.x <= t.right ? 0 : Math.min(
156
- Math.abs(e.x - t.left),
157
- Math.abs(e.x - t.right)
158
- ),
159
- y: e.y >= t.top && e.y <= t.bottom ? 0 : Math.min(
160
- Math.abs(e.y - t.top),
161
- Math.abs(e.y - t.bottom)
162
- )
163
- };
164
- }
165
- function Lt({
166
- orientation: e,
167
- rects: t,
168
- targetRect: n
169
- }) {
170
- const o = {
171
- x: n.x + n.width / 2,
172
- y: n.y + n.height / 2
173
- };
174
- let i, s = Number.MAX_VALUE;
175
- for (const u of t) {
176
- const { x: a, y: r } = Je(o, u), l = e === "horizontal" ? a : r;
177
- l < s && (s = l, i = u);
178
- }
179
- return C(i, "No rect found"), i;
180
- }
181
- let de;
182
- function Ct() {
183
- return de === void 0 && (typeof matchMedia == "function" ? de = !!matchMedia("(pointer:coarse)").matches : de = !1), de;
184
- }
185
- function Ze(e) {
186
- const { element: t, orientation: n, panels: o, separators: i } = e, s = ze(
187
- n,
188
- Array.from(t.children).filter(Ye).map((z) => ({ element: z }))
189
- ).map(({ element: z }) => z), u = [];
190
- let a = !1, r = !1, l = -1, c = -1, m = 0, p, S = [];
191
- {
192
- let z = -1;
193
- for (const f of s)
194
- f.hasAttribute("data-panel") && (z++, f.hasAttribute("data-disabled") || (m++, l === -1 && (l = z), c = z));
195
- }
196
- if (m > 1) {
197
- let z = -1;
198
- for (const f of s)
199
- if (f.hasAttribute("data-panel")) {
200
- z++;
201
- const d = o.find(
202
- (h) => h.element === f
203
- );
204
- if (d) {
205
- if (p) {
206
- const h = p.element.getBoundingClientRect(), y = f.getBoundingClientRect();
207
- let b;
208
- if (r) {
209
- const v = n === "horizontal" ? new DOMRect(
210
- h.right,
211
- h.top,
212
- 0,
213
- h.height
214
- ) : new DOMRect(
215
- h.left,
216
- h.bottom,
217
- h.width,
218
- 0
219
- ), g = n === "horizontal" ? new DOMRect(y.left, y.top, 0, y.height) : new DOMRect(y.left, y.top, y.width, 0);
220
- switch (S.length) {
221
- case 0: {
222
- b = [
223
- v,
224
- g
225
- ];
226
- break;
227
- }
228
- case 1: {
229
- const w = S[0], E = Lt({
230
- orientation: n,
231
- rects: [h, y],
232
- targetRect: w.element.getBoundingClientRect()
233
- });
234
- b = [
235
- w,
236
- E === h ? g : v
237
- ];
238
- break;
239
- }
240
- default: {
241
- b = S;
242
- break;
243
- }
244
- }
245
- } else
246
- S.length ? b = S : b = [
247
- n === "horizontal" ? new DOMRect(
248
- h.right,
249
- y.top,
250
- y.left - h.right,
251
- y.height
252
- ) : new DOMRect(
253
- y.left,
254
- h.bottom,
255
- y.width,
256
- y.top - h.bottom
257
- )
258
- ];
259
- for (const v of b) {
260
- let g = "width" in v ? v : v.element.getBoundingClientRect();
261
- const w = Ct() ? e.resizeTargetMinimumSize.coarse : e.resizeTargetMinimumSize.fine;
262
- if (g.width < w) {
263
- const L = w - g.width;
264
- g = new DOMRect(
265
- g.x - L / 2,
266
- g.y,
267
- g.width + L,
268
- g.height
269
- );
270
- }
271
- if (g.height < w) {
272
- const L = w - g.height;
273
- g = new DOMRect(
274
- g.x,
275
- g.y - L / 2,
276
- g.width,
277
- g.height + L
278
- );
279
- }
280
- const E = z <= l || z > c;
281
- !a && !E && u.push({
282
- group: e,
283
- groupSize: ne({ group: e }),
284
- panels: [p, d],
285
- separator: "width" in v ? void 0 : v,
286
- rect: g
287
- }), a = !1;
288
- }
289
- }
290
- r = !1, p = d, S = [];
291
- }
292
- } else if (f.hasAttribute("data-separator")) {
293
- f.ariaDisabled !== null && (a = !0);
294
- const d = i.find(
295
- (h) => h.element === f
296
- );
297
- d ? S.push(d) : (p = void 0, S = []);
298
- } else
299
- r = !0;
300
- }
301
- return u;
302
- }
303
- class Qe {
143
+ class nt {
304
144
  #e = {};
305
145
  addListener(t, n) {
306
146
  const o = this.#e[t];
@@ -314,17 +154,17 @@ class Qe {
314
154
  if (o.length === 1)
315
155
  o[0].call(null, n);
316
156
  else {
317
- let i = !1, s = null;
318
- const u = Array.from(o);
319
- for (let a = 0; a < u.length; a++) {
320
- const r = u[a];
157
+ let r = !1, s = null;
158
+ const i = Array.from(o);
159
+ for (let u = 0; u < i.length; u++) {
160
+ const c = i[u];
321
161
  try {
322
- r.call(null, n);
323
- } catch (l) {
324
- s === null && (i = !0, s = l);
162
+ c.call(null, n);
163
+ } catch (a) {
164
+ s === null && (r = !0, s = a);
325
165
  }
326
166
  }
327
- if (i)
167
+ if (r)
328
168
  throw s;
329
169
  }
330
170
  }
@@ -334,48 +174,80 @@ class Qe {
334
174
  removeListener(t, n) {
335
175
  const o = this.#e[t];
336
176
  if (o !== void 0) {
337
- const i = o.indexOf(n);
338
- i >= 0 && o.splice(i, 1);
177
+ const r = o.indexOf(n);
178
+ r >= 0 && o.splice(r, 1);
339
179
  }
340
180
  }
341
181
  }
342
- let ee = {
182
+ let T = {
343
183
  cursorFlags: 0,
344
184
  state: "inactive"
345
185
  };
346
- const xe = new Qe();
347
- function W() {
348
- return ee;
186
+ const Re = new nt();
187
+ function X() {
188
+ return T;
349
189
  }
350
- function Rt(e) {
351
- return xe.addListener("change", e);
190
+ function ot(e) {
191
+ return Re.addListener("change", e);
352
192
  }
353
- function Et(e) {
354
- const t = ee, n = { ...ee };
355
- n.cursorFlags = e, ee = n, xe.emit("change", {
356
- prev: t,
357
- next: n
193
+ function Dt(e, t = [], n) {
194
+ const o = T, r = { ...T };
195
+ r.cursorFlags = e, r.state === "active" && (r.previews = t, n && (r.previewLayoutMap = n)), T = r, Re.emit("change", {
196
+ prev: o,
197
+ next: r
358
198
  });
359
199
  }
360
- function te(e) {
361
- const t = ee;
362
- ee = e, xe.emit("change", {
200
+ function W(e) {
201
+ const t = T;
202
+ T = e, Re.emit("change", {
363
203
  prev: t,
364
204
  next: e
365
205
  });
366
206
  }
367
- const Mt = (e) => e, Se = () => {
368
- }, et = 1, tt = 2, nt = 4, ot = 8, Ie = 3, ke = 12;
369
- let pe;
370
- function De() {
371
- return pe === void 0 && (pe = !1, typeof window < "u" && (window.navigator.userAgent.includes("Chrome") || window.navigator.userAgent.includes("Firefox")) && (pe = !0)), pe;
207
+ function Ot(e) {
208
+ T.state !== "active" || !T.previews.some((t) => t.separator === e) || W({
209
+ ...T,
210
+ previews: T.previews.map(
211
+ (t) => t.separator === e ? { ...t } : t
212
+ )
213
+ });
372
214
  }
373
- function It({
215
+ function Gt(e) {
216
+ if (T.state === "inactive")
217
+ return !1;
218
+ const t = T.hitRegions.filter(
219
+ (o) => o.group !== e
220
+ ), n = T.state === "active" && T.previews.some((o) => o.group === e);
221
+ if (t.length === T.hitRegions.length && !n)
222
+ return !1;
223
+ if (t.length === 0)
224
+ W({ cursorFlags: 0, state: "inactive" });
225
+ else if (T.state === "active") {
226
+ const o = new Map(T.initialLayoutMap), r = new Map(T.previewLayoutMap);
227
+ o.delete(e), r.delete(e), W({
228
+ ...T,
229
+ cursorFlags: 0,
230
+ hitRegions: t,
231
+ initialLayoutMap: o,
232
+ previewLayoutMap: r,
233
+ previews: T.previews.filter((s) => s.group !== e)
234
+ });
235
+ } else
236
+ W({ ...T, hitRegions: t });
237
+ return !0;
238
+ }
239
+ const At = (e) => e, we = () => {
240
+ }, rt = 1, it = 2, st = 4, at = 8, Fe = 3, Ne = 12;
241
+ let me;
242
+ function _e() {
243
+ return me === void 0 && (me = !1, typeof window < "u" && (window.navigator.userAgent.includes("Chrome") || window.navigator.userAgent.includes("Firefox")) && (me = !0)), me;
244
+ }
245
+ function Ft({
374
246
  cursorFlags: e,
375
247
  groups: t,
376
248
  state: n
377
249
  }) {
378
- let o = 0, i = 0;
250
+ let o = 0, r = 0;
379
251
  switch (n) {
380
252
  case "active":
381
253
  case "hover":
@@ -387,53 +259,53 @@ function It({
387
259
  break;
388
260
  }
389
261
  case "vertical": {
390
- i++;
262
+ r++;
391
263
  break;
392
264
  }
393
265
  }
394
266
  });
395
267
  }
396
- if (!(o === 0 && i === 0)) {
268
+ if (!(o === 0 && r === 0)) {
397
269
  switch (n) {
398
270
  case "active": {
399
- if (e && De()) {
400
- const s = (e & et) !== 0, u = (e & tt) !== 0, a = (e & nt) !== 0, r = (e & ot) !== 0;
271
+ if (e && _e()) {
272
+ const s = (e & rt) !== 0, i = (e & it) !== 0, u = (e & st) !== 0, c = (e & at) !== 0;
401
273
  if (s)
402
- return a ? "se-resize" : r ? "ne-resize" : "e-resize";
274
+ return u ? "se-resize" : c ? "ne-resize" : "e-resize";
275
+ if (i)
276
+ return u ? "sw-resize" : c ? "nw-resize" : "w-resize";
403
277
  if (u)
404
- return a ? "sw-resize" : r ? "nw-resize" : "w-resize";
405
- if (a)
406
278
  return "s-resize";
407
- if (r)
279
+ if (c)
408
280
  return "n-resize";
409
281
  }
410
282
  break;
411
283
  }
412
284
  }
413
- return De() ? o > 0 && i > 0 ? "move" : o > 0 ? "ew-resize" : "ns-resize" : o > 0 && i > 0 ? "grab" : o > 0 ? "col-resize" : "row-resize";
285
+ return _e() ? o > 0 && r > 0 ? "move" : o > 0 ? "ew-resize" : "ns-resize" : o > 0 && r > 0 ? "grab" : o > 0 ? "col-resize" : "row-resize";
414
286
  }
415
287
  }
416
- const Te = /* @__PURE__ */ new WeakMap();
417
- function Pe(e) {
288
+ const $e = /* @__PURE__ */ new WeakMap();
289
+ function fe(e) {
418
290
  if (!e.defaultView || !e.adoptedStyleSheets)
419
291
  return;
420
- let { prevStyle: t, styleSheet: n } = Te.get(e) ?? {};
292
+ let { prevStyle: t, styleSheet: n } = $e.get(e) ?? {};
421
293
  n === void 0 && (n = new e.defaultView.CSSStyleSheet(), e.adoptedStyleSheets && (Object.isExtensible(e.adoptedStyleSheets) ? e.adoptedStyleSheets.push(n) : e.adoptedStyleSheets = [
422
294
  ...e.adoptedStyleSheets,
423
295
  n
424
296
  ]));
425
- const o = W();
297
+ const o = X();
426
298
  switch (o.state) {
427
299
  case "active":
428
300
  case "hover": {
429
- const i = It({
301
+ const r = Ft({
430
302
  cursorFlags: o.cursorFlags,
431
- groups: o.hitRegions.map((u) => u.group),
303
+ groups: o.hitRegions.map((i) => i.group),
432
304
  state: o.state
433
- }), s = `*, *:hover {cursor: ${i} !important; }`;
305
+ }), s = `*, *:hover {cursor: ${r} !important; }`;
434
306
  if (t === s)
435
307
  return;
436
- t = s, i ? n.cssRules.length === 0 ? n.insertRule(s) : n.replaceSync(s) : n.cssRules.length === 1 && n.deleteRule(0);
308
+ t = s, r ? n.cssRules.length === 0 ? n.insertRule(s) : n.replaceSync(s) : n.cssRules.length === 1 && n.deleteRule(0);
437
309
  break;
438
310
  }
439
311
  case "inactive": {
@@ -441,600 +313,859 @@ function Pe(e) {
441
313
  break;
442
314
  }
443
315
  }
444
- Te.set(e, {
316
+ $e.set(e, {
445
317
  prevStyle: t,
446
318
  styleSheet: n
447
319
  });
448
320
  }
449
- let F = /* @__PURE__ */ new Map();
450
- const it = new Qe();
451
- function kt(e) {
452
- F = new Map(F), F.delete(e);
321
+ function L(e, t = "Assertion error") {
322
+ if (!e)
323
+ throw Error(t);
324
+ }
325
+ function Ce(e, t) {
326
+ return Array.from(t).sort(
327
+ e === "horizontal" ? Nt : _t
328
+ );
329
+ }
330
+ function Nt(e, t) {
331
+ const n = e.element.offsetLeft - t.element.offsetLeft;
332
+ return n !== 0 ? n : e.element.offsetWidth - t.element.offsetWidth;
333
+ }
334
+ function _t(e, t) {
335
+ const n = e.element.offsetTop - t.element.offsetTop;
336
+ return n !== 0 ? n : e.element.offsetHeight - t.element.offsetHeight;
337
+ }
338
+ function lt(e) {
339
+ return e !== null && typeof e == "object" && "nodeType" in e && e.nodeType === Node.ELEMENT_NODE;
340
+ }
341
+ function ct(e, t) {
342
+ return {
343
+ x: e.x >= t.left && e.x <= t.right ? 0 : Math.min(
344
+ Math.abs(e.x - t.left),
345
+ Math.abs(e.x - t.right)
346
+ ),
347
+ y: e.y >= t.top && e.y <= t.bottom ? 0 : Math.min(
348
+ Math.abs(e.y - t.top),
349
+ Math.abs(e.y - t.bottom)
350
+ )
351
+ };
352
+ }
353
+ function $t({
354
+ orientation: e,
355
+ rects: t,
356
+ targetRect: n
357
+ }) {
358
+ const o = {
359
+ x: n.x + n.width / 2,
360
+ y: n.y + n.height / 2
361
+ };
362
+ let r, s = Number.MAX_VALUE;
363
+ for (const i of t) {
364
+ const { x: u, y: c } = ct(o, i), a = e === "horizontal" ? u : c;
365
+ a < s && (s = a, r = i);
366
+ }
367
+ return L(r, "No rect found"), r;
368
+ }
369
+ let ge;
370
+ function Ht() {
371
+ return ge === void 0 && (typeof matchMedia == "function" ? ge = !!matchMedia("(pointer:coarse)").matches : ge = !1), ge;
372
+ }
373
+ function Me({
374
+ expandHitTargets: e = !0,
375
+ group: t,
376
+ includeDisabled: n = !1
377
+ }) {
378
+ const { element: o, orientation: r, panels: s, separators: i } = t, u = Ce(
379
+ r,
380
+ Array.from(o.children).filter(lt).filter((m) => !m.hasAttribute("data-resize-preview")).map((m) => ({ element: m }))
381
+ ).map(({ element: m }) => m), c = [];
382
+ let a = !1, l = !1, f = -1, y, d = -1, p = 0, h, v = [];
383
+ {
384
+ let m = -1;
385
+ for (const g of u)
386
+ g.hasAttribute("data-panel") && (m++, g.hasAttribute("data-disabled") || (p++, f === -1 && (f = m), d = m));
387
+ }
388
+ if (n || p > 1) {
389
+ let m = -1;
390
+ for (const g of u)
391
+ if (g.hasAttribute("data-panel")) {
392
+ m++;
393
+ const x = s.find(
394
+ (b) => b.element === g
395
+ );
396
+ if (x) {
397
+ if (h) {
398
+ const b = h.element.getBoundingClientRect(), z = g.getBoundingClientRect();
399
+ let E;
400
+ if (l) {
401
+ const R = r === "horizontal" ? new DOMRect(
402
+ b.right,
403
+ b.top,
404
+ 0,
405
+ b.height
406
+ ) : new DOMRect(
407
+ b.left,
408
+ b.bottom,
409
+ b.width,
410
+ 0
411
+ ), w = r === "horizontal" ? new DOMRect(z.left, z.top, 0, z.height) : new DOMRect(z.left, z.top, z.width, 0);
412
+ switch (v.length) {
413
+ case 0: {
414
+ E = [
415
+ R,
416
+ w
417
+ ];
418
+ break;
419
+ }
420
+ case 1: {
421
+ const C = v[0], F = $t({
422
+ orientation: r,
423
+ rects: [b, z],
424
+ targetRect: C.element.getBoundingClientRect()
425
+ });
426
+ E = [
427
+ C,
428
+ F === b ? w : R
429
+ ];
430
+ break;
431
+ }
432
+ default: {
433
+ E = v;
434
+ break;
435
+ }
436
+ }
437
+ } else
438
+ v.length ? E = v : E = [
439
+ r === "horizontal" ? new DOMRect(
440
+ b.right,
441
+ z.top,
442
+ z.left - b.right,
443
+ z.height
444
+ ) : new DOMRect(
445
+ z.left,
446
+ b.bottom,
447
+ z.width,
448
+ z.top - b.bottom
449
+ )
450
+ ];
451
+ for (const R of E) {
452
+ let w = "width" in R ? R : R.element.getBoundingClientRect();
453
+ const C = e ? Ht() ? t.resizeTargetMinimumSize.coarse : t.resizeTargetMinimumSize.fine : 0;
454
+ if (w.width < C) {
455
+ const I = C - w.width;
456
+ w = new DOMRect(
457
+ w.x - I / 2,
458
+ w.y,
459
+ w.width + I,
460
+ w.height
461
+ );
462
+ }
463
+ if (w.height < C) {
464
+ const I = C - w.height;
465
+ w = new DOMRect(
466
+ w.x,
467
+ w.y - I / 2,
468
+ w.width,
469
+ w.height + I
470
+ );
471
+ }
472
+ const F = m <= f || m > d;
473
+ (n || !a && !F) && (y ??= ae({ group: t }), c.push({
474
+ group: t,
475
+ groupSize: y,
476
+ panels: [h, x],
477
+ separator: "width" in R ? void 0 : R,
478
+ rect: w
479
+ })), a = !1;
480
+ }
481
+ }
482
+ l = !1, h = x, v = [];
483
+ }
484
+ } else if (g.hasAttribute("data-separator")) {
485
+ g.ariaDisabled !== null && (a = !0);
486
+ const x = i.find(
487
+ (b) => b.element === g
488
+ );
489
+ x ? v.push(x) : (h = void 0, v = []);
490
+ } else
491
+ l = !0;
492
+ }
493
+ return c;
453
494
  }
454
- function Oe(e, t) {
455
- for (const [n] of F)
495
+ let B = /* @__PURE__ */ new Map();
496
+ const ut = new nt();
497
+ function Vt(e) {
498
+ B = new Map(B), B.delete(e);
499
+ }
500
+ function ft(e, t) {
501
+ for (const [n] of B)
456
502
  if (n.id === e)
457
503
  return n;
458
504
  }
459
- function H(e, t) {
460
- for (const [n, o] of F)
505
+ function Q(e, t) {
506
+ for (const [n, o] of B)
461
507
  if (n.id === e)
462
508
  return o;
463
509
  if (t)
464
510
  throw Error(`Could not find data for Group with id ${e}`);
465
511
  }
466
- function V() {
467
- return F;
512
+ function ee() {
513
+ return B;
468
514
  }
469
- function we(e, t) {
470
- return it.addListener("groupChange", (n) => {
515
+ function Ee(e, t) {
516
+ return ut.addListener("groupChange", (n) => {
471
517
  n.group.id === e && t(n);
472
518
  });
473
519
  }
474
- function j(e, t, n) {
475
- const o = F.get(e);
476
- F = new Map(F), F.set(e, t), it.emit("groupChange", {
520
+ function q(e, t, n) {
521
+ const o = B.get(e);
522
+ B = new Map(B), B.set(e, t), ut.emit("groupChange", {
477
523
  group: e,
478
524
  isUserInteraction: n?.isUserInteraction === !0,
479
525
  prev: o,
480
526
  next: t
481
527
  });
482
528
  }
483
- function rt(e) {
484
- const t = W(), n = V();
485
- let o = !1;
486
- switch (t.state) {
529
+ function jt(e, t) {
530
+ if (e.length !== t.length)
531
+ return !1;
532
+ for (let n = 0; n < e.length; n++)
533
+ if (e[n] != t[n])
534
+ return !1;
535
+ return !0;
536
+ }
537
+ function D(e, t, n = 0) {
538
+ return Math.abs(A(e) - A(t)) <= n;
539
+ }
540
+ function j(e, t) {
541
+ return D(e, t) ? 0 : e > t ? 1 : -1;
542
+ }
543
+ function se({
544
+ overrideDisabledPanels: e,
545
+ panelConstraints: t,
546
+ prevSize: n,
547
+ size: o
548
+ }) {
549
+ const {
550
+ collapsedSize: r = 0,
551
+ collapsedThreshold: s,
552
+ collapsible: i,
553
+ disabled: u,
554
+ maxSize: c = 100,
555
+ minSize: a = 0
556
+ } = t;
557
+ if (u && !e)
558
+ return n;
559
+ if (j(o, a) < 0)
560
+ if (i) {
561
+ const l = s ?? (a - r) / 2, f = j(n, r) <= 0, y = f ? r + l : a - l, d = j(o, y);
562
+ j(o, r) <= 0 || d < 0 || s !== void 0 && f && d === 0 ? o = r : o = a;
563
+ } else
564
+ o = a;
565
+ return o = Math.min(c, o), o = A(o), o;
566
+ }
567
+ function de({
568
+ delta: e,
569
+ initialLayout: t,
570
+ panelConstraints: n,
571
+ pivotIndices: o,
572
+ prevLayout: r,
573
+ trigger: s
574
+ }) {
575
+ if (D(e, 0))
576
+ return t;
577
+ const i = s === "imperative-api", u = n.map(
578
+ ({ panelId: p }) => t[p]
579
+ ), c = n.map(
580
+ ({ panelId: p }) => r[p]
581
+ ), a = [...u], [l, f] = o;
582
+ L(l != null, "Invalid first pivot index"), L(f != null, "Invalid second pivot index");
583
+ let y = 0;
584
+ switch (s) {
585
+ case "keyboard": {
586
+ {
587
+ const p = e < 0 ? f : l, h = n[p];
588
+ L(
589
+ h,
590
+ `Panel constraints not found for index ${p}`
591
+ );
592
+ const {
593
+ collapsedSize: v = 0,
594
+ collapsible: m,
595
+ minSize: g = 0
596
+ } = h;
597
+ if (m) {
598
+ const x = u[p];
599
+ if (L(
600
+ x != null,
601
+ `Previous layout not found for panel index ${p}`
602
+ ), D(x, v)) {
603
+ const b = g - x;
604
+ j(b, Math.abs(e)) > 0 && (e = e < 0 ? 0 - b : b);
605
+ }
606
+ }
607
+ }
608
+ {
609
+ const p = e < 0 ? l : f, h = n[p];
610
+ L(
611
+ h,
612
+ `No panel constraints found for index ${p}`
613
+ );
614
+ const {
615
+ collapsedSize: v = 0,
616
+ collapsible: m,
617
+ minSize: g = 0
618
+ } = h;
619
+ if (m) {
620
+ const x = u[p];
621
+ if (L(
622
+ x != null,
623
+ `Previous layout not found for panel index ${p}`
624
+ ), D(x, g)) {
625
+ const b = x - v;
626
+ j(b, Math.abs(e)) > 0 && (e = e < 0 ? 0 - b : b);
627
+ }
628
+ }
629
+ }
630
+ break;
631
+ }
632
+ default: {
633
+ const p = e < 0 ? f : l, h = n[p];
634
+ L(
635
+ h,
636
+ `Panel constraints not found for index ${p}`
637
+ );
638
+ const v = u[p], { collapsedSize: m, collapsedThreshold: g, collapsible: x, minSize: b } = h;
639
+ if (x && j(v, b) < 0) {
640
+ const z = b - m, E = g ?? z / 2, R = v + Math.abs(e);
641
+ if (j(R, b) < 0) {
642
+ const w = j(Math.abs(e), E), C = g === void 0 && e < 0;
643
+ w > 0 || w === 0 && C ? e = e < 0 ? -z : z : e = 0;
644
+ }
645
+ }
646
+ break;
647
+ }
648
+ }
649
+ {
650
+ const p = e < 0 ? 1 : -1;
651
+ let h = e < 0 ? f : l, v = 0;
652
+ for (; ; ) {
653
+ const g = u[h];
654
+ L(
655
+ g != null,
656
+ `Previous layout not found for panel index ${h}`
657
+ );
658
+ const b = se({
659
+ overrideDisabledPanels: i,
660
+ panelConstraints: n[h],
661
+ prevSize: g,
662
+ size: 100
663
+ }) - g;
664
+ if (v += b, h += p, h < 0 || h >= n.length)
665
+ break;
666
+ }
667
+ const m = Math.min(Math.abs(e), Math.abs(v));
668
+ e = e < 0 ? 0 - m : m;
669
+ }
670
+ {
671
+ let h = e < 0 ? l : f;
672
+ for (; h >= 0 && h < n.length; ) {
673
+ const v = Math.abs(e) - Math.abs(y), m = u[h];
674
+ L(
675
+ m != null,
676
+ `Previous layout not found for panel index ${h}`
677
+ );
678
+ const g = m - v, x = se({
679
+ overrideDisabledPanels: i,
680
+ panelConstraints: n[h],
681
+ prevSize: m,
682
+ size: g
683
+ });
684
+ if (!D(m, x) && (y += m - x, a[h] = x, y.toFixed(3).localeCompare(Math.abs(e).toFixed(3), void 0, {
685
+ numeric: !0
686
+ }) >= 0))
687
+ break;
688
+ e < 0 ? h-- : h++;
689
+ }
690
+ }
691
+ if (jt(c, a))
692
+ return r;
693
+ {
694
+ const p = e < 0 ? f : l, h = u[p];
695
+ L(
696
+ h != null,
697
+ `Previous layout not found for panel index ${p}`
698
+ );
699
+ const v = h + y, m = se({
700
+ overrideDisabledPanels: i,
701
+ panelConstraints: n[p],
702
+ prevSize: h,
703
+ size: v
704
+ });
705
+ if (a[p] = m, !D(m, v)) {
706
+ let g = v - m, b = e < 0 ? f : l;
707
+ for (; b >= 0 && b < n.length; ) {
708
+ const z = a[b];
709
+ L(
710
+ z != null,
711
+ `Previous layout not found for panel index ${b}`
712
+ );
713
+ const E = z + g, R = se({
714
+ overrideDisabledPanels: i,
715
+ panelConstraints: n[b],
716
+ prevSize: z,
717
+ size: E
718
+ });
719
+ if (D(z, R) || (g -= R - z, a[b] = R), D(g, 0))
720
+ break;
721
+ e > 0 ? b-- : b++;
722
+ }
723
+ }
724
+ }
725
+ const d = Object.values(a).reduce(
726
+ (p, h) => h + p,
727
+ 0
728
+ );
729
+ return D(d, 100, 0.1) ? a.reduce((p, h, v) => (p[n[v].panelId] = h, p), {}) : r;
730
+ }
731
+ function K(e, t) {
732
+ if (Object.keys(e).length !== Object.keys(t).length)
733
+ return !1;
734
+ for (const n in e)
735
+ if (t[n] === void 0 || j(e[n], t[n]) !== 0)
736
+ return !1;
737
+ return !0;
738
+ }
739
+ function Ie({
740
+ commit: e,
741
+ document: t,
742
+ event: n,
743
+ hitRegions: o,
744
+ initialLayoutMap: r,
745
+ mountedGroups: s,
746
+ pointerDownAtPoint: i,
747
+ prevCursorFlags: u
748
+ }) {
749
+ let c = 0;
750
+ const a = X();
751
+ let l = a.state === "active" ? a.previews : [];
752
+ const f = new Map(
753
+ a.state === "active" ? a.previewLayoutMap : void 0
754
+ );
755
+ o.forEach((d) => {
756
+ const { group: p, groupSize: h } = d, { orientation: v, panels: m } = p;
757
+ if (e && p.resizePreviewMode !== "separator")
758
+ return;
759
+ const { disableCursor: g } = p.mutableState;
760
+ let x = 0;
761
+ i ? v === "horizontal" ? x = (n.clientX - i.x) / h * 100 : x = (n.clientY - i.y) / h * 100 : v === "horizontal" ? x = n.clientX < 0 ? -100 : 100 : x = n.clientY < 0 ? -100 : 100;
762
+ const b = r.get(p), z = s.get(p);
763
+ if (!b || !z)
764
+ return;
765
+ const {
766
+ defaultLayoutDeferred: E,
767
+ derivedPanelConstraints: R,
768
+ groupSize: w,
769
+ layout: C,
770
+ separatorToPanels: F
771
+ } = z;
772
+ if (R && C && F) {
773
+ const I = p.resizePreviewMode === "separator" ? f.get(p) ?? C : C, M = de({
774
+ delta: x,
775
+ initialLayout: b,
776
+ panelConstraints: R,
777
+ pivotIndices: d.panels.map((N) => m.indexOf(N)),
778
+ prevLayout: I,
779
+ trigger: "mouse-or-touch"
780
+ });
781
+ if (p.resizePreviewMode === "separator" && !e && !K(M, I)) {
782
+ f.set(p, M);
783
+ let N = 0;
784
+ const _ = m.map((S) => (N += M[S.id] - b[S.id], N * (h / 100)));
785
+ l = l.map((S) => {
786
+ if (S.group !== p)
787
+ return S;
788
+ const P = _[S.panelIndex];
789
+ return P === S.offset ? S : { ...S, offset: P };
790
+ });
791
+ }
792
+ if (K(M, I) && x !== 0 && !g)
793
+ switch (v) {
794
+ case "horizontal": {
795
+ c |= x < 0 ? rt : it;
796
+ break;
797
+ }
798
+ case "vertical": {
799
+ c |= x < 0 ? st : at;
800
+ break;
801
+ }
802
+ }
803
+ (p.resizePreviewMode !== "separator" || e) && !K(M, C) && q(d.group, {
804
+ defaultLayoutDeferred: E,
805
+ derivedPanelConstraints: R,
806
+ groupSize: w,
807
+ layout: M,
808
+ separatorToPanels: F
809
+ });
810
+ }
811
+ });
812
+ let y = 0;
813
+ n.movementX === 0 ? y |= u & Fe : y |= c & Fe, n.movementY === 0 ? y |= u & Ne : y |= c & Ne, Dt(y, l, f), fe(t);
814
+ }
815
+ function dt(e, t) {
816
+ const n = X(), o = ee();
817
+ let r = !1;
818
+ switch (n.state) {
487
819
  case "active":
488
- te({
820
+ Ie({
821
+ commit: !0,
822
+ document: e,
823
+ event: t,
824
+ hitRegions: n.hitRegions,
825
+ initialLayoutMap: n.initialLayoutMap,
826
+ mountedGroups: o,
827
+ pointerDownAtPoint: n.pointerDownAtPoint,
828
+ prevCursorFlags: n.cursorFlags
829
+ }), W({
489
830
  cursorFlags: 0,
490
831
  state: "inactive"
491
- }), t.hitRegions.length > 0 && (Pe(e), o = !0, t.hitRegions.forEach((i) => {
492
- if (!n.has(i.group))
832
+ }), n.hitRegions.length > 0 && (fe(e), r = !0, n.hitRegions.forEach((s) => {
833
+ if (!o.has(s.group))
493
834
  return;
494
- const s = H(i.group.id, !0);
495
- j(i.group, s, {
835
+ const i = Q(s.group.id, !0);
836
+ q(s.group, i, {
496
837
  isUserInteraction: !0
497
838
  });
498
839
  }));
499
840
  }
500
- return o;
841
+ return r;
501
842
  }
502
- function Ge(e) {
503
- e.defaultPrevented || rt(e.currentTarget);
843
+ function He(e) {
844
+ e.defaultPrevented || dt(e.currentTarget, e);
504
845
  }
505
- function Dt(e, t, n) {
506
- let o, i = {
846
+ function Bt(e, t, n) {
847
+ let o, r = {
507
848
  x: 1 / 0,
508
849
  y: 1 / 0
509
850
  };
510
851
  for (const s of t) {
511
- const u = Je(n, s.rect);
852
+ const i = ct(n, s.rect);
512
853
  switch (e) {
513
854
  case "horizontal": {
514
- u.x <= i.x && (o = s, i = u);
855
+ i.x <= r.x && (o = s, r = i);
515
856
  break;
516
857
  }
517
858
  case "vertical": {
518
- u.y <= i.y && (o = s, i = u);
859
+ i.y <= r.y && (o = s, r = i);
519
860
  break;
520
861
  }
521
862
  }
522
863
  }
523
864
  return o ? {
524
- distance: i,
865
+ distance: r,
525
866
  hitRegion: o
526
867
  } : void 0;
527
868
  }
528
- function Tt(e) {
869
+ function Ut(e) {
529
870
  return e !== null && typeof e == "object" && "nodeType" in e && e.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
530
871
  }
531
- function Ot(e, t) {
872
+ function Wt(e, t) {
532
873
  if (e === t) throw new Error("Cannot compare node with itself");
533
874
  const n = {
534
- a: Ne(e),
535
- b: Ne(t)
875
+ a: Be(e),
876
+ b: Be(t)
536
877
  };
537
878
  let o;
538
879
  for (; n.a.at(-1) === n.b.at(-1); )
539
880
  o = n.a.pop(), n.b.pop();
540
- C(
881
+ L(
541
882
  o,
542
883
  "Stacking order can only be calculated for elements with a common ancestor"
543
884
  );
544
- const i = {
545
- a: Fe(Ae(n.a)),
546
- b: Fe(Ae(n.b))
885
+ const r = {
886
+ a: je(Ve(n.a)),
887
+ b: je(Ve(n.b))
547
888
  };
548
- if (i.a === i.b) {
549
- const s = o.childNodes, u = {
889
+ if (r.a === r.b) {
890
+ const s = o.childNodes, i = {
550
891
  a: n.a.at(-1),
551
892
  b: n.b.at(-1)
552
893
  };
553
- let a = s.length;
554
- for (; a--; ) {
555
- const r = s[a];
556
- if (r === u.a) return 1;
557
- if (r === u.b) return -1;
894
+ let u = s.length;
895
+ for (; u--; ) {
896
+ const c = s[u];
897
+ if (c === i.a) return 1;
898
+ if (c === i.b) return -1;
558
899
  }
559
900
  }
560
- return Math.sign(i.a - i.b);
901
+ return Math.sign(r.a - r.b);
561
902
  }
562
- const Gt = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
563
- function At(e) {
564
- const t = getComputedStyle(st(e) ?? e).display;
903
+ const Kt = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
904
+ function qt(e) {
905
+ const t = getComputedStyle(pt(e) ?? e).display;
565
906
  return t === "flex" || t === "inline-flex";
566
907
  }
567
- function Ft(e) {
908
+ function Xt(e) {
568
909
  const t = getComputedStyle(e);
569
- return !!(t.position === "fixed" || t.zIndex !== "auto" && (t.position !== "static" || At(e)) || +t.opacity < 1 || "transform" in t && t.transform !== "none" || "webkitTransform" in t && t.webkitTransform !== "none" || "mixBlendMode" in t && t.mixBlendMode !== "normal" || "filter" in t && t.filter !== "none" || "webkitFilter" in t && t.webkitFilter !== "none" || "isolation" in t && t.isolation === "isolate" || Gt.test(t.willChange) || t.webkitOverflowScrolling === "touch");
910
+ return !!(t.position === "fixed" || t.zIndex !== "auto" && (t.position !== "static" || qt(e)) || +t.opacity < 1 || "transform" in t && t.transform !== "none" || "webkitTransform" in t && t.webkitTransform !== "none" || "mixBlendMode" in t && t.mixBlendMode !== "normal" || "filter" in t && t.filter !== "none" || "webkitFilter" in t && t.webkitFilter !== "none" || "isolation" in t && t.isolation === "isolate" || Kt.test(t.willChange) || t.webkitOverflowScrolling === "touch");
570
911
  }
571
- function Ae(e) {
912
+ function Ve(e) {
572
913
  let t = e.length;
573
914
  for (; t--; ) {
574
915
  const n = e[t];
575
- if (C(n, "Missing node"), Ft(n)) return n;
916
+ if (L(n, "Missing node"), Xt(n)) return n;
576
917
  }
577
918
  return null;
578
919
  }
579
- function Fe(e) {
920
+ function je(e) {
580
921
  return e && Number(getComputedStyle(e).zIndex) || 0;
581
922
  }
582
- function Ne(e) {
923
+ function Be(e) {
583
924
  const t = [];
584
925
  for (; e; )
585
- t.push(e), e = st(e);
926
+ t.push(e), e = pt(e);
586
927
  return t;
587
928
  }
588
- function st(e) {
929
+ function pt(e) {
589
930
  const { parentNode: t } = e;
590
- return Tt(t) ? t.host : t;
931
+ return Ut(t) ? t.host : t;
591
932
  }
592
- function Nt(e, t) {
933
+ function Yt(e, t) {
593
934
  return e.x < t.x + t.width && e.x + e.width > t.x && e.y < t.y + t.height && e.y + e.height > t.y;
594
935
  }
595
- function _t({
936
+ function Jt({
596
937
  groupElement: e,
597
938
  hitRegion: t,
598
939
  pointerEventTarget: n
599
940
  }) {
600
- if (!Ye(n) || n.contains(e) || e.contains(n))
941
+ if (!lt(n) || n.contains(e) || e.contains(n))
601
942
  return !0;
602
- if (Ot(n, e) > 0) {
943
+ if (Wt(n, e) > 0) {
603
944
  let o = n;
604
945
  for (; o; ) {
605
946
  if (o.contains(e))
606
947
  return !0;
607
- if (Nt(o.getBoundingClientRect(), t))
948
+ if (Yt(o.getBoundingClientRect(), t))
608
949
  return !1;
609
950
  o = o.parentElement;
610
951
  }
611
952
  }
612
953
  return !0;
613
954
  }
614
- function Le(e, t) {
955
+ function ke(e, t) {
615
956
  const n = [];
616
- return t.forEach((o, i) => {
617
- if (i.disabled)
957
+ return t.forEach((o, r) => {
958
+ if (r.disabled)
618
959
  return;
619
- const s = Ze(i), u = Dt(i.orientation, s, {
960
+ const s = Me({ group: r }), i = Bt(r.orientation, s, {
620
961
  x: e.clientX,
621
962
  y: e.clientY
622
963
  });
623
- u && u.distance.x <= 0 && u.distance.y <= 0 && _t({
624
- groupElement: i.element,
625
- hitRegion: u.hitRegion.rect,
964
+ i && i.distance.x <= 0 && i.distance.y <= 0 && Jt({
965
+ groupElement: r.element,
966
+ hitRegion: i.hitRegion.rect,
626
967
  pointerEventTarget: e.target
627
- }) && n.push(u.hitRegion);
968
+ }) && n.push(i.hitRegion);
628
969
  }), n;
629
970
  }
630
- function $t(e, t) {
631
- if (e.length !== t.length)
632
- return !1;
633
- for (let n = 0; n < e.length; n++)
634
- if (e[n] != t[n])
635
- return !1;
636
- return !0;
637
- }
638
- function D(e, t, n = 0) {
639
- return Math.abs(T(e) - T(t)) <= n;
640
- }
641
- function A(e, t) {
642
- return D(e, t) ? 0 : e > t ? 1 : -1;
643
- }
644
- function Z({
645
- overrideDisabledPanels: e,
646
- panelConstraints: t,
647
- prevSize: n,
648
- size: o
649
- }) {
650
- const {
651
- collapsedSize: i = 0,
652
- collapsible: s,
653
- disabled: u,
654
- maxSize: a = 100,
655
- minSize: r = 0
656
- } = t;
657
- if (u && !e)
658
- return n;
659
- if (A(o, r) < 0)
660
- if (s) {
661
- const l = (i + r) / 2;
662
- A(o, l) < 0 ? o = i : o = r;
663
- } else
664
- o = r;
665
- return o = Math.min(a, o), o = T(o), o;
666
- }
667
- function ae({
668
- delta: e,
669
- initialLayout: t,
670
- panelConstraints: n,
671
- pivotIndices: o,
672
- prevLayout: i,
673
- trigger: s
674
- }) {
675
- if (D(e, 0))
676
- return t;
677
- const u = s === "imperative-api", a = Object.values(t), r = Object.values(i), l = [...a], [c, m] = o;
678
- C(c != null, "Invalid first pivot index"), C(m != null, "Invalid second pivot index");
679
- let p = 0;
680
- switch (s) {
681
- case "keyboard": {
682
- {
683
- const f = e < 0 ? m : c, d = n[f];
684
- C(
685
- d,
686
- `Panel constraints not found for index ${f}`
687
- );
688
- const {
689
- collapsedSize: h = 0,
690
- collapsible: y,
691
- minSize: b = 0
692
- } = d;
693
- if (y) {
694
- const v = a[f];
695
- if (C(
696
- v != null,
697
- `Previous layout not found for panel index ${f}`
698
- ), D(v, h)) {
699
- const g = b - v;
700
- A(g, Math.abs(e)) > 0 && (e = e < 0 ? 0 - g : g);
701
- }
702
- }
703
- }
704
- {
705
- const f = e < 0 ? c : m, d = n[f];
706
- C(
707
- d,
708
- `No panel constraints found for index ${f}`
709
- );
710
- const {
711
- collapsedSize: h = 0,
712
- collapsible: y,
713
- minSize: b = 0
714
- } = d;
715
- if (y) {
716
- const v = a[f];
717
- if (C(
718
- v != null,
719
- `Previous layout not found for panel index ${f}`
720
- ), D(v, b)) {
721
- const g = v - h;
722
- A(g, Math.abs(e)) > 0 && (e = e < 0 ? 0 - g : g);
723
- }
724
- }
725
- }
726
- break;
727
- }
728
- default: {
729
- const f = e < 0 ? m : c, d = n[f];
730
- C(
731
- d,
732
- `Panel constraints not found for index ${f}`
733
- );
734
- const h = a[f], { collapsible: y, collapsedSize: b, minSize: v } = d;
735
- if (y && A(h, v) < 0)
736
- if (e > 0) {
737
- const g = v - b, w = g / 2, E = h + e;
738
- A(E, v) < 0 && (e = A(e, w) <= 0 ? 0 : g);
739
- } else {
740
- const g = v - b, w = 100 - g / 2, E = h - e;
741
- A(E, v) < 0 && (e = A(100 + e, w) > 0 ? 0 : -g);
742
- }
743
- break;
744
- }
745
- }
746
- {
747
- const f = e < 0 ? 1 : -1;
748
- let d = e < 0 ? m : c, h = 0;
749
- for (; ; ) {
750
- const b = a[d];
751
- C(
752
- b != null,
753
- `Previous layout not found for panel index ${d}`
754
- );
755
- const g = Z({
756
- overrideDisabledPanels: u,
757
- panelConstraints: n[d],
758
- prevSize: b,
759
- size: 100
760
- }) - b;
761
- if (h += g, d += f, d < 0 || d >= n.length)
762
- break;
763
- }
764
- const y = Math.min(Math.abs(e), Math.abs(h));
765
- e = e < 0 ? 0 - y : y;
766
- }
767
- {
768
- let d = e < 0 ? c : m;
769
- for (; d >= 0 && d < n.length; ) {
770
- const h = Math.abs(e) - Math.abs(p), y = a[d];
771
- C(
772
- y != null,
773
- `Previous layout not found for panel index ${d}`
774
- );
775
- const b = y - h, v = Z({
776
- overrideDisabledPanels: u,
777
- panelConstraints: n[d],
778
- prevSize: y,
779
- size: b
780
- });
781
- if (!D(y, v) && (p += y - v, l[d] = v, p.toFixed(3).localeCompare(Math.abs(e).toFixed(3), void 0, {
782
- numeric: !0
783
- }) >= 0))
784
- break;
785
- e < 0 ? d-- : d++;
786
- }
787
- }
788
- if ($t(r, l))
789
- return i;
790
- {
791
- const f = e < 0 ? m : c, d = a[f];
792
- C(
793
- d != null,
794
- `Previous layout not found for panel index ${f}`
795
- );
796
- const h = d + p, y = Z({
797
- overrideDisabledPanels: u,
798
- panelConstraints: n[f],
799
- prevSize: d,
800
- size: h
801
- });
802
- if (l[f] = y, !D(y, h)) {
803
- let b = h - y, g = e < 0 ? m : c;
804
- for (; g >= 0 && g < n.length; ) {
805
- const w = l[g];
806
- C(
807
- w != null,
808
- `Previous layout not found for panel index ${g}`
809
- );
810
- const E = w + b, L = Z({
811
- overrideDisabledPanels: u,
812
- panelConstraints: n[g],
813
- prevSize: w,
814
- size: E
815
- });
816
- if (D(w, L) || (b -= L - w, l[g] = L), D(b, 0))
817
- break;
818
- e > 0 ? g-- : g++;
819
- }
820
- }
821
- }
822
- const S = Object.values(l).reduce(
823
- (f, d) => d + f,
824
- 0
825
- );
826
- if (!D(S, 100, 0.1))
827
- return i;
828
- const z = Object.keys(i);
829
- return l.reduce((f, d, h) => (f[z[h]] = d, f), {});
830
- }
831
- function K(e, t) {
832
- if (Object.keys(e).length !== Object.keys(t).length)
833
- return !1;
834
- for (const n in e)
835
- if (t[n] === void 0 || A(e[n], t[n]) !== 0)
836
- return !1;
837
- return !0;
838
- }
839
- function X({
971
+ function ne({
840
972
  layout: e,
841
973
  panelConstraints: t
842
974
  }) {
843
- const n = Object.values(e), o = [...n], i = o.reduce(
844
- (a, r) => a + r,
975
+ const n = t.map(({ panelId: i }) => e[i]), o = [...n], r = o.reduce(
976
+ (i, u) => i + u,
845
977
  0
846
978
  );
847
- if (o.length !== t.length)
979
+ if (Object.keys(e).length !== t.length)
848
980
  throw Error(
849
- `Invalid ${t.length} panel layout: ${o.map((a) => `${a}%`).join(", ")}`
981
+ `Invalid ${t.length} panel layout: ${Object.values(e).map((i) => `${i}%`).join(", ")}`
850
982
  );
851
- if (!D(i, 100) && o.length > 0)
852
- for (let a = 0; a < t.length; a++) {
853
- const r = o[a];
854
- C(r != null, `No layout data found for index ${a}`);
855
- const l = 100 / i * r;
856
- o[a] = l;
983
+ if (!D(r, 100) && o.length > 0)
984
+ for (let i = 0; i < t.length; i++) {
985
+ const u = o[i];
986
+ L(u != null, `No layout data found for index ${i}`);
987
+ const c = 100 / r * u;
988
+ o[i] = c;
857
989
  }
858
990
  let s = 0;
859
- for (let a = 0; a < t.length; a++) {
860
- const r = n[a];
861
- C(r != null, `No layout data found for index ${a}`);
862
- const l = o[a];
863
- C(l != null, `No layout data found for index ${a}`);
864
- const c = Z({
991
+ for (let i = 0; i < t.length; i++) {
992
+ const u = n[i];
993
+ L(u != null, `No layout data found for index ${i}`);
994
+ const c = o[i];
995
+ L(c != null, `No layout data found for index ${i}`);
996
+ const a = se({
865
997
  overrideDisabledPanels: !0,
866
- panelConstraints: t[a],
867
- prevSize: r,
868
- size: l
998
+ panelConstraints: t[i],
999
+ prevSize: u,
1000
+ size: c
869
1001
  });
870
- l != c && (s += l - c, o[a] = c);
1002
+ c != a && (s += c - a, o[i] = a);
871
1003
  }
872
1004
  if (!D(s, 0))
873
- for (let a = 0; a < t.length; a++) {
874
- const r = o[a];
875
- C(r != null, `No layout data found for index ${a}`);
876
- const l = r + s, c = Z({
1005
+ for (let i = 0; i < t.length; i++) {
1006
+ const u = o[i];
1007
+ L(u != null, `No layout data found for index ${i}`);
1008
+ const c = u + s, a = se({
877
1009
  overrideDisabledPanels: !0,
878
- panelConstraints: t[a],
879
- prevSize: r,
880
- size: l
1010
+ panelConstraints: t[i],
1011
+ prevSize: u,
1012
+ size: c
881
1013
  });
882
- if (r !== c && (s -= c - r, o[a] = c, D(s, 0)))
1014
+ if (u !== a && (s -= a - u, o[i] = a, D(s, 0)))
883
1015
  break;
884
1016
  }
885
- const u = Object.keys(e);
886
- return o.reduce((a, r, l) => (a[u[l]] = r, a), {});
1017
+ return o.reduce((i, u, c) => (i[t[c].panelId] = u, i), {});
887
1018
  }
888
- function at({
1019
+ function ht({
889
1020
  groupId: e,
890
1021
  panelId: t
891
1022
  }) {
892
1023
  const n = () => {
893
- const r = V();
1024
+ const c = ee();
894
1025
  for (const [
895
- l,
1026
+ a,
896
1027
  {
897
- defaultLayoutDeferred: c,
898
- derivedPanelConstraints: m,
899
- layout: p,
900
- groupSize: S,
901
- separatorToPanels: z
1028
+ defaultLayoutDeferred: l,
1029
+ derivedPanelConstraints: f,
1030
+ layout: y,
1031
+ groupSize: d,
1032
+ separatorToPanels: p
902
1033
  }
903
- ] of r)
904
- if (l.id === e)
1034
+ ] of c)
1035
+ if (a.id === e)
905
1036
  return {
906
- defaultLayoutDeferred: c,
907
- derivedPanelConstraints: m,
908
- group: l,
909
- groupSize: S,
910
- layout: p,
911
- separatorToPanels: z
1037
+ defaultLayoutDeferred: l,
1038
+ derivedPanelConstraints: f,
1039
+ group: a,
1040
+ groupSize: d,
1041
+ layout: y,
1042
+ separatorToPanels: p
912
1043
  };
913
1044
  throw Error(`Group ${e} not found`);
914
1045
  }, o = () => {
915
- const r = n().derivedPanelConstraints.find(
916
- (l) => l.panelId === t
1046
+ const c = n().derivedPanelConstraints.find(
1047
+ (a) => a.panelId === t
917
1048
  );
918
- if (r !== void 0)
919
- return r;
1049
+ if (c !== void 0)
1050
+ return c;
920
1051
  throw Error(`Panel constraints not found for Panel ${t}`);
921
- }, i = () => {
922
- const r = n().group.panels.find((l) => l.id === t);
923
- if (r !== void 0)
924
- return r;
1052
+ }, r = () => {
1053
+ const c = n().group.panels.find((a) => a.id === t);
1054
+ if (c !== void 0)
1055
+ return c;
925
1056
  throw Error(`Layout not found for Panel ${t}`);
926
1057
  }, s = () => {
927
- const r = n().layout[t];
928
- if (r !== void 0)
929
- return r;
1058
+ const c = n().layout[t];
1059
+ if (c !== void 0)
1060
+ return c;
930
1061
  throw Error(`Layout not found for Panel ${t}`);
931
- }, u = ({
932
- nextSize: r,
933
- panels: l,
934
- prevLayout: c,
935
- derivedPanelConstraints: m
1062
+ }, i = ({
1063
+ nextSize: c,
1064
+ panels: a,
1065
+ prevLayout: l,
1066
+ derivedPanelConstraints: f
936
1067
  }) => {
937
- const p = s(), S = l.findIndex((h) => h.id === t), z = S === 0, f = S === l.length - 1;
938
- if (f && r < p && (z || l.slice(0, S).every((h, y) => {
939
- const b = m[y];
940
- return b?.collapsible && D(b.collapsedSize, c[b.panelId]);
1068
+ const y = s(), d = a.findIndex((m) => m.id === t), p = d === 0, h = d === a.length - 1;
1069
+ if (h && c < y && (p || a.slice(0, d).every((m, g) => {
1070
+ const x = f[g];
1071
+ return x?.collapsible && D(x.collapsedSize, l[x.panelId]);
941
1072
  }))) {
942
- const h = l.slice(0, S).reduce((y, b) => y + c[b.id], 0);
1073
+ const m = a.slice(0, d).reduce((g, x) => g + l[x.id], 0);
943
1074
  return {
944
- ...c,
945
- [t]: T(100 - h)
1075
+ ...l,
1076
+ [t]: A(100 - m)
946
1077
  };
947
1078
  }
948
- return ae({
949
- delta: f ? p - r : r - p,
950
- initialLayout: c,
951
- panelConstraints: m,
952
- pivotIndices: f ? [S - 1, S] : [S, S + 1],
953
- prevLayout: c,
1079
+ return de({
1080
+ delta: h ? y - c : c - y,
1081
+ initialLayout: l,
1082
+ panelConstraints: f,
1083
+ pivotIndices: h ? [d - 1, d] : [d, d + 1],
1084
+ prevLayout: l,
954
1085
  trigger: "imperative-api"
955
1086
  });
956
- }, a = (r) => {
957
- const l = s();
958
- if (r === l)
1087
+ }, u = (c) => {
1088
+ const a = s();
1089
+ if (c === a)
959
1090
  return;
960
1091
  const {
961
- defaultLayoutDeferred: c,
962
- derivedPanelConstraints: m,
963
- group: p,
964
- groupSize: S,
965
- layout: z,
966
- separatorToPanels: f
967
- } = n(), d = u({
968
- nextSize: r,
969
- panels: p.panels,
970
- prevLayout: z,
971
- derivedPanelConstraints: m
972
- }), h = X({
973
- layout: d,
974
- panelConstraints: m
1092
+ defaultLayoutDeferred: l,
1093
+ derivedPanelConstraints: f,
1094
+ group: y,
1095
+ groupSize: d,
1096
+ layout: p,
1097
+ separatorToPanels: h
1098
+ } = n(), v = i({
1099
+ nextSize: c,
1100
+ panels: y.panels,
1101
+ prevLayout: p,
1102
+ derivedPanelConstraints: f
1103
+ }), m = ne({
1104
+ layout: v,
1105
+ panelConstraints: f
975
1106
  });
976
- K(z, h) || j(p, {
977
- defaultLayoutDeferred: c,
978
- derivedPanelConstraints: m,
979
- groupSize: S,
980
- layout: h,
981
- separatorToPanels: f
1107
+ K(p, m) || q(y, {
1108
+ defaultLayoutDeferred: l,
1109
+ derivedPanelConstraints: f,
1110
+ groupSize: d,
1111
+ layout: m,
1112
+ separatorToPanels: h
982
1113
  });
983
1114
  };
984
1115
  return {
985
1116
  collapse: () => {
986
- const { collapsible: r, collapsedSize: l } = o(), { mutableValues: c } = i(), m = s();
987
- r && m !== l && (c.expandToSize = m, a(l));
1117
+ const { collapsible: c, collapsedSize: a } = o(), { mutableValues: l } = r(), f = s();
1118
+ c && f !== a && (l.expandToSize = f, u(a));
988
1119
  },
989
1120
  expand: () => {
990
- const { collapsible: r, collapsedSize: l, minSize: c } = o(), { mutableValues: m } = i(), p = s();
991
- if (r && p === l) {
992
- let S = m.expandToSize ?? c;
993
- S === 0 && (S = 1), a(S);
1121
+ const { collapsible: c, collapsedSize: a, minSize: l } = o(), { mutableValues: f } = r(), y = s();
1122
+ if (c && y === a) {
1123
+ let d = f.expandToSize ?? l;
1124
+ d === 0 && (d = 1), u(d);
994
1125
  }
995
1126
  },
996
1127
  getSize: () => {
997
- const { group: r } = n(), l = s(), { element: c } = i(), m = r.orientation === "horizontal" ? c.offsetWidth : c.offsetHeight;
1128
+ const { group: c } = n(), a = s(), { element: l } = r(), f = c.orientation === "horizontal" ? l.offsetWidth : l.offsetHeight;
998
1129
  return {
999
- asPercentage: l,
1000
- inPixels: m
1130
+ asPercentage: a,
1131
+ inPixels: f
1001
1132
  };
1002
1133
  },
1003
1134
  isCollapsed: () => {
1004
- const { collapsible: r, collapsedSize: l } = o(), c = s();
1005
- return r && D(l, c);
1135
+ const { collapsible: c, collapsedSize: a } = o(), l = s();
1136
+ return c && D(a, l);
1006
1137
  },
1007
- resize: (r) => {
1008
- const { group: l } = n(), { element: c } = i(), m = ne({ group: l }), p = oe({
1009
- groupSize: m,
1010
- panelElement: c,
1011
- styleProp: r
1012
- }), S = T(p / m * 100);
1013
- a(S);
1138
+ resize: (c) => {
1139
+ const { group: a } = n(), { element: l } = r(), f = ae({ group: a }), y = ie({
1140
+ groupSize: f,
1141
+ panelElement: l,
1142
+ styleProp: c
1143
+ }), d = A(y / f * 100);
1144
+ u(d);
1014
1145
  }
1015
1146
  };
1016
1147
  }
1017
- function _e(e) {
1148
+ function Ue(e) {
1018
1149
  if (e.defaultPrevented)
1019
1150
  return;
1020
- const t = V();
1021
- Le(e, t).forEach((o) => {
1151
+ const t = ee();
1152
+ ke(e, t).forEach((o) => {
1022
1153
  if (o.separator && !o.separator.disableDoubleClick) {
1023
- const i = o.panels.find(
1154
+ const r = o.panels.find(
1024
1155
  (s) => s.panelConstraints.defaultSize !== void 0
1025
1156
  );
1026
- if (i) {
1027
- const s = i.panelConstraints.defaultSize, u = at({
1157
+ if (r) {
1158
+ const s = r.panelConstraints.defaultSize, i = ht({
1028
1159
  groupId: o.group.id,
1029
- panelId: i.id
1160
+ panelId: r.id
1030
1161
  });
1031
- u && s !== void 0 && (u.resize(s), e.preventDefault());
1162
+ i && s !== void 0 && (i.resize(s), e.preventDefault());
1032
1163
  }
1033
1164
  }
1034
1165
  });
1035
1166
  }
1036
- function he(e) {
1037
- const t = V();
1167
+ function ye(e) {
1168
+ const t = ee();
1038
1169
  for (const [n] of t)
1039
1170
  if (n.separators.some(
1040
1171
  (o) => o.element === e
@@ -1042,14 +1173,14 @@ function he(e) {
1042
1173
  return n;
1043
1174
  throw Error("Could not find parent Group for separator element");
1044
1175
  }
1045
- function lt({
1176
+ function mt({
1046
1177
  groupId: e
1047
1178
  }) {
1048
1179
  const t = () => {
1049
- const n = V();
1050
- for (const [o, i] of n)
1180
+ const n = ee();
1181
+ for (const [o, r] of n)
1051
1182
  if (o.id === e)
1052
- return { group: o, ...i };
1183
+ return { group: o, ...r };
1053
1184
  throw Error(`Could not find Group with id "${e}"`);
1054
1185
  };
1055
1186
  return {
@@ -1060,50 +1191,50 @@ function lt({
1060
1191
  setLayout(n) {
1061
1192
  const {
1062
1193
  defaultLayoutDeferred: o,
1063
- derivedPanelConstraints: i,
1194
+ derivedPanelConstraints: r,
1064
1195
  group: s,
1065
- groupSize: u,
1066
- layout: a,
1067
- separatorToPanels: r
1068
- } = t(), l = X({
1196
+ groupSize: i,
1197
+ layout: u,
1198
+ separatorToPanels: c
1199
+ } = t(), a = ne({
1069
1200
  layout: n,
1070
- panelConstraints: i
1201
+ panelConstraints: r
1071
1202
  });
1072
- return o ? a : (K(a, l) || j(s, {
1203
+ return o ? u : (K(u, a) || q(s, {
1073
1204
  defaultLayoutDeferred: o,
1074
- derivedPanelConstraints: i,
1075
- groupSize: u,
1076
- layout: l,
1077
- separatorToPanels: r
1078
- }), l);
1205
+ derivedPanelConstraints: r,
1206
+ groupSize: i,
1207
+ layout: a,
1208
+ separatorToPanels: c
1209
+ }), a);
1079
1210
  }
1080
1211
  };
1081
1212
  }
1082
- function B(e, t) {
1083
- const n = he(e), o = H(n.id, !0), i = n.separators.find(
1084
- (m) => m.element === e
1213
+ function te(e, t) {
1214
+ const n = ye(e), o = Q(n.id, !0), r = n.separators.find(
1215
+ (f) => f.element === e
1085
1216
  );
1086
- C(i, "Matching separator not found");
1087
- const s = o.separatorToPanels.get(i);
1088
- C(s, "Matching panels not found");
1089
- const u = s.map((m) => n.panels.indexOf(m)), r = lt({ groupId: n.id }).getLayout(), l = ae({
1217
+ L(r, "Matching separator not found");
1218
+ const s = o.separatorToPanels.get(r);
1219
+ L(s, "Matching panels not found");
1220
+ const i = s.map((f) => n.panels.indexOf(f)), c = mt({ groupId: n.id }).getLayout(), a = de({
1090
1221
  delta: t,
1091
- initialLayout: r,
1222
+ initialLayout: c,
1092
1223
  panelConstraints: o.derivedPanelConstraints,
1093
- pivotIndices: u,
1094
- prevLayout: r,
1224
+ pivotIndices: i,
1225
+ prevLayout: c,
1095
1226
  trigger: "keyboard"
1096
- }), c = X({
1097
- layout: l,
1227
+ }), l = ne({
1228
+ layout: a,
1098
1229
  panelConstraints: o.derivedPanelConstraints
1099
1230
  });
1100
- K(r, c) || j(
1231
+ K(c, l) || q(
1101
1232
  n,
1102
1233
  {
1103
1234
  defaultLayoutDeferred: o.defaultLayoutDeferred,
1104
1235
  derivedPanelConstraints: o.derivedPanelConstraints,
1105
1236
  groupSize: o.groupSize,
1106
- layout: c,
1237
+ layout: l,
1107
1238
  separatorToPanels: o.separatorToPanels
1108
1239
  },
1109
1240
  // Keyboard resizes (arrow keys, Home/End, Enter collapse/expand) originate
@@ -1113,155 +1244,142 @@ function B(e, t) {
1113
1244
  { isUserInteraction: !0 }
1114
1245
  );
1115
1246
  }
1116
- function $e(e) {
1247
+ function We(e) {
1117
1248
  if (e.defaultPrevented)
1118
1249
  return;
1119
- const t = e.currentTarget, n = he(t);
1120
- if (!n.disabled)
1250
+ const t = e.currentTarget, n = ye(t);
1251
+ if (!(n.disabled || n.separators.find(
1252
+ (r) => r.element === t
1253
+ )?.disabled))
1121
1254
  switch (e.key) {
1122
1255
  case "ArrowDown": {
1123
- e.preventDefault(), n.orientation === "vertical" && B(t, 5);
1256
+ e.preventDefault(), n.orientation === "vertical" && te(t, 5);
1124
1257
  break;
1125
1258
  }
1126
1259
  case "ArrowLeft": {
1127
- e.preventDefault(), n.orientation === "horizontal" && B(t, -5);
1260
+ e.preventDefault(), n.orientation === "horizontal" && te(t, -5);
1128
1261
  break;
1129
1262
  }
1130
1263
  case "ArrowRight": {
1131
- e.preventDefault(), n.orientation === "horizontal" && B(t, 5);
1264
+ e.preventDefault(), n.orientation === "horizontal" && te(t, 5);
1132
1265
  break;
1133
1266
  }
1134
1267
  case "ArrowUp": {
1135
- e.preventDefault(), n.orientation === "vertical" && B(t, -5);
1268
+ e.preventDefault(), n.orientation === "vertical" && te(t, -5);
1136
1269
  break;
1137
1270
  }
1138
1271
  case "End": {
1139
- e.preventDefault(), B(t, 100);
1272
+ e.preventDefault(), te(t, 100);
1140
1273
  break;
1141
1274
  }
1142
1275
  case "Enter": {
1143
1276
  e.preventDefault();
1144
- const o = he(t), i = H(o.id, !0), { derivedPanelConstraints: s, layout: u, separatorToPanels: a } = i, r = o.separators.find(
1145
- (p) => p.element === t
1277
+ const r = ye(t), s = Q(r.id, !0), { derivedPanelConstraints: i, layout: u, separatorToPanels: c } = s, a = r.separators.find(
1278
+ (d) => d.element === t
1146
1279
  );
1147
- C(r, "Matching separator not found");
1148
- const l = a.get(r);
1149
- C(l, "Matching panels not found");
1150
- const c = l[0], m = s.find(
1151
- (p) => p.panelId === c.id
1280
+ L(a, "Matching separator not found");
1281
+ const l = c.get(a);
1282
+ L(l, "Matching panels not found");
1283
+ const f = l[0], y = i.find(
1284
+ (d) => d.panelId === f.id
1152
1285
  );
1153
- if (C(m, "Panel metadata not found"), m.collapsible) {
1154
- const p = u[c.id], S = m.collapsedSize === p ? o.mutableState.expandedPanelSizes[c.id] ?? m.minSize : m.collapsedSize;
1155
- B(t, S - p);
1286
+ if (L(y, "Panel metadata not found"), y.collapsible) {
1287
+ const d = u[f.id], p = y.collapsedSize === d ? r.mutableState.expandedPanelSizes[f.id] ?? y.minSize : y.collapsedSize;
1288
+ te(t, p - d);
1156
1289
  }
1157
1290
  break;
1158
1291
  }
1159
1292
  case "F6": {
1160
1293
  e.preventDefault();
1161
- const i = he(t).separators.map(
1162
- (r) => r.element
1163
- ), s = Array.from(i).findIndex(
1164
- (r) => r === e.currentTarget
1294
+ const s = ye(t).separators.map(
1295
+ (a) => a.element
1296
+ ), i = Array.from(s).findIndex(
1297
+ (a) => a === e.currentTarget
1165
1298
  );
1166
- C(s !== null, "Index not found");
1167
- const u = e.shiftKey ? s > 0 ? s - 1 : i.length - 1 : s + 1 < i.length ? s + 1 : 0;
1168
- i[u].focus({
1299
+ L(i !== null, "Index not found");
1300
+ const u = e.shiftKey ? i > 0 ? i - 1 : s.length - 1 : i + 1 < s.length ? i + 1 : 0;
1301
+ s[u].focus({
1169
1302
  preventScroll: !0
1170
1303
  });
1171
1304
  break;
1172
1305
  }
1173
1306
  case "Home": {
1174
- e.preventDefault(), B(t, -100);
1307
+ e.preventDefault(), te(t, -100);
1175
1308
  break;
1176
1309
  }
1177
1310
  }
1178
1311
  }
1179
- function je(e) {
1312
+ function Zt(e, t) {
1313
+ const { element: n, orientation: o, panels: r } = e, s = n.getBoundingClientRect(), i = o === "horizontal";
1314
+ return Me({
1315
+ expandHitTargets: !1,
1316
+ group: e,
1317
+ includeDisabled: !0
1318
+ }).map(
1319
+ ({ panels: c, rect: a, separator: l }, f) => {
1320
+ const y = r.indexOf(c[0]), d = i ? a.left + a.width / 2 : a.top + a.height / 2;
1321
+ return {
1322
+ active: t.some((h) => {
1323
+ if (h.group !== e || h.panels[0] !== c[0])
1324
+ return !1;
1325
+ if (l || h.separator)
1326
+ return h.separator === l;
1327
+ const v = i ? h.rect.left + h.rect.width / 2 : h.rect.top + h.rect.height / 2;
1328
+ return D(d, v);
1329
+ }),
1330
+ group: e,
1331
+ key: l ? `separator-${l.id}` : `panel-${c[0].id}-${f}`,
1332
+ offset: 0,
1333
+ panelIndex: y,
1334
+ rect: new DOMRect(
1335
+ (i && !l ? d : a.left) - s.left - n.clientLeft + n.scrollLeft,
1336
+ (!i && !l ? d : a.top) - s.top - n.clientTop + n.scrollTop,
1337
+ i && !l ? 0 : a.width,
1338
+ !i && !l ? 0 : a.height
1339
+ ),
1340
+ separator: l
1341
+ };
1342
+ }
1343
+ );
1344
+ }
1345
+ function Ke(e) {
1180
1346
  if (e.defaultPrevented)
1181
1347
  return;
1182
1348
  if (e.pointerType === "mouse" && e.button > 0)
1183
1349
  return;
1184
- const t = V(), n = Le(e, t), o = /* @__PURE__ */ new Map();
1185
- let i = !1;
1186
- n.forEach((s) => {
1187
- s.separator && (i || (i = !0, s.separator.element.focus({
1350
+ const t = ee(), n = ke(e, t);
1351
+ if (n.length === 0)
1352
+ return;
1353
+ const o = /* @__PURE__ */ new Map();
1354
+ let r = !1;
1355
+ n.forEach((i) => {
1356
+ i.separator && (r || (r = !0, i.separator.element.focus({
1188
1357
  // @ts-expect-error https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#browser_compatibility
1189
1358
  focusVisible: !1,
1190
1359
  preventScroll: !0
1191
1360
  })));
1192
- const u = t.get(s.group);
1193
- u && o.set(s.group, u.layout);
1194
- }), te({
1361
+ const u = t.get(i.group);
1362
+ u && o.set(i.group, u.layout);
1363
+ });
1364
+ const s = Array.from(o.keys()).flatMap(
1365
+ (i) => i.resizePreviewMode === "separator" ? Zt(i, n) : []
1366
+ );
1367
+ W({
1195
1368
  cursorFlags: 0,
1196
1369
  hitRegions: n,
1197
1370
  initialLayoutMap: o,
1198
1371
  pointerDownAtPoint: { x: e.clientX, y: e.clientY },
1372
+ previewLayoutMap: new Map(o),
1373
+ previews: s,
1199
1374
  state: "active"
1200
- }), n.length && e.preventDefault();
1201
- }
1202
- function ut({
1203
- document: e,
1204
- event: t,
1205
- hitRegions: n,
1206
- initialLayoutMap: o,
1207
- mountedGroups: i,
1208
- pointerDownAtPoint: s,
1209
- prevCursorFlags: u
1210
- }) {
1211
- let a = 0;
1212
- n.forEach((l) => {
1213
- const { group: c, groupSize: m } = l, { orientation: p, panels: S } = c, { disableCursor: z } = c.mutableState;
1214
- let f = 0;
1215
- s ? p === "horizontal" ? f = (t.clientX - s.x) / m * 100 : f = (t.clientY - s.y) / m * 100 : p === "horizontal" ? f = t.clientX < 0 ? -100 : 100 : f = t.clientY < 0 ? -100 : 100;
1216
- const d = o.get(c), h = i.get(c);
1217
- if (!d || !h)
1218
- return;
1219
- const {
1220
- defaultLayoutDeferred: y,
1221
- derivedPanelConstraints: b,
1222
- groupSize: v,
1223
- layout: g,
1224
- separatorToPanels: w
1225
- } = h;
1226
- if (b && g && w) {
1227
- const E = ae({
1228
- delta: f,
1229
- initialLayout: d,
1230
- panelConstraints: b,
1231
- pivotIndices: l.panels.map((L) => S.indexOf(L)),
1232
- prevLayout: g,
1233
- trigger: "mouse-or-touch"
1234
- });
1235
- if (K(E, g)) {
1236
- if (f !== 0 && !z)
1237
- switch (p) {
1238
- case "horizontal": {
1239
- a |= f < 0 ? et : tt;
1240
- break;
1241
- }
1242
- case "vertical": {
1243
- a |= f < 0 ? nt : ot;
1244
- break;
1245
- }
1246
- }
1247
- } else
1248
- j(l.group, {
1249
- defaultLayoutDeferred: y,
1250
- derivedPanelConstraints: b,
1251
- groupSize: v,
1252
- layout: E,
1253
- separatorToPanels: w
1254
- });
1255
- }
1256
- });
1257
- let r = 0;
1258
- t.movementX === 0 ? r |= u & Ie : r |= a & Ie, t.movementY === 0 ? r |= u & ke : r |= a & ke, Et(r), Pe(e);
1375
+ }), e.preventDefault();
1259
1376
  }
1260
- function He(e) {
1261
- const t = V(), n = W();
1377
+ function qe(e) {
1378
+ const t = ee(), n = X();
1262
1379
  switch (n.state) {
1263
1380
  case "active":
1264
- ut({
1381
+ Ie({
1382
+ commit: !1,
1265
1383
  document: e.currentTarget,
1266
1384
  event: e,
1267
1385
  hitRegions: n.hitRegions,
@@ -1271,35 +1389,39 @@ function He(e) {
1271
1389
  });
1272
1390
  }
1273
1391
  }
1274
- function Ve(e) {
1392
+ function Xe(e) {
1275
1393
  if (e.defaultPrevented)
1276
1394
  return;
1277
- const t = W(), n = V();
1395
+ const t = X(), n = ee();
1278
1396
  switch (t.state) {
1279
1397
  case "active": {
1280
1398
  if (
1281
1399
  // Skip this check for "pointerleave" events, else Firefox triggers a false positive (see #514)
1282
1400
  e.buttons === 0
1283
1401
  ) {
1284
- te({
1402
+ t.previewLayoutMap.forEach((o, r) => {
1403
+ const s = n.get(r);
1404
+ r.resizePreviewMode === "separator" && s && !K(o, s.layout) && q(r, { ...s, layout: o });
1405
+ }), W({
1285
1406
  cursorFlags: 0,
1286
1407
  state: "inactive"
1287
1408
  }), t.hitRegions.forEach((o) => {
1288
1409
  if (!n.has(o.group))
1289
1410
  return;
1290
- const i = H(o.group.id, !0);
1291
- j(o.group, i, {
1411
+ const r = Q(o.group.id, !0);
1412
+ q(o.group, r, {
1292
1413
  isUserInteraction: !0
1293
1414
  });
1294
- });
1415
+ }), fe(e.currentTarget);
1295
1416
  return;
1296
1417
  }
1297
1418
  for (const o of t.hitRegions)
1298
1419
  if (o.separator) {
1299
- const { element: i } = o.separator;
1300
- i.isConnected && !i.hasPointerCapture?.(e.pointerId) && i.setPointerCapture?.(e.pointerId);
1420
+ const { element: r } = o.separator;
1421
+ r.isConnected && !r.hasPointerCapture?.(e.pointerId) && r.setPointerCapture?.(e.pointerId);
1301
1422
  }
1302
- ut({
1423
+ Ie({
1424
+ commit: !1,
1303
1425
  document: e.currentTarget,
1304
1426
  event: e,
1305
1427
  hitRegions: t.hitRegions,
@@ -1311,67 +1433,86 @@ function Ve(e) {
1311
1433
  break;
1312
1434
  }
1313
1435
  default: {
1314
- const o = Le(e, n);
1315
- o.length === 0 ? t.state !== "inactive" && te({
1436
+ const o = ke(e, n);
1437
+ o.length === 0 ? t.state !== "inactive" && W({
1316
1438
  cursorFlags: 0,
1317
1439
  state: "inactive"
1318
- }) : te({
1440
+ }) : W({
1319
1441
  cursorFlags: 0,
1320
1442
  hitRegions: o,
1321
1443
  state: "hover"
1322
- }), Pe(e.currentTarget);
1444
+ }), fe(e.currentTarget);
1323
1445
  break;
1324
1446
  }
1325
1447
  }
1326
1448
  }
1327
- function Ue(e) {
1449
+ function Ye(e) {
1328
1450
  if (e.relatedTarget instanceof HTMLIFrameElement)
1329
- switch (W().state) {
1451
+ switch (X().state) {
1330
1452
  case "hover":
1331
- te({
1453
+ W({
1332
1454
  cursorFlags: 0,
1333
1455
  state: "inactive"
1334
1456
  });
1335
1457
  }
1336
1458
  }
1337
- function Be(e) {
1459
+ function Je(e) {
1338
1460
  if (e.defaultPrevented)
1339
1461
  return;
1340
1462
  if (e.pointerType === "mouse" && e.button > 0)
1341
1463
  return;
1342
- rt(e.currentTarget) && e.preventDefault();
1464
+ dt(
1465
+ e.currentTarget,
1466
+ e
1467
+ ) && e.preventDefault();
1343
1468
  }
1344
- function We(e) {
1469
+ function Qt(e) {
1345
1470
  let t = 0, n = 0;
1346
1471
  const o = {};
1347
1472
  for (const s of e)
1348
1473
  if (s.defaultSize !== void 0) {
1349
1474
  t++;
1350
- const u = T(s.defaultSize);
1351
- n += u, o[s.panelId] = u;
1475
+ const i = A(s.defaultSize);
1476
+ n += i, o[s.panelId] = i;
1352
1477
  } else
1353
1478
  o[s.panelId] = void 0;
1354
- const i = e.length - t;
1355
- if (i !== 0) {
1356
- const s = T((100 - n) / i);
1357
- for (const u of e)
1358
- u.defaultSize === void 0 && (o[u.panelId] = s);
1479
+ const r = e.length - t;
1480
+ if (r !== 0) {
1481
+ const s = A((100 - n) / r);
1482
+ for (const i of e)
1483
+ i.defaultSize === void 0 && (o[i.panelId] = s);
1359
1484
  }
1360
1485
  return o;
1361
1486
  }
1362
- function jt(e, t, n) {
1487
+ function en(e, t) {
1488
+ const n = e.map((r) => r.id), o = Object.keys(t);
1489
+ if (n.length !== o.length)
1490
+ return !1;
1491
+ for (const r of n)
1492
+ if (!o.includes(r))
1493
+ return !1;
1494
+ return !0;
1495
+ }
1496
+ function Ze({
1497
+ group: e,
1498
+ panelConstraints: t
1499
+ }) {
1500
+ const n = e.panels.map(({ id: r }) => r).join(","), o = e.mutableState.defaultLayout;
1501
+ return e.mutableState.layouts[n] ?? (o && en(e.panels, o) ? o : Qt(t));
1502
+ }
1503
+ function tn(e, t, n) {
1363
1504
  if (!n[0])
1364
1505
  return;
1365
- const i = e.panels.find((l) => l.element === t);
1366
- if (!i || !i.onResize)
1506
+ const r = e.panels.find((a) => a.element === t);
1507
+ if (!r || !r.onResize)
1367
1508
  return;
1368
- const s = ne({ group: e }), u = e.orientation === "horizontal" ? i.element.offsetWidth : i.element.offsetHeight, a = i.mutableValues.prevSize, r = {
1369
- asPercentage: T(u / s * 100),
1370
- inPixels: u
1509
+ const s = ae({ group: e }), i = e.orientation === "horizontal" ? r.element.offsetWidth : r.element.offsetHeight, u = r.mutableValues.prevSize, c = {
1510
+ asPercentage: A(i / s * 100),
1511
+ inPixels: i
1371
1512
  };
1372
- i.mutableValues.prevSize = r, i.onResize(r, i.id, a);
1513
+ r.mutableValues.prevSize = c, r.onResize(c, r.id, u);
1373
1514
  }
1374
- function Ht(e, t) {
1515
+ function gt(e, t) {
1375
1516
  if (Object.keys(e).length !== Object.keys(t).length)
1376
1517
  return !1;
1377
1518
  for (const o in e)
@@ -1379,10 +1520,10 @@ function Ht(e, t) {
1379
1520
  return !1;
1380
1521
  return !0;
1381
1522
  }
1382
- function Vt(e, t) {
1383
- return e.length !== t.length ? !1 : e.every((n, o) => Ht(n, t[o]));
1523
+ function nn(e, t) {
1524
+ return e.length !== t.length ? !1 : e.every((n, o) => gt(n, t[o]));
1384
1525
  }
1385
- function Ut({
1526
+ function on({
1386
1527
  group: e,
1387
1528
  nextGroupSize: t,
1388
1529
  prevGroupSize: n,
@@ -1390,172 +1531,166 @@ function Ut({
1390
1531
  }) {
1391
1532
  if (n <= 0 || t <= 0 || n === t)
1392
1533
  return o;
1393
- let i = 0, s = 0, u = !1;
1394
- const a = /* @__PURE__ */ new Map(), r = [];
1395
- for (const m of e.panels) {
1396
- const p = o[m.id] ?? 0;
1397
- switch (m.panelConstraints.groupResizeBehavior) {
1534
+ let r = 0, s = 0, i = !1;
1535
+ const u = /* @__PURE__ */ new Map(), c = [];
1536
+ for (const f of e.panels) {
1537
+ const y = o[f.id] ?? 0;
1538
+ switch (f.panelConstraints.groupResizeBehavior) {
1398
1539
  case "preserve-pixel-size": {
1399
- u = !0;
1400
- const S = p / 100 * n, z = T(
1401
- S / t * 100
1540
+ i = !0;
1541
+ const d = y / 100 * n, p = A(
1542
+ d / t * 100
1402
1543
  );
1403
- a.set(m.id, z), i += z;
1544
+ u.set(f.id, p), r += p;
1404
1545
  break;
1405
1546
  }
1406
1547
  case "preserve-relative-size":
1407
1548
  default: {
1408
- r.push(m.id), s += p;
1549
+ c.push(f.id), s += y;
1409
1550
  break;
1410
1551
  }
1411
1552
  }
1412
1553
  }
1413
- if (!u || r.length === 0)
1554
+ if (!i || c.length === 0)
1414
1555
  return o;
1415
- const l = 100 - i, c = { ...o };
1416
- if (a.forEach((m, p) => {
1417
- c[p] = m;
1556
+ const a = 100 - r, l = { ...o };
1557
+ if (u.forEach((f, y) => {
1558
+ l[y] = f;
1418
1559
  }), s > 0)
1419
- for (const m of r) {
1420
- const p = o[m] ?? 0;
1421
- c[m] = T(
1422
- p / s * l
1560
+ for (const f of c) {
1561
+ const y = o[f] ?? 0;
1562
+ l[f] = A(
1563
+ y / s * a
1423
1564
  );
1424
1565
  }
1425
1566
  else {
1426
- const m = T(
1427
- l / r.length
1567
+ const f = A(
1568
+ a / c.length
1428
1569
  );
1429
- for (const p of r)
1430
- c[p] = m;
1570
+ for (const y of c)
1571
+ l[y] = f;
1431
1572
  }
1432
- return c;
1433
- }
1434
- function Bt(e, t) {
1435
- const n = e.map((i) => i.id), o = Object.keys(t);
1436
- if (n.length !== o.length)
1437
- return !1;
1438
- for (const i of n)
1439
- if (!o.includes(i))
1440
- return !1;
1441
- return !0;
1573
+ return l;
1442
1574
  }
1443
- const J = /* @__PURE__ */ new Map();
1444
- function Wt(e) {
1575
+ const re = /* @__PURE__ */ new Map();
1576
+ function rn(e) {
1445
1577
  let t = !0;
1446
- C(
1578
+ L(
1447
1579
  e.element.ownerDocument.defaultView,
1448
1580
  "Cannot register an unmounted Group"
1449
1581
  );
1450
- const n = e.element.ownerDocument.defaultView.ResizeObserver, o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), s = new n((f) => {
1451
- for (const d of f) {
1452
- const { borderBoxSize: h, target: y } = d;
1453
- if (y === e.element) {
1582
+ const n = e.element.ownerDocument.defaultView.ResizeObserver, o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = new n((d) => {
1583
+ for (const p of d) {
1584
+ const { borderBoxSize: h, target: v } = p;
1585
+ if (v === e.element) {
1454
1586
  if (t) {
1455
- const b = ne({ group: e });
1456
- if (b === 0)
1587
+ const m = ae({ group: e });
1588
+ if (m === 0)
1457
1589
  return;
1458
- const v = H(e.id);
1459
- if (!v)
1590
+ const g = Q(e.id);
1591
+ if (!g)
1460
1592
  return;
1461
- const g = be(e), w = v.defaultLayoutDeferred ? We(g) : v.layout, E = Ut({
1593
+ const x = Le(e), b = g.defaultLayoutDeferred ? Ze({
1462
1594
  group: e,
1463
- nextGroupSize: b,
1464
- prevGroupSize: v.groupSize,
1465
- prevLayout: w
1466
- }), L = X({
1467
- layout: E,
1468
- panelConstraints: g
1595
+ panelConstraints: x
1596
+ }) : g.layout, z = on({
1597
+ group: e,
1598
+ nextGroupSize: m,
1599
+ prevGroupSize: g.groupSize,
1600
+ prevLayout: b
1601
+ }), E = ne({
1602
+ layout: z,
1603
+ panelConstraints: x
1469
1604
  });
1470
- if (!v.defaultLayoutDeferred && K(v.layout, L) && Vt(
1471
- v.derivedPanelConstraints,
1472
- g
1473
- ) && v.groupSize === b)
1605
+ if (!g.defaultLayoutDeferred && K(g.layout, E) && nn(
1606
+ g.derivedPanelConstraints,
1607
+ x
1608
+ ) && g.groupSize === m)
1474
1609
  continue;
1475
- j(e, {
1610
+ q(e, {
1476
1611
  defaultLayoutDeferred: !1,
1477
- derivedPanelConstraints: g,
1478
- groupSize: b,
1479
- layout: L,
1480
- separatorToPanels: v.separatorToPanels
1612
+ derivedPanelConstraints: x,
1613
+ groupSize: m,
1614
+ layout: E,
1615
+ separatorToPanels: g.separatorToPanels
1481
1616
  });
1482
1617
  }
1483
1618
  } else
1484
- jt(e, y, h);
1619
+ tn(e, v, h);
1485
1620
  }
1486
1621
  });
1487
- s.observe(e.element), e.panels.forEach((f) => {
1488
- C(
1489
- !o.has(f.id),
1490
- `Panel ids must be unique; id "${f.id}" was used more than once`
1491
- ), o.add(f.id), f.onResize && s.observe(f.element);
1622
+ s.observe(e.element), e.panels.forEach((d) => {
1623
+ L(
1624
+ !o.has(d.id),
1625
+ `Panel ids must be unique; id "${d.id}" was used more than once`
1626
+ ), o.add(d.id), d.onResize && s.observe(d.element);
1492
1627
  });
1493
- const u = ne({ group: e }), a = be(e), r = e.panels.map(({ id: f }) => f).join(",");
1494
- let l = e.mutableState.defaultLayout;
1495
- l && (Bt(e.panels, l) || (l = void 0));
1496
- const c = e.mutableState.layouts[r] ?? l ?? We(a), m = X({
1628
+ const i = ae({ group: e }), u = Le(e), c = Ze({
1629
+ group: e,
1630
+ panelConstraints: u
1631
+ }), a = ne({
1497
1632
  layout: c,
1498
- panelConstraints: a
1499
- }), p = e.element.ownerDocument;
1500
- J.set(
1501
- p,
1502
- (J.get(p) ?? 0) + 1
1633
+ panelConstraints: u
1634
+ }), l = e.element.ownerDocument;
1635
+ re.set(
1636
+ l,
1637
+ (re.get(l) ?? 0) + 1
1503
1638
  );
1504
- const S = /* @__PURE__ */ new Map();
1505
- return Ze(e).forEach((f) => {
1506
- f.separator && S.set(f.separator, f.panels);
1507
- }), j(e, {
1508
- defaultLayoutDeferred: u === 0,
1509
- derivedPanelConstraints: a,
1510
- groupSize: u,
1511
- layout: m,
1512
- separatorToPanels: S
1513
- }), e.separators.forEach((f) => {
1514
- C(
1515
- !i.has(f.id),
1516
- `Separator ids must be unique; id "${f.id}" was used more than once`
1517
- ), i.add(f.id), f.element.addEventListener("keydown", $e);
1518
- }), J.get(p) === 1 && (p.addEventListener("contextmenu", Ge, !0), p.addEventListener("dblclick", _e, !0), p.addEventListener("pointerdown", je, !0), p.addEventListener("pointerleave", He), p.addEventListener("pointermove", Ve), p.addEventListener("pointerout", Ue), p.addEventListener("pointerup", Be, !0)), function() {
1519
- t = !1, J.set(
1520
- p,
1521
- Math.max(0, (J.get(p) ?? 0) - 1)
1522
- ), kt(e), e.separators.forEach((d) => {
1523
- d.element.removeEventListener("keydown", $e);
1524
- }), J.get(p) || (p.removeEventListener(
1639
+ const f = /* @__PURE__ */ new Map();
1640
+ return Me({ group: e, includeDisabled: !0 }).forEach((d) => {
1641
+ d.separator && f.set(d.separator, d.panels);
1642
+ }), q(e, {
1643
+ defaultLayoutDeferred: i === 0,
1644
+ derivedPanelConstraints: u,
1645
+ groupSize: i,
1646
+ layout: a,
1647
+ separatorToPanels: f
1648
+ }), e.separators.forEach((d) => {
1649
+ L(
1650
+ !r.has(d.id),
1651
+ `Separator ids must be unique; id "${d.id}" was used more than once`
1652
+ ), r.add(d.id), d.element.addEventListener("keydown", We);
1653
+ }), re.get(l) === 1 && (l.addEventListener("contextmenu", He, !0), l.addEventListener("dblclick", Ue, !0), l.addEventListener("pointerdown", Ke, !0), l.addEventListener("pointerleave", qe), l.addEventListener("pointermove", Xe), l.addEventListener("pointerout", Ye), l.addEventListener("pointerup", Je, !0)), function() {
1654
+ t = !1, re.set(
1655
+ l,
1656
+ Math.max(0, (re.get(l) ?? 0) - 1)
1657
+ ), Vt(e), Gt(e) && fe(l), e.separators.forEach((p) => {
1658
+ p.element.removeEventListener("keydown", We);
1659
+ }), re.get(l) || (l.removeEventListener(
1525
1660
  "contextmenu",
1526
- Ge,
1661
+ He,
1527
1662
  !0
1528
- ), p.removeEventListener(
1663
+ ), l.removeEventListener(
1529
1664
  "dblclick",
1530
- _e,
1665
+ Ue,
1531
1666
  !0
1532
- ), p.removeEventListener(
1667
+ ), l.removeEventListener(
1533
1668
  "pointerdown",
1534
- je,
1669
+ Ke,
1535
1670
  !0
1536
- ), p.removeEventListener("pointerleave", He), p.removeEventListener("pointermove", Ve), p.removeEventListener("pointerout", Ue), p.removeEventListener("pointerup", Be, !0)), s.disconnect();
1671
+ ), l.removeEventListener("pointerleave", qe), l.removeEventListener("pointermove", Xe), l.removeEventListener("pointerout", Ye), l.removeEventListener("pointerup", Je, !0)), s.disconnect();
1537
1672
  };
1538
1673
  }
1539
- function Kt() {
1540
- const [e, t] = Q({}), n = ie(() => t({}), []);
1674
+ function sn() {
1675
+ const [e, t] = Z({}), n = ce(() => t({}), []);
1541
1676
  return [e, n];
1542
1677
  }
1543
- function Ce(e) {
1544
- const t = mt();
1678
+ function Te(e) {
1679
+ const t = Pt();
1545
1680
  return `${e ?? t}`;
1546
1681
  }
1547
- const q = typeof window < "u" ? Ke : ge;
1548
- function re(e) {
1682
+ const V = typeof window < "u" ? Qe : Se;
1683
+ function ue(e) {
1549
1684
  const t = O(e);
1550
- return q(() => {
1685
+ return V(() => {
1551
1686
  t.current = e;
1552
- }, [e]), ie(
1687
+ }, [e]), ce(
1553
1688
  (...n) => t.current?.(...n),
1554
1689
  [t]
1555
1690
  );
1556
1691
  }
1557
- function Re(...e) {
1558
- return re((t) => {
1692
+ function De(...e) {
1693
+ return ue((t) => {
1559
1694
  e.forEach((n) => {
1560
1695
  if (n)
1561
1696
  switch (typeof n) {
@@ -1571,268 +1706,429 @@ function Re(...e) {
1571
1706
  });
1572
1707
  });
1573
1708
  }
1574
- function Ee(e) {
1709
+ function Oe(e) {
1575
1710
  const t = O({ ...e });
1576
- return q(() => {
1711
+ return V(() => {
1577
1712
  for (const n in e)
1578
1713
  t.current[n] = e[n];
1579
1714
  }, [e]), t.current;
1580
1715
  }
1581
- const ct = gt(null);
1582
- function Xt(e, t) {
1716
+ const yt = Lt(null);
1717
+ function an({
1718
+ separator: e
1719
+ }) {
1720
+ const { element: t } = e, n = O(null);
1721
+ return V(() => {
1722
+ const o = t.cloneNode(!0), r = [t, ...t.querySelectorAll("*")], s = [o, ...o.querySelectorAll("*")], i = t.ownerDocument.defaultView;
1723
+ return r.forEach((u, c) => {
1724
+ const a = s[c];
1725
+ if (a instanceof i.HTMLElement || a instanceof i.SVGElement) {
1726
+ const l = i.getComputedStyle(u);
1727
+ for (let f = 0; f < l.length; f++) {
1728
+ const y = l.item(f);
1729
+ a.style.setProperty(
1730
+ y,
1731
+ l.getPropertyValue(y)
1732
+ );
1733
+ }
1734
+ }
1735
+ a.removeAttribute("data-testid"), a.removeAttribute("id");
1736
+ }), Object.assign(o.style, {
1737
+ boxSizing: "border-box",
1738
+ height: "100%",
1739
+ margin: "0",
1740
+ position: "static",
1741
+ transform: "none",
1742
+ width: "100%"
1743
+ }), n.current.appendChild(o), () => o.remove();
1744
+ }, [t]), /* @__PURE__ */ U(
1745
+ "div",
1746
+ {
1747
+ ref: n,
1748
+ style: {
1749
+ height: "100%",
1750
+ opacity: 0.65,
1751
+ pointerEvents: "none",
1752
+ width: "100%"
1753
+ }
1754
+ }
1755
+ );
1756
+ }
1757
+ function be() {
1758
+ const e = Ct(yt);
1759
+ return L(
1760
+ e,
1761
+ "Group Context not found; did you render a Panel or Separator outside of a Group?"
1762
+ ), e;
1763
+ }
1764
+ function vt(e) {
1765
+ const { registerOverlay: t } = be(), n = O(e);
1766
+ gt(n.current, e) || (n.current = e);
1767
+ const o = n.current;
1768
+ return V(
1769
+ () => t(o),
1770
+ [t, o]
1771
+ ), null;
1772
+ }
1773
+ vt.displayName = "SeparatorOverlay";
1774
+ function ln({
1775
+ active: e,
1776
+ orientation: t,
1777
+ style: n,
1778
+ ...o
1779
+ }) {
1780
+ let r;
1781
+ switch (t) {
1782
+ case "horizontal": {
1783
+ r = {
1784
+ height: "100%",
1785
+ minWidth: "1px"
1786
+ };
1787
+ break;
1788
+ }
1789
+ case "vertical": {
1790
+ r = {
1791
+ minHeight: "1px",
1792
+ width: "100%"
1793
+ };
1794
+ break;
1795
+ }
1796
+ }
1797
+ return /* @__PURE__ */ U(
1798
+ "div",
1799
+ {
1800
+ ...o,
1801
+ "data-separator-overlay": e ? "active" : "inactive",
1802
+ style: {
1803
+ ...r,
1804
+ ...n,
1805
+ flexShrink: 0,
1806
+ pointerEvents: "none"
1807
+ }
1808
+ }
1809
+ );
1810
+ }
1811
+ function cn({
1812
+ overlay: e,
1813
+ preview: t
1814
+ }) {
1815
+ const { group: n, offset: o, rect: r, separator: s } = t, i = n.orientation === "horizontal";
1816
+ let u = s?.preview, c = e;
1817
+ return Rt(u) && u.type === vt && (c = u.props, u = void 0), u == null && (c ? u = /* @__PURE__ */ U(
1818
+ ln,
1819
+ {
1820
+ ...c,
1821
+ active: t.active,
1822
+ orientation: n.orientation
1823
+ }
1824
+ ) : s && (u = /* @__PURE__ */ U(an, { separator: s }))), /* @__PURE__ */ U(
1825
+ "div",
1826
+ {
1827
+ "aria-hidden": "true",
1828
+ "data-resize-preview": !0,
1829
+ inert: !0,
1830
+ style: {
1831
+ height: r.height,
1832
+ left: r.left,
1833
+ pointerEvents: "none",
1834
+ position: "absolute",
1835
+ top: r.top,
1836
+ transform: i ? `translateX(${o}px)` : `translateY(${o}px)`,
1837
+ width: r.width
1838
+ },
1839
+ children: u
1840
+ }
1841
+ );
1842
+ }
1843
+ function un(e, t) {
1583
1844
  const n = O({
1584
1845
  getLayout: () => ({}),
1585
- setLayout: Mt
1846
+ setLayout: At
1586
1847
  });
1587
- Xe(t, () => n.current, []), q(() => {
1848
+ et(t, () => n.current, []), V(() => {
1588
1849
  Object.assign(
1589
1850
  n.current,
1590
- lt({ groupId: e })
1851
+ mt({ groupId: e })
1591
1852
  );
1592
1853
  });
1593
1854
  }
1594
- function qt({
1855
+ function fn({
1856
+ groupId: e,
1857
+ resizePreviewMode: t
1858
+ }) {
1859
+ const [n, o] = Z([]), r = O(n);
1860
+ return V(() => {
1861
+ const s = (u) => {
1862
+ const c = ft(e), a = t === "separator" && u.state === "active" ? u.previews.filter(
1863
+ (f) => f.group === c && (f.active || !D(f.offset, 0))
1864
+ ) : [], l = r.current;
1865
+ l.length === a.length && a.every(
1866
+ (f, y) => f === l[y]
1867
+ ) || (r.current = a, o(a));
1868
+ };
1869
+ if (t !== "separator") {
1870
+ s(X());
1871
+ return;
1872
+ }
1873
+ const i = ot(
1874
+ ({ next: u }) => s(u)
1875
+ );
1876
+ return s(X()), i;
1877
+ }, [e, t]), n;
1878
+ }
1879
+ function dn({
1595
1880
  children: e,
1596
1881
  className: t,
1597
1882
  defaultLayout: n,
1598
1883
  disableCursor: o,
1599
- disabled: i,
1884
+ disabled: r,
1600
1885
  elementRef: s,
1601
- groupRef: u,
1602
- id: a,
1603
- onLayoutChange: r,
1604
- onLayoutChanged: l,
1605
- orientation: c = "horizontal",
1606
- resizeTargetMinimumSize: m = {
1886
+ groupRef: i,
1887
+ id: u,
1888
+ onLayoutChange: c,
1889
+ onLayoutChanged: a,
1890
+ orientation: l = "horizontal",
1891
+ resizePreviewMode: f = "panel",
1892
+ resizeTargetMinimumSize: y = {
1607
1893
  coarse: 20,
1608
1894
  fine: 10
1609
1895
  },
1610
- style: p,
1611
- ...S
1896
+ style: d,
1897
+ ...p
1612
1898
  }) {
1613
- const z = O({
1899
+ const h = O({
1614
1900
  onLayoutChange: {},
1615
1901
  onLayoutChanged: {}
1616
- }), f = re((x) => {
1617
- K(z.current.onLayoutChange, x) || (z.current.onLayoutChange = x, r?.(x));
1618
- }), d = re(
1619
- (x, P) => {
1620
- K(z.current.onLayoutChanged, x) || (z.current.onLayoutChanged = x, l?.(x, { isUserInteraction: P }));
1902
+ }), v = ue((S) => {
1903
+ K(h.current.onLayoutChange, S) || (h.current.onLayoutChange = S, c?.(S));
1904
+ }), m = ue(
1905
+ (S, P) => {
1906
+ K(h.current.onLayoutChanged, S) || (h.current.onLayoutChanged = S, a?.(S, { isUserInteraction: P }));
1621
1907
  }
1622
- ), h = Ce(a), y = O(null), [b, v] = Kt(), g = O({
1908
+ ), g = Te(u), [x, b] = Z(), z = fn({
1909
+ groupId: g,
1910
+ resizePreviewMode: f
1911
+ }), E = O(null), [R, w] = sn(), C = O({
1623
1912
  lastExpandedPanelSizes: {},
1624
1913
  layouts: {},
1625
1914
  panels: [],
1626
- resizeTargetMinimumSize: m,
1627
1915
  separators: []
1628
- }), w = Re(y, s);
1629
- Xt(h, u);
1630
- const E = re(
1631
- (x, P) => {
1632
- const I = W(), R = Oe(x), M = H(x);
1633
- if (M) {
1634
- let k = !1;
1635
- switch (I.state) {
1636
- case "active": {
1637
- k = I.hitRegions.some(
1638
- (U) => U.group === R
1639
- );
1640
- break;
1641
- }
1642
- }
1916
+ }), F = De(E, s);
1917
+ un(g, i);
1918
+ const I = ue(
1919
+ (S, P) => {
1920
+ const k = Q(S);
1921
+ if (k)
1643
1922
  return {
1644
- flexGrow: M.layout[P] ?? 1,
1645
- pointerEvents: k ? "none" : void 0
1923
+ flexGrow: k.layout[P] ?? 1
1646
1924
  };
1647
- }
1648
1925
  if (n?.[P])
1649
1926
  return {
1650
1927
  flexGrow: n?.[P]
1651
1928
  };
1652
1929
  }
1653
- ), L = Ee({
1930
+ ), M = Oe({
1654
1931
  defaultLayout: n,
1655
- disableCursor: o
1656
- }), G = ve(
1932
+ disableCursor: o,
1933
+ resizeTargetMinimumSize: y
1934
+ }), N = Pe(
1657
1935
  () => ({
1658
1936
  get disableCursor() {
1659
- return !!L.disableCursor;
1937
+ return !!M.disableCursor;
1660
1938
  },
1661
- getPanelStyles: E,
1662
- id: h,
1663
- orientation: c,
1664
- registerPanel: (x) => {
1665
- const P = g.current;
1666
- return P.panels = ze(c, [
1939
+ getPanelStyles: I,
1940
+ id: g,
1941
+ orientation: l,
1942
+ registerPanel: (S) => {
1943
+ const P = C.current;
1944
+ return P.panels = Ce(l, [
1667
1945
  ...P.panels,
1668
- x
1669
- ]), v(), () => {
1946
+ S
1947
+ ]), w(), () => {
1670
1948
  P.panels = P.panels.filter(
1671
- (I) => I !== x
1672
- ), v();
1949
+ (k) => k !== S
1950
+ ), w();
1673
1951
  };
1674
1952
  },
1675
- registerSeparator: (x) => {
1676
- const P = g.current;
1677
- return P.separators = ze(c, [
1953
+ registerOverlay: (S) => (b(S), () => {
1954
+ b(void 0);
1955
+ }),
1956
+ registerSeparator: (S) => {
1957
+ const P = C.current;
1958
+ return P.separators = Ce(l, [
1678
1959
  ...P.separators,
1679
- x
1680
- ]), v(), () => {
1960
+ S
1961
+ ]), w(), () => {
1681
1962
  P.separators = P.separators.filter(
1682
- (I) => I !== x
1683
- ), v();
1963
+ (k) => k !== S
1964
+ ), w();
1684
1965
  };
1685
1966
  },
1686
- updatePanelProps: (x, { disabled: P }) => {
1687
- const R = g.current.panels.find(
1688
- (U) => U.id === x
1967
+ updatePanelProps: (S, { disabled: P }) => {
1968
+ const G = C.current.panels.find(
1969
+ (oe) => oe.id === S
1689
1970
  );
1690
- R && (R.panelConstraints.disabled = P);
1691
- const M = Oe(h), k = H(h);
1692
- M && k && j(M, {
1693
- ...k,
1694
- derivedPanelConstraints: be(M)
1971
+ G && (G.panelConstraints.disabled = P);
1972
+ const $ = ft(g), Y = Q(g);
1973
+ $ && Y && q($, {
1974
+ ...Y,
1975
+ derivedPanelConstraints: Le($)
1695
1976
  });
1696
1977
  },
1697
- updateSeparatorProps: (x, {
1978
+ updateSeparatorProps: (S, {
1698
1979
  disabled: P,
1699
- disableDoubleClick: I
1980
+ disableDoubleClick: k
1700
1981
  }) => {
1701
- const M = g.current.separators.find(
1702
- (k) => k.id === x
1982
+ const $ = C.current.separators.find(
1983
+ (Y) => Y.id === S
1703
1984
  );
1704
- M && (M.disabled = P, M.disableDoubleClick = I);
1985
+ $ && ($.disabled = P, $.disableDoubleClick = k);
1705
1986
  }
1706
1987
  }),
1707
- [E, h, v, c, L]
1708
- ), N = O(null);
1709
- return q(() => {
1710
- const x = y.current;
1711
- if (x === null)
1988
+ [I, g, w, l, M]
1989
+ ), _ = O(null);
1990
+ return V(() => {
1991
+ const S = E.current;
1992
+ if (S === null)
1712
1993
  return;
1713
- const P = g.current;
1714
- let I;
1715
- if (L.defaultLayout !== void 0 && Object.keys(L.defaultLayout).length === P.panels.length) {
1716
- I = {};
1717
- for (const _ of P.panels) {
1718
- const Y = L.defaultLayout[_.id];
1719
- Y !== void 0 && (I[_.id] = Y);
1994
+ const P = C.current;
1995
+ let k;
1996
+ if (M.defaultLayout !== void 0 && Object.keys(M.defaultLayout).length === P.panels.length) {
1997
+ k = {};
1998
+ for (const J of P.panels) {
1999
+ const pe = M.defaultLayout[J.id];
2000
+ pe !== void 0 && (k[J.id] = pe);
1720
2001
  }
1721
2002
  }
1722
- const R = {
1723
- disabled: !!i,
1724
- element: x,
1725
- id: h,
2003
+ const G = {
2004
+ disabled: !!r,
2005
+ element: S,
2006
+ id: g,
1726
2007
  mutableState: {
1727
- defaultLayout: I,
1728
- disableCursor: !!L.disableCursor,
1729
- expandedPanelSizes: g.current.lastExpandedPanelSizes,
1730
- layouts: g.current.layouts
2008
+ defaultLayout: k,
2009
+ disableCursor: !!M.disableCursor,
2010
+ expandedPanelSizes: C.current.lastExpandedPanelSizes,
2011
+ layouts: C.current.layouts
1731
2012
  },
1732
- orientation: c,
2013
+ orientation: l,
1733
2014
  panels: P.panels,
1734
- resizeTargetMinimumSize: P.resizeTargetMinimumSize,
2015
+ resizePreviewMode: f,
2016
+ get resizeTargetMinimumSize() {
2017
+ return M.resizeTargetMinimumSize;
2018
+ },
1735
2019
  separators: P.separators
1736
2020
  };
1737
- N.current = R;
1738
- const M = Wt(R), { defaultLayoutDeferred: k, derivedPanelConstraints: U, layout: le } = H(R.id, !0);
1739
- !k && U.length > 0 && (f(le), d(le, !1));
1740
- const ue = we(h, (_) => {
1741
- const { defaultLayoutDeferred: Y, derivedPanelConstraints: ce, layout: fe } = _.next;
1742
- if (Y || ce.length === 0)
2021
+ _.current = G;
2022
+ const $ = rn(G), { defaultLayoutDeferred: Y, derivedPanelConstraints: oe, layout: le } = Q(G.id, !0);
2023
+ !Y && oe.length > 0 && (v(le), m(le, !1));
2024
+ const xe = Ee(g, (J) => {
2025
+ const { defaultLayoutDeferred: pe, derivedPanelConstraints: Ge, layout: he } = J.next;
2026
+ if (pe || Ge.length === 0)
1743
2027
  return;
1744
- const ft = R.panels.map(({ id: $ }) => $).join(",");
1745
- R.mutableState.layouts[ft] = fe, ce.forEach(($) => {
1746
- if ($.collapsible) {
1747
- const { layout: ye } = _.prev ?? {};
1748
- if (ye) {
1749
- const pt = D(
1750
- $.collapsedSize,
1751
- fe[$.panelId]
1752
- ), ht = D(
1753
- $.collapsedSize,
1754
- ye[$.panelId]
2028
+ const St = G.panels.map(({ id: H }) => H).join(",");
2029
+ G.mutableState.layouts[St] = he, Ge.forEach((H) => {
2030
+ if (H.collapsible) {
2031
+ const { layout: ze } = J.prev ?? {};
2032
+ if (ze) {
2033
+ const xt = D(
2034
+ H.collapsedSize,
2035
+ he[H.panelId]
2036
+ ), zt = D(
2037
+ H.collapsedSize,
2038
+ ze[H.panelId]
1755
2039
  );
1756
- pt && !ht && (R.mutableState.expandedPanelSizes[$.panelId] = ye[$.panelId]);
2040
+ xt && !zt && (G.mutableState.expandedPanelSizes[H.panelId] = ze[H.panelId]);
1757
2041
  }
1758
2042
  }
1759
2043
  });
1760
- const dt = W().state !== "active";
1761
- f(fe), dt && d(fe, _.isUserInteraction);
2044
+ const Ae = X(), bt = Ae.state !== "active" || !Ae.hitRegions.some((H) => H.group === G);
2045
+ v(he), bt && m(he, J.isUserInteraction);
1762
2046
  });
1763
2047
  return () => {
1764
- N.current = null, M(), ue();
2048
+ _.current = null, $(), xe();
1765
2049
  };
1766
2050
  }, [
1767
- i,
1768
- h,
1769
- d,
2051
+ r,
2052
+ g,
2053
+ m,
2054
+ v,
2055
+ l,
2056
+ R,
1770
2057
  f,
1771
- c,
1772
- b,
1773
- L
1774
- ]), ge(() => {
1775
- const x = N.current;
1776
- x && (x.mutableState.defaultLayout = n, x.mutableState.disableCursor = !!o);
1777
- }), /* @__PURE__ */ se(ct.Provider, { value: G, children: /* @__PURE__ */ se(
2058
+ M
2059
+ ]), Se(() => {
2060
+ const S = _.current;
2061
+ S && (S.mutableState.defaultLayout = n, S.mutableState.disableCursor = !!o);
2062
+ }), /* @__PURE__ */ U(yt.Provider, { value: N, children: /* @__PURE__ */ wt(
1778
2063
  "div",
1779
2064
  {
1780
- ...S,
2065
+ ...p,
1781
2066
  className: t,
1782
2067
  "data-group": !0,
1783
- "data-testid": h,
1784
- id: h,
1785
- ref: w,
2068
+ "data-testid": g,
2069
+ id: g,
2070
+ ref: F,
1786
2071
  style: {
1787
2072
  height: "100%",
1788
2073
  width: "100%",
1789
2074
  overflow: "hidden",
1790
- ...p,
2075
+ position: f === "separator" ? "relative" : void 0,
2076
+ ...d,
1791
2077
  display: "flex",
1792
- flexDirection: c === "horizontal" ? "row" : "column",
2078
+ flexDirection: l === "horizontal" ? "row" : "column",
1793
2079
  flexWrap: "nowrap",
1794
2080
  // Inform the browser that the library is handling touch events for this element
1795
2081
  // but still allow users to scroll content within panels in the non-resizing direction
1796
2082
  // NOTE This is not an inherited style
1797
2083
  // See github.com/bvaughn/react-resizable-panels/issues/662
1798
- touchAction: c === "horizontal" ? "pan-y" : "pan-x"
2084
+ touchAction: l === "horizontal" ? "pan-y" : "pan-x"
1799
2085
  },
1800
- children: e
2086
+ children: [
2087
+ e,
2088
+ z.map((S) => /* @__PURE__ */ U(
2089
+ cn,
2090
+ {
2091
+ overlay: x,
2092
+ preview: S
2093
+ },
2094
+ S.key
2095
+ ))
2096
+ ]
1801
2097
  }
1802
2098
  ) });
1803
2099
  }
1804
- qt.displayName = "Group";
1805
- function me(e, t) {
2100
+ dn.displayName = "Group";
2101
+ function ve(e, t) {
1806
2102
  return `react-resizable-panels:${[e, ...t].join(":")}`;
1807
2103
  }
1808
- function Yt({
2104
+ function pn({
1809
2105
  id: e,
1810
2106
  panelIds: t,
1811
2107
  storage: n
1812
2108
  }) {
1813
- const o = me(e, []), i = n.getItem(o);
1814
- if (i)
2109
+ const o = ve(e, []), r = n.getItem(o);
2110
+ if (r)
1815
2111
  try {
1816
- const s = JSON.parse(i);
2112
+ const s = JSON.parse(r);
1817
2113
  if (t) {
1818
- const u = t.join(","), a = s[u];
1819
- if (a && Array.isArray(a.layout) && t.length === a.layout.length) {
1820
- const r = {};
1821
- for (let l = 0; l < t.length; l++)
1822
- r[t[l]] = a.layout[l];
1823
- return r;
2114
+ const i = t.join(","), u = s[i];
2115
+ if (u && Array.isArray(u.layout) && t.length === u.layout.length) {
2116
+ const c = {};
2117
+ for (let a = 0; a < t.length; a++)
2118
+ c[t[a]] = u.layout[a];
2119
+ return c;
1824
2120
  }
1825
2121
  } else {
1826
- const u = Object.keys(s);
1827
- if (u.length === 1) {
1828
- const a = s[u[0]];
1829
- if (a && Array.isArray(a.layout)) {
1830
- const r = u[0].split(",");
1831
- if (r.length === a.layout.length) {
1832
- const l = {};
1833
- for (let c = 0; c < r.length; c++)
1834
- l[r[c]] = a.layout[c];
1835
- return l;
2122
+ const i = Object.keys(s);
2123
+ if (i.length === 1) {
2124
+ const u = s[i[0]];
2125
+ if (u && Array.isArray(u.layout)) {
2126
+ const c = i[0].split(",");
2127
+ if (c.length === u.layout.length) {
2128
+ const a = {};
2129
+ for (let l = 0; l < c.length; l++)
2130
+ a[c[l]] = u.layout[l];
2131
+ return a;
1836
2132
  }
1837
2133
  }
1838
2134
  }
@@ -1840,224 +2136,220 @@ function Yt({
1840
2136
  } catch {
1841
2137
  }
1842
2138
  }
1843
- function an({
2139
+ function zn({
1844
2140
  debounceSaveMs: e = 100,
1845
2141
  onlySaveAfterUserInteractions: t,
1846
2142
  panelIds: n,
1847
2143
  storage: o = localStorage,
1848
- ...i
2144
+ ...r
1849
2145
  }) {
1850
- const s = n !== void 0, u = "id" in i ? i.id : i.groupId, a = me(u, n ?? []), r = qe(
1851
- Jt,
1852
- () => o.getItem(a),
1853
- () => o.getItem(a)
1854
- ), l = ve(() => {
1855
- if (r) {
1856
- const d = JSON.parse(r), h = Object.values(d);
1857
- if (Array.from(h).every((y) => typeof y == "number"))
1858
- return d;
2146
+ const s = n !== void 0, i = "id" in r ? r.id : r.groupId, u = ve(i, n ?? []), c = tt(
2147
+ hn,
2148
+ () => o.getItem(u),
2149
+ () => o.getItem(u)
2150
+ ), a = Pe(() => {
2151
+ if (c) {
2152
+ const v = JSON.parse(c), m = Object.values(v);
2153
+ if (Array.from(m).every((g) => typeof g == "number"))
2154
+ return v;
1859
2155
  }
1860
- }, [r]), c = ve(() => {
1861
- if (!l)
1862
- return Yt({
1863
- id: u,
2156
+ }, [c]), l = Pe(() => {
2157
+ if (!a)
2158
+ return pn({
2159
+ id: i,
1864
2160
  panelIds: n,
1865
2161
  storage: o
1866
2162
  });
1867
- }, [l, u, n, o]), m = l ?? c, p = O(null), S = ie(() => {
1868
- const d = p.current;
1869
- d && (p.current = null, clearTimeout(d));
2163
+ }, [a, i, n, o]), f = a ?? l, y = O(null), d = ce(() => {
2164
+ const v = y.current;
2165
+ v && (y.current = null, clearTimeout(v));
1870
2166
  }, []);
1871
- Ke(() => () => {
1872
- S();
1873
- }, [S]);
1874
- const z = ie(
2167
+ Qe(() => () => {
2168
+ d();
2169
+ }, [d]);
2170
+ const p = ce(
1875
2171
  // The hook persists every layout commit -- including library-driven ones --
1876
2172
  // because it owns its own storage and the goal is to remember whatever
1877
2173
  // layout the user is currently looking at. Consumers that only want to
1878
2174
  // persist on user interaction should branch on `isUserInteraction` in
1879
2175
  // their own callback (see #716) rather than via this hook.
1880
- (d, h) => {
1881
- if (t && !h.isUserInteraction)
2176
+ (v, m) => {
2177
+ if (t && !m.isUserInteraction)
1882
2178
  return;
1883
- S();
1884
- let y;
1885
- s ? y = me(u, Object.keys(d)) : y = me(u, []);
2179
+ d();
2180
+ let g;
2181
+ s ? g = ve(i, Object.keys(v)) : g = ve(i, []);
1886
2182
  try {
1887
- o.setItem(y, JSON.stringify(d));
1888
- } catch (b) {
1889
- console.error(b);
2183
+ o.setItem(g, JSON.stringify(v));
2184
+ } catch (x) {
2185
+ console.error(x);
1890
2186
  }
1891
2187
  },
1892
2188
  [
1893
- S,
2189
+ d,
1894
2190
  s,
1895
- u,
2191
+ i,
1896
2192
  t,
1897
2193
  o
1898
2194
  ]
1899
- ), f = ie(
1900
- (d) => {
1901
- S(), e === 0 ? z(d, { isUserInteraction: !1 }) : p.current = setTimeout(() => {
1902
- z(d, { isUserInteraction: !1 });
2195
+ ), h = ce(
2196
+ (v) => {
2197
+ d(), e === 0 ? p(v, { isUserInteraction: !1 }) : y.current = setTimeout(() => {
2198
+ p(v, { isUserInteraction: !1 });
1903
2199
  }, e);
1904
2200
  },
1905
- [S, e, z]
2201
+ [d, e, p]
1906
2202
  );
1907
2203
  return {
1908
2204
  /**
1909
2205
  * Pass this value to `Group` as the `defaultLayout` prop.
1910
2206
  */
1911
- defaultLayout: m,
2207
+ defaultLayout: f,
1912
2208
  /**
1913
2209
  * Attach this callback on the `Group` as the `onLayoutChange` prop.
1914
2210
  *
1915
2211
  * @deprecated Use the {@link onLayoutChanged} prop instead.
1916
2212
  */
1917
- onLayoutChange: f,
2213
+ onLayoutChange: h,
1918
2214
  /**
1919
2215
  * Attach this callback on the `Group` as the `onLayoutChanged` prop.
1920
2216
  */
1921
- onLayoutChanged: z
2217
+ onLayoutChanged: p
1922
2218
  };
1923
2219
  }
1924
- function Jt() {
2220
+ function hn() {
1925
2221
  return function() {
1926
2222
  };
1927
2223
  }
1928
- function ln() {
1929
- return Q(null);
2224
+ function wn() {
2225
+ return Z(null);
1930
2226
  }
1931
- function un() {
2227
+ function Pn() {
1932
2228
  return O(null);
1933
2229
  }
1934
- function Me() {
1935
- const e = yt(ct);
1936
- return C(
1937
- e,
1938
- "Group Context not found; did you render a Panel or Separator outside of a Group?"
1939
- ), e;
1940
- }
1941
- function Zt(e, t) {
1942
- const { id: n } = Me(), o = O({
1943
- collapse: Se,
1944
- expand: Se,
2230
+ function mn(e, t) {
2231
+ const { id: n } = be(), o = O({
2232
+ collapse: we,
2233
+ expand: we,
1945
2234
  getSize: () => ({
1946
2235
  asPercentage: 0,
1947
2236
  inPixels: 0
1948
2237
  }),
1949
2238
  isCollapsed: () => !1,
1950
- resize: Se
2239
+ resize: we
1951
2240
  });
1952
- Xe(t, () => o.current, []), q(() => {
2241
+ et(t, () => o.current, []), V(() => {
1953
2242
  Object.assign(
1954
2243
  o.current,
1955
- at({ groupId: n, panelId: e })
2244
+ ht({ groupId: n, panelId: e })
1956
2245
  );
1957
2246
  });
1958
2247
  }
1959
- function Qt({
2248
+ function gn({
1960
2249
  children: e,
1961
2250
  className: t,
1962
2251
  collapsedSize: n = "0%",
1963
- collapsible: o = !1,
1964
- defaultSize: i,
1965
- disabled: s,
2252
+ collapsedThreshold: o,
2253
+ collapsible: r = !1,
2254
+ defaultSize: s,
2255
+ disabled: i,
1966
2256
  elementRef: u,
1967
- groupResizeBehavior: a = "preserve-relative-size",
1968
- id: r,
2257
+ groupResizeBehavior: c = "preserve-relative-size",
2258
+ id: a,
1969
2259
  maxSize: l = "100%",
1970
- minSize: c = "0%",
1971
- onResize: m,
1972
- panelRef: p,
1973
- style: S,
1974
- ...z
2260
+ minSize: f = "0%",
2261
+ onResize: y,
2262
+ panelRef: d,
2263
+ style: p,
2264
+ ...h
1975
2265
  }) {
1976
- const f = !!r, d = Ce(r), h = Ee({
1977
- disabled: s
1978
- }), y = O(null), b = Re(y, u), {
1979
- getPanelStyles: v,
1980
- id: g,
1981
- orientation: w,
1982
- registerPanel: E,
1983
- updatePanelProps: L
1984
- } = Me(), G = m !== null, N = re(
1985
- (R, M, k) => {
1986
- m?.(R, r, k);
2266
+ const v = !!a, m = Te(a), g = Oe({
2267
+ disabled: i
2268
+ }), x = O(null), b = De(x, u), {
2269
+ getPanelStyles: z,
2270
+ id: E,
2271
+ orientation: R,
2272
+ registerPanel: w,
2273
+ updatePanelProps: C
2274
+ } = be(), F = y !== null, I = ue(
2275
+ (S, P, k) => {
2276
+ y?.(S, a, k);
1987
2277
  }
1988
2278
  );
1989
- q(() => {
1990
- const R = y.current;
1991
- if (R !== null) {
1992
- const M = {
1993
- element: R,
1994
- id: d,
1995
- idIsStable: f,
2279
+ V(() => {
2280
+ const S = x.current;
2281
+ if (S !== null) {
2282
+ const P = {
2283
+ element: S,
2284
+ id: m,
2285
+ idIsStable: v,
1996
2286
  mutableValues: {
1997
2287
  expandToSize: void 0,
1998
2288
  prevSize: void 0
1999
2289
  },
2000
- onResize: G ? N : void 0,
2290
+ onResize: F ? I : void 0,
2001
2291
  panelConstraints: {
2002
- groupResizeBehavior: a,
2292
+ groupResizeBehavior: c,
2003
2293
  collapsedSize: n,
2004
- collapsible: o,
2005
- defaultSize: i,
2006
- disabled: h.disabled,
2294
+ collapsedThreshold: o,
2295
+ collapsible: r,
2296
+ defaultSize: s,
2297
+ disabled: g.disabled,
2007
2298
  maxSize: l,
2008
- minSize: c
2299
+ minSize: f
2009
2300
  }
2010
2301
  };
2011
- return E(M);
2302
+ return w(P);
2012
2303
  }
2013
2304
  }, [
2014
- a,
2305
+ c,
2015
2306
  n,
2016
2307
  o,
2017
- i,
2018
- G,
2019
- d,
2020
- f,
2308
+ r,
2309
+ s,
2310
+ F,
2311
+ m,
2312
+ v,
2021
2313
  l,
2022
- c,
2023
- N,
2024
- E,
2025
- h
2026
- ]), ge(() => {
2027
- L(d, { disabled: s });
2028
- }, [s, d, L]), Zt(d, p);
2029
- const x = () => {
2030
- const R = v(g, d);
2031
- if (R)
2032
- return JSON.stringify(R);
2033
- }, P = qe(
2034
- (R) => we(g, R),
2035
- x,
2036
- x
2314
+ f,
2315
+ I,
2316
+ w,
2317
+ g
2318
+ ]), Se(() => {
2319
+ C(m, { disabled: i });
2320
+ }, [i, m, C]), mn(m, d);
2321
+ const M = () => {
2322
+ const S = z(E, m);
2323
+ if (S)
2324
+ return JSON.stringify(S);
2325
+ }, N = tt(
2326
+ (S) => Ee(E, S),
2327
+ M,
2328
+ M
2037
2329
  );
2038
- let I;
2039
- return P ? I = JSON.parse(P) : i !== void 0 ? I = {
2330
+ let _;
2331
+ return N ? _ = JSON.parse(N) : s !== void 0 ? _ = {
2040
2332
  flexGrow: void 0,
2041
2333
  flexShrink: void 0,
2042
- flexBasis: i
2043
- } : I = { flexGrow: 1 }, /* @__PURE__ */ se(
2334
+ flexBasis: s
2335
+ } : _ = { flexGrow: 1 }, /* @__PURE__ */ U(
2044
2336
  "div",
2045
2337
  {
2046
- ...z,
2047
- "data-disabled": s || void 0,
2338
+ ...h,
2339
+ "data-disabled": i || void 0,
2048
2340
  "data-panel": !0,
2049
- "data-testid": d,
2050
- id: d,
2341
+ "data-testid": m,
2342
+ id: m,
2051
2343
  ref: b,
2052
2344
  style: {
2053
- ...en,
2345
+ ...yn,
2054
2346
  display: "flex",
2055
2347
  flexBasis: 0,
2056
2348
  flexShrink: 1,
2057
2349
  overflow: "visible",
2058
- ...I
2350
+ ..._
2059
2351
  },
2060
- children: /* @__PURE__ */ se(
2352
+ children: /* @__PURE__ */ U(
2061
2353
  "div",
2062
2354
  {
2063
2355
  className: t,
@@ -2066,12 +2358,12 @@ function Qt({
2066
2358
  maxWidth: "100%",
2067
2359
  flexGrow: 1,
2068
2360
  overflow: "auto",
2069
- ...S,
2361
+ ...p,
2070
2362
  // Inform the browser that the library is handling touch events for this element
2071
2363
  // but still allow users to scroll content within panels in the non-resizing direction
2072
2364
  // NOTE This is not an inherited style
2073
2365
  // See github.com/bvaughn/react-resizable-panels/issues/662
2074
- touchAction: w === "horizontal" ? "pan-y" : "pan-x"
2366
+ touchAction: R === "horizontal" ? "pan-y" : "pan-x"
2075
2367
  },
2076
2368
  children: e
2077
2369
  }
@@ -2079,8 +2371,8 @@ function Qt({
2079
2371
  }
2080
2372
  );
2081
2373
  }
2082
- Qt.displayName = "Panel";
2083
- const en = {
2374
+ gn.displayName = "Panel";
2375
+ const yn = {
2084
2376
  minHeight: 0,
2085
2377
  maxHeight: "100%",
2086
2378
  height: "auto",
@@ -2092,39 +2384,39 @@ const en = {
2092
2384
  padding: 0,
2093
2385
  margin: 0
2094
2386
  };
2095
- function cn() {
2096
- return Q(null);
2387
+ function Ln() {
2388
+ return Z(null);
2097
2389
  }
2098
- function fn() {
2390
+ function Cn() {
2099
2391
  return O(null);
2100
2392
  }
2101
- function tn({
2393
+ function vn({
2102
2394
  layout: e,
2103
2395
  panelConstraints: t,
2104
2396
  panelId: n,
2105
2397
  panelIndex: o
2106
2398
  }) {
2107
- let i, s;
2108
- const u = e[n], a = t.find(
2109
- (r) => r.panelId === n
2399
+ let r, s;
2400
+ const i = e[n], u = t.find(
2401
+ (c) => c.panelId === n
2110
2402
  );
2111
- if (a) {
2112
- const r = a.maxSize, l = a.collapsible ? a.collapsedSize : a.minSize, c = [o, o + 1];
2113
- s = X({
2114
- layout: ae({
2115
- delta: l - u,
2403
+ if (u) {
2404
+ const c = u.maxSize, a = u.collapsible ? u.collapsedSize : u.minSize, l = [o, o + 1];
2405
+ s = ne({
2406
+ layout: de({
2407
+ delta: a - i,
2116
2408
  initialLayout: e,
2117
2409
  panelConstraints: t,
2118
- pivotIndices: c,
2410
+ pivotIndices: l,
2119
2411
  prevLayout: e
2120
2412
  }),
2121
2413
  panelConstraints: t
2122
- })[n], i = X({
2123
- layout: ae({
2124
- delta: r - u,
2414
+ })[n], r = ne({
2415
+ layout: de({
2416
+ delta: c - i,
2125
2417
  initialLayout: e,
2126
2418
  panelConstraints: t,
2127
- pivotIndices: c,
2419
+ pivotIndices: l,
2128
2420
  prevLayout: e
2129
2421
  }),
2130
2422
  panelConstraints: t
@@ -2132,109 +2424,131 @@ function tn({
2132
2424
  }
2133
2425
  return {
2134
2426
  valueControls: n,
2135
- valueMax: i,
2427
+ valueMax: r,
2136
2428
  valueMin: s,
2137
- valueNow: u
2429
+ valueNow: i
2138
2430
  };
2139
2431
  }
2140
- function nn({
2432
+ function Sn({
2141
2433
  children: e,
2142
2434
  className: t,
2143
2435
  disabled: n,
2144
2436
  disableDoubleClick: o,
2145
- elementRef: i,
2437
+ elementRef: r,
2146
2438
  id: s,
2439
+ preview: i,
2147
2440
  style: u,
2148
- ...a
2441
+ ...c
2149
2442
  }) {
2150
- const r = Ce(s), l = Ee({
2443
+ const a = Te(s), l = Oe({
2151
2444
  disabled: n,
2152
- disableDoubleClick: o
2153
- }), [c, m] = Q({}), [p, S] = Q("inactive"), [z, f] = Q(!1), d = O(null), h = Re(d, i), {
2154
- disableCursor: y,
2155
- id: b,
2156
- orientation: v,
2157
- registerSeparator: g,
2445
+ disableDoubleClick: o,
2446
+ children: e,
2447
+ className: t,
2448
+ preview: i,
2449
+ style: u
2450
+ }), [f, y] = Z({}), [d, p] = Z("inactive"), [h, v] = Z(!1), m = O(null), g = O(null), x = De(m, r), {
2451
+ disableCursor: b,
2452
+ id: z,
2453
+ orientation: E,
2454
+ registerSeparator: R,
2158
2455
  updateSeparatorProps: w
2159
- } = Me(), E = v === "horizontal" ? "vertical" : "horizontal";
2160
- q(() => {
2161
- const N = d.current;
2162
- if (N !== null) {
2163
- const x = {
2456
+ } = be(), C = E === "horizontal" ? "vertical" : "horizontal";
2457
+ V(() => {
2458
+ const M = m.current;
2459
+ if (M !== null) {
2460
+ const N = {
2164
2461
  disabled: l.disabled,
2165
2462
  disableDoubleClick: l.disableDoubleClick,
2166
- element: N,
2167
- id: r
2168
- }, P = g(x), I = Rt(
2169
- (M) => {
2170
- S(
2171
- M.next.state !== "inactive" && M.next.hitRegions.some(
2172
- (k) => k.separator === x
2173
- ) ? M.next.state : "inactive"
2463
+ element: M,
2464
+ id: a,
2465
+ get children() {
2466
+ return l.children;
2467
+ },
2468
+ get className() {
2469
+ return l.className;
2470
+ },
2471
+ get preview() {
2472
+ return l.preview;
2473
+ },
2474
+ get style() {
2475
+ return l.style;
2476
+ }
2477
+ };
2478
+ g.current = N;
2479
+ const _ = R(N), S = ot(
2480
+ (k) => {
2481
+ p(
2482
+ k.next.state !== "inactive" && k.next.hitRegions.some(
2483
+ (G) => G.separator === N
2484
+ ) ? k.next.state : "inactive"
2174
2485
  );
2175
2486
  }
2176
- ), R = we(
2177
- b,
2178
- (M) => {
2179
- const { derivedPanelConstraints: k, layout: U, separatorToPanels: le } = M.next, ue = le.get(x);
2180
- if (ue) {
2181
- const _ = ue[0], Y = k.findIndex(
2182
- (ce) => ce.panelId === _.id
2487
+ ), P = Ee(
2488
+ z,
2489
+ (k) => {
2490
+ const { derivedPanelConstraints: G, layout: $, separatorToPanels: Y } = k.next, oe = Y.get(N);
2491
+ if (oe) {
2492
+ const le = oe[0], xe = G.findIndex(
2493
+ (J) => J.panelId === le.id
2183
2494
  );
2184
- m(
2185
- tn({
2186
- layout: U,
2187
- panelConstraints: k,
2188
- panelId: _.id,
2189
- panelIndex: Y
2495
+ y(
2496
+ vn({
2497
+ layout: $,
2498
+ panelConstraints: G,
2499
+ panelId: le.id,
2500
+ panelIndex: xe
2190
2501
  })
2191
2502
  );
2192
2503
  }
2193
2504
  }
2194
2505
  );
2195
2506
  return () => {
2196
- I(), R(), P();
2507
+ g.current = null, S(), P(), _();
2197
2508
  };
2198
2509
  }
2199
- }, [b, r, g, l]), ge(() => {
2200
- w(r, { disabled: n, disableDoubleClick: o });
2201
- }, [n, o, r, w]);
2202
- let L;
2203
- n && !y && (L = "not-allowed");
2204
- let G;
2510
+ }, [z, a, R, l]), V(() => {
2511
+ const M = g.current;
2512
+ M && Ot(M);
2513
+ }, [i]), Se(() => {
2514
+ w(a, { disabled: n, disableDoubleClick: o });
2515
+ }, [n, o, a, w]);
2516
+ let F;
2517
+ n && !b && (F = "not-allowed");
2518
+ let I;
2205
2519
  if (n)
2206
- G = "disabled";
2520
+ I = "disabled";
2207
2521
  else
2208
- switch (p) {
2522
+ switch (d) {
2209
2523
  case "active": {
2210
- G = "active";
2524
+ I = "active";
2211
2525
  break;
2212
2526
  }
2213
2527
  default:
2214
- z ? G = "focus" : G = p;
2528
+ h ? I = "focus" : I = d;
2215
2529
  }
2216
- return /* @__PURE__ */ se(
2530
+ return /* @__PURE__ */ U(
2217
2531
  "div",
2218
2532
  {
2219
- ...a,
2220
- "aria-controls": c.valueControls,
2533
+ ...c,
2534
+ "aria-controls": f.valueControls,
2221
2535
  "aria-disabled": n || void 0,
2222
- "aria-orientation": E,
2223
- "aria-valuemax": c.valueMax,
2224
- "aria-valuemin": c.valueMin,
2225
- "aria-valuenow": c.valueNow,
2536
+ "aria-orientation": C,
2537
+ "aria-valuemax": f.valueMax,
2538
+ "aria-valuemin": f.valueMin,
2539
+ "aria-valuenow": f.valueNow,
2226
2540
  children: e,
2227
2541
  className: t,
2228
- "data-separator": G,
2229
- "data-testid": r,
2230
- id: r,
2231
- onBlur: () => f(!1),
2232
- onFocus: () => f(!0),
2233
- ref: h,
2542
+ "data-separator": I,
2543
+ "data-testid": a,
2544
+ id: a,
2545
+ onBlur: () => v(!1),
2546
+ onFocus: () => v(!0),
2547
+ ref: x,
2234
2548
  role: "separator",
2235
2549
  style: {
2236
2550
  flexBasis: "auto",
2237
- cursor: L,
2551
+ cursor: F,
2238
2552
  ...u,
2239
2553
  flexGrow: 0,
2240
2554
  flexShrink: 0,
@@ -2246,16 +2560,17 @@ function nn({
2246
2560
  }
2247
2561
  );
2248
2562
  }
2249
- nn.displayName = "Separator";
2563
+ Sn.displayName = "Separator";
2250
2564
  export {
2251
- qt as Group,
2252
- Qt as Panel,
2253
- nn as Separator,
2254
- Ct as isCoarsePointer,
2255
- an as useDefaultLayout,
2256
- ln as useGroupCallbackRef,
2257
- un as useGroupRef,
2258
- cn as usePanelCallbackRef,
2259
- fn as usePanelRef
2565
+ dn as Group,
2566
+ gn as Panel,
2567
+ Sn as Separator,
2568
+ vt as SeparatorOverlay,
2569
+ Ht as isCoarsePointer,
2570
+ zn as useDefaultLayout,
2571
+ wn as useGroupCallbackRef,
2572
+ Pn as useGroupRef,
2573
+ Ln as usePanelCallbackRef,
2574
+ Cn as usePanelRef
2260
2575
  };
2261
2576
  //# sourceMappingURL=react-resizable-panels.js.map