react-panel-layout 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +291 -0
  2. package/dist/FloatingPanelFrame-DDT6aING.js +66 -0
  3. package/dist/FloatingPanelFrame-DDT6aING.js.map +1 -0
  4. package/dist/FloatingPanelFrame-DrYwgI9f.cjs +2 -0
  5. package/dist/FloatingPanelFrame-DrYwgI9f.cjs.map +1 -0
  6. package/dist/GridLayout-DC7fCmcI.cjs +2 -0
  7. package/dist/GridLayout-DC7fCmcI.cjs.map +1 -0
  8. package/dist/GridLayout-tpSM0iM-.js +1460 -0
  9. package/dist/GridLayout-tpSM0iM-.js.map +1 -0
  10. package/dist/components/grid/GridLayout.d.ts +5 -0
  11. package/dist/components/pivot/PivotLayer.d.ts +14 -0
  12. package/dist/components/window/FloatingWindow.d.ts +15 -0
  13. package/dist/config/PanelContentDeclaration.d.ts +20 -0
  14. package/dist/config/panelRouter.d.ts +4 -2
  15. package/dist/config.cjs +1 -1
  16. package/dist/config.cjs.map +1 -1
  17. package/dist/config.js +125 -76
  18. package/dist/config.js.map +1 -1
  19. package/dist/constants/styles.d.ts +8 -0
  20. package/dist/floating.cjs +1 -1
  21. package/dist/floating.js +1 -1
  22. package/dist/index.cjs +2 -2
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.ts +4 -1
  25. package/dist/index.js +996 -853
  26. package/dist/index.js.map +1 -1
  27. package/dist/modules/grid/GridLayoutContext.d.ts +5 -0
  28. package/dist/modules/grid/resizeHandles.d.ts +14 -0
  29. package/dist/modules/grid/trackUtils.d.ts +29 -0
  30. package/dist/modules/grid/useGridTracks.d.ts +6 -15
  31. package/dist/modules/grid/useLayerInteractions.d.ts +2 -1
  32. package/dist/modules/panels/rendering/ContentRegistry.d.ts +50 -0
  33. package/dist/modules/panels/rendering/RenderContext.d.ts +1 -0
  34. package/dist/modules/panels/state/types.d.ts +2 -2
  35. package/dist/modules/pivot/PivotContent.d.ts +29 -0
  36. package/dist/modules/pivot/index.d.ts +5 -0
  37. package/dist/modules/pivot/types.d.ts +62 -0
  38. package/dist/modules/pivot/usePivot.d.ts +28 -0
  39. package/dist/modules/window/useFloatingState.d.ts +9 -0
  40. package/dist/pivot/index.d.ts +8 -0
  41. package/dist/pivot.cjs +2 -0
  42. package/dist/pivot.cjs.map +1 -0
  43. package/dist/pivot.js +5 -0
  44. package/dist/pivot.js.map +1 -0
  45. package/dist/styles-DcG3aIFx.cjs +2 -0
  46. package/dist/styles-DcG3aIFx.cjs.map +1 -0
  47. package/dist/styles-w0ZixggV.js +51 -0
  48. package/dist/styles-w0ZixggV.js.map +1 -0
  49. package/dist/types.d.ts +106 -4
  50. package/dist/usePivot-C8q0pMgW.cjs +2 -0
  51. package/dist/usePivot-C8q0pMgW.cjs.map +1 -0
  52. package/dist/usePivot-z9gumDf-.js +97 -0
  53. package/dist/usePivot-z9gumDf-.js.map +1 -0
  54. package/dist/utils/css.d.ts +19 -0
  55. package/package.json +6 -1
  56. package/dist/FloatingPanelFrame-BeP9z8EI.js +0 -98
  57. package/dist/FloatingPanelFrame-BeP9z8EI.js.map +0 -1
  58. package/dist/FloatingPanelFrame-Cu50Y9xg.cjs +0 -2
  59. package/dist/FloatingPanelFrame-Cu50Y9xg.cjs.map +0 -1
  60. package/dist/GridLayout-CwuQEP7k.cjs +0 -2
  61. package/dist/GridLayout-CwuQEP7k.cjs.map +0 -1
  62. package/dist/GridLayout-DZCV1X-3.js +0 -1338
  63. package/dist/GridLayout-DZCV1X-3.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,22 +1,24 @@
1
- import { u as Rt, a as Pt, b as Ct, c as J, d as Dt, e as _, f as At, t as kt, R as nt, G as ot } from "./GridLayout-DZCV1X-3.js";
2
- import { D as vr, g as Ir, r as wr, h as yr } from "./GridLayout-DZCV1X-3.js";
1
+ import { u as kt, a as Mt, b as _t, c as J, d as Ot, e as M, t as Bt, R as ot, G as st } from "./GridLayout-tpSM0iM-.js";
2
+ import { D as kn, f as Mn, F as _n, r as On, g as Bn } from "./GridLayout-tpSM0iM-.js";
3
3
  import { jsx as m, jsxs as H, Fragment as et } from "react/jsx-runtime";
4
4
  import * as l from "react";
5
- import { m as _t, n as Mt, o as Ot, H as Bt, r as Lt, s as $t, t as Ht, u as Nt, v as zt, w as Xt, T as Yt, x as Ft, y as jt, z as Vt, A as Kt, B as Ut, E as qt, S as Wt } from "./FloatingPanelFrame-BeP9z8EI.js";
6
- import { I as Gr } from "./FloatingPanelFrame-BeP9z8EI.js";
7
- const Zt = (t) => ({
8
- width: Bt,
5
+ import { t as Lt, u as Ht, v as Nt, H as zt, y as $t, z as Ft, A as Xt, B as Yt, E as jt, I as Kt, T as Ut, J as Vt, K as Wt, L as qt, M as Zt, N as Jt, O as Qt, S as te } from "./styles-w0ZixggV.js";
6
+ import { Q as Hn } from "./styles-w0ZixggV.js";
7
+ import { a as nt } from "./usePivot-z9gumDf-.js";
8
+ import { createPortal as ee } from "react-dom";
9
+ const ne = (t) => ({
10
+ width: zt,
9
11
  cursor: "col-resize",
10
12
  position: "relative",
11
13
  userSelect: "none",
12
- backgroundColor: t === "drag" ? _t : t === "hover" ? Mt : Ot
13
- }), pr = ({ onResize: t, component: e, element: r }) => {
14
- const { ref: n, isDragging: o, onPointerDown: s } = Rt({
14
+ backgroundColor: t === "drag" ? Lt : t === "hover" ? Ht : Nt
15
+ }), Gn = ({ onResize: t, component: e, element: n }) => {
16
+ const { ref: r, isDragging: o, onPointerDown: s } = kt({
15
17
  axis: "x",
16
18
  onResize: t
17
19
  }), [a, i] = l.useState(!1), c = {
18
- ref: n,
19
- style: Zt(o ? "drag" : a ? "hover" : "idle"),
20
+ ref: r,
21
+ style: ne(o ? "drag" : a ? "hover" : "idle"),
20
22
  role: "separator",
21
23
  "aria-orientation": "vertical",
22
24
  "data-dragging": o ? "true" : void 0,
@@ -24,78 +26,146 @@ const Zt = (t) => ({
24
26
  onPointerEnter: () => i(!0),
25
27
  onPointerLeave: () => i(!1)
26
28
  };
27
- return r ? l.cloneElement(r, c) : e ? /* @__PURE__ */ m(e, { ...c }) : /* @__PURE__ */ m("div", { ...c });
28
- }, fr = () => {
29
- const { layerId: t } = Pt(), { getLayerHandleProps: e } = Ct();
29
+ return n ? l.cloneElement(n, c) : e ? /* @__PURE__ */ m(e, { ...c }) : /* @__PURE__ */ m("div", { ...c });
30
+ }, Cn = () => {
31
+ const { layerId: t } = Mt(), { getLayerHandleProps: e } = _t();
30
32
  return l.useMemo(() => e(t), [e, t]);
31
- }, lt = l.createContext(null), Jt = () => {
32
- const t = l.useContext(lt);
33
+ }, it = { left: 0, top: 0 }, at = { width: 400, height: 300 }, En = (t) => {
34
+ const [e, n] = l.useState(() => {
35
+ const u = {};
36
+ return t.forEach((p) => {
37
+ if (p.floating) {
38
+ const g = p.floating;
39
+ u[p.id] = {
40
+ position: g.defaultPosition ?? it,
41
+ size: g.defaultSize ?? at
42
+ };
43
+ }
44
+ }), u;
45
+ }), r = l.useMemo(() => {
46
+ const u = /* @__PURE__ */ new Map();
47
+ return t.forEach((p) => u.set(p.id, p)), u;
48
+ }, [t]), o = l.useCallback(
49
+ (u) => {
50
+ const p = r.get(u);
51
+ return p?.floating?.position !== void 0 ? p.floating.position : e[u]?.position ?? it;
52
+ },
53
+ [r, e]
54
+ ), s = l.useCallback(
55
+ (u) => {
56
+ const p = r.get(u);
57
+ return p?.floating?.size !== void 0 ? p.floating.size : e[u]?.size ?? at;
58
+ },
59
+ [r, e]
60
+ ), a = l.useCallback(
61
+ (u) => r.get(u)?.floating?.zIndex,
62
+ [r]
63
+ ), i = l.useCallback(
64
+ (u, p) => {
65
+ const g = r.get(u);
66
+ g?.floating && (g.floating.position === void 0 && n((v) => {
67
+ const h = v[u];
68
+ return h ? {
69
+ ...v,
70
+ [u]: { ...h, position: p }
71
+ } : v;
72
+ }), g.floating.onMove?.(p));
73
+ },
74
+ [r]
75
+ ), c = l.useCallback(
76
+ (u, p) => {
77
+ const g = r.get(u);
78
+ g?.floating && (g.floating.size === void 0 && n((v) => {
79
+ const h = v[u];
80
+ return h ? {
81
+ ...v,
82
+ [u]: { ...h, size: p }
83
+ } : v;
84
+ }), g.floating.onResize?.(p));
85
+ },
86
+ [r]
87
+ ), d = l.useCallback(
88
+ (u) => {
89
+ r.get(u)?.floating?.onClose?.();
90
+ },
91
+ [r]
92
+ );
93
+ return {
94
+ getPosition: o,
95
+ getSize: s,
96
+ getZIndex: a,
97
+ updatePosition: i,
98
+ updateSize: c,
99
+ close: d
100
+ };
101
+ }, ft = l.createContext(null), re = () => {
102
+ const t = l.useContext(ft);
33
103
  if (!t)
34
104
  throw new Error("useKeybindings must be used within KeybindingsProvider");
35
105
  return t;
36
- }, Qt = (t) => {
106
+ }, oe = (t) => {
37
107
  const e = [];
38
108
  t.metaKey && e.push("Mod"), t.ctrlKey && e.push("Ctrl"), t.altKey && e.push("Alt"), t.shiftKey && e.push("Shift");
39
- const r = t.key.length === 1 ? t.key.toUpperCase() : t.key;
40
- return e.push(r), e.join("-");
41
- }, te = ({ children: t, configure: e }) => {
42
- const r = l.useRef({}), n = l.useCallback((a, i) => {
43
- r.current = { ...r.current, [a]: i };
109
+ const n = t.key.length === 1 ? t.key.toUpperCase() : t.key;
110
+ return e.push(n), e.join("-");
111
+ }, se = ({ children: t, configure: e }) => {
112
+ const n = l.useRef({}), r = l.useCallback((a, i) => {
113
+ n.current = { ...n.current, [a]: i };
44
114
  }, []), o = l.useCallback((a) => {
45
- const i = { ...r.current };
46
- delete i[a], r.current = i;
115
+ const i = { ...n.current };
116
+ delete i[a], n.current = i;
47
117
  }, []);
48
118
  l.useEffect(() => {
49
119
  const a = (i) => {
50
- const c = Qt(i), u = r.current[c];
51
- u && u(i);
120
+ const c = oe(i), d = n.current[c];
121
+ d && d(i);
52
122
  };
53
123
  return window.addEventListener("keydown", a), () => {
54
124
  window.removeEventListener("keydown", a);
55
125
  };
56
126
  }, []);
57
- const s = l.useMemo(() => ({ register: n, unregister: o }), [n, o]);
127
+ const s = l.useMemo(() => ({ register: r, unregister: o }), [r, o]);
58
128
  return l.useEffect(() => {
59
129
  e && e(s);
60
- }, [s, e]), /* @__PURE__ */ m(lt.Provider, { value: s, children: t });
61
- }, ee = (t, e) => {
62
- t.register("Mod-\\", (r) => {
63
- r.preventDefault(), e.splitFocused("vertical");
64
- }), t.register("Mod-Shift-\\", (r) => {
65
- r.preventDefault(), e.splitFocused("horizontal");
130
+ }, [s, e]), /* @__PURE__ */ m(ft.Provider, { value: s, children: t });
131
+ }, ie = (t, e) => {
132
+ t.register("Mod-\\", (n) => {
133
+ n.preventDefault(), e.splitFocused("vertical");
134
+ }), t.register("Mod-Shift-\\", (n) => {
135
+ n.preventDefault(), e.splitFocused("horizontal");
66
136
  });
67
- for (const r of [1, 2, 3, 4, 5, 6, 7, 8, 9])
68
- t.register(`Mod-${String(r)}`, (n) => {
69
- n.preventDefault(), e.focusGroupIndex(r);
137
+ for (const n of [1, 2, 3, 4, 5, 6, 7, 8, 9])
138
+ t.register(`Mod-${String(n)}`, (r) => {
139
+ r.preventDefault(), e.focusGroupIndex(n);
70
140
  });
71
- t.register("Alt-ArrowRight", (r) => {
72
- r.preventDefault(), e.focusNextGroup();
73
- }), t.register("Alt-ArrowLeft", (r) => {
74
- r.preventDefault(), e.focusPrevGroup();
141
+ t.register("Alt-ArrowRight", (n) => {
142
+ n.preventDefault(), e.focusNextGroup();
143
+ }), t.register("Alt-ArrowLeft", (n) => {
144
+ n.preventDefault(), e.focusPrevGroup();
75
145
  });
76
- }, re = (t) => t.type === "group", dt = (t, e = { x: 0, y: 0, w: 100, h: 100 }) => {
77
- const r = /* @__PURE__ */ new Map(), n = (o, s) => {
78
- if (re(o)) {
79
- r.set(o.groupId, s);
146
+ }, ae = (t) => t.type === "group", gt = (t, e = { x: 0, y: 0, w: 100, h: 100 }) => {
147
+ const n = /* @__PURE__ */ new Map(), r = (o, s) => {
148
+ if (ae(o)) {
149
+ n.set(o.groupId, s);
80
150
  return;
81
151
  }
82
152
  if (o.direction === "vertical") {
83
- const c = s.w * o.ratio, u = s.w - c;
84
- n(o.a, { x: s.x, y: s.y, w: c, h: s.h }), n(o.b, { x: s.x + c, y: s.y, w: u, h: s.h });
153
+ const c = s.w * o.ratio, d = s.w - c;
154
+ r(o.a, { x: s.x, y: s.y, w: c, h: s.h }), r(o.b, { x: s.x + c, y: s.y, w: d, h: s.h });
85
155
  return;
86
156
  }
87
157
  const a = s.h * o.ratio, i = s.h - a;
88
- n(o.a, { x: s.x, y: s.y, w: s.w, h: a }), n(o.b, { x: s.x, y: s.y + a, w: s.w, h: i });
158
+ r(o.a, { x: s.x, y: s.y, w: s.w, h: a }), r(o.b, { x: s.x, y: s.y + a, w: s.w, h: i });
89
159
  };
90
- return n(t, e), r;
91
- }, ne = (t, e) => {
92
- const r = dt(t.tree), n = {
160
+ return r(t, e), n;
161
+ }, ce = (t, e) => {
162
+ const n = gt(t.tree), r = {
93
163
  areas: [["root"]],
94
164
  rows: [{ size: "1fr" }],
95
165
  columns: [{ size: "1fr" }],
96
166
  gap: "0px",
97
167
  style: { position: "relative" }
98
- }, o = Array.from(r.entries()).map(([s, a]) => {
168
+ }, o = Array.from(n.entries()).map(([s, a]) => {
99
169
  const i = {
100
170
  position: "absolute",
101
171
  left: `${a.x}%`,
@@ -113,167 +183,167 @@ const Zt = (t) => ({
113
183
  component: e(s)
114
184
  };
115
185
  });
116
- return { config: n, layers: o };
117
- }, oe = (t, e, r) => {
118
- const n = dt(t.tree), o = Array.from(new Set(Array.from(n.values()).flatMap((h) => [h.x, h.x + h.w]))).sort((h, w) => h - w), s = Array.from(new Set(Array.from(n.values()).flatMap((h) => [h.y, h.y + h.h]))).sort((h, w) => h - w), a = o.slice(1).map((h, w) => `${h - o[w]}fr`), i = s.slice(1).map((h, w) => `${h - s[w]}fr`), c = a.map((h) => ({ size: h, resizable: r })), u = i.map((h) => ({ size: h, resizable: r })), d = (h, w, b, y) => {
119
- for (const [f, I] of n.entries())
120
- if (h >= I.x && w <= I.x + I.w && b >= I.y && y <= I.y + I.h)
121
- return f;
186
+ return { config: r, layers: o };
187
+ }, ue = (t, e, n) => {
188
+ const r = gt(t.tree), o = Array.from(new Set(Array.from(r.values()).flatMap((h) => [h.x, h.x + h.w]))).sort((h, y) => h - y), s = Array.from(new Set(Array.from(r.values()).flatMap((h) => [h.y, h.y + h.h]))).sort((h, y) => h - y), a = o.slice(1).map((h, y) => `${h - o[y]}fr`), i = s.slice(1).map((h, y) => `${h - s[y]}fr`), c = a.map((h) => ({ size: h, resizable: n })), d = i.map((h) => ({ size: h, resizable: n })), u = (h, y, w, T) => {
189
+ for (const [b, I] of r.entries())
190
+ if (h >= I.x && y <= I.x + I.w && w >= I.y && T <= I.y + I.h)
191
+ return b;
122
192
  return ".";
123
- }, g = [];
193
+ }, p = [];
124
194
  for (let h = 0; h < s.length - 1; h += 1) {
125
- const w = [];
126
- for (let b = 0; b < o.length - 1; b += 1)
127
- w.push(d(o[b], o[b + 1], s[h], s[h + 1]));
128
- g.push(w);
195
+ const y = [];
196
+ for (let w = 0; w < o.length - 1; w += 1)
197
+ y.push(u(o[w], o[w + 1], s[h], s[h + 1]));
198
+ p.push(y);
129
199
  }
130
- const v = {
131
- areas: g,
132
- rows: u,
200
+ const g = {
201
+ areas: p,
202
+ rows: d,
133
203
  columns: c,
134
204
  gap: "0px"
135
- }, T = Array.from(n.keys()).map((h) => ({
205
+ }, v = Array.from(r.keys()).map((h) => ({
136
206
  id: h,
137
207
  gridArea: h,
138
208
  component: e(h)
139
209
  }));
140
- return { config: v, layers: T };
141
- }, pt = l.createContext(null), se = () => {
142
- const t = l.useContext(pt);
210
+ return { config: g, layers: v };
211
+ }, bt = l.createContext(null), le = () => {
212
+ const t = l.useContext(bt);
143
213
  if (!t)
144
214
  throw new Error("usePanelRenderContext must be used within PanelRenderProvider");
145
215
  return t;
146
- }, ie = ({ value: t, children: e }) => /* @__PURE__ */ m(pt.Provider, { value: t, children: e }), ft = l.createContext(null), bt = () => {
147
- const t = l.useContext(ft);
216
+ }, de = ({ value: t, children: e }) => /* @__PURE__ */ m(bt.Provider, { value: t, children: e }), ht = l.createContext(null), mt = () => {
217
+ const t = l.useContext(ht);
148
218
  if (!t)
149
219
  throw new Error("useDomRegistry must be used within DomRegistryProvider");
150
220
  return t;
151
- }, ae = ({ children: t }) => {
152
- const e = l.useRef(/* @__PURE__ */ new Map()), r = l.useCallback((c) => {
153
- const u = e.current.get(c);
154
- if (u)
155
- return u;
156
- const d = { group: null, tabbar: null, content: null };
157
- return e.current.set(c, d), d;
158
- }, []), n = l.useCallback(
159
- (c, u) => {
160
- const d = r(c);
161
- if (d.group = u, u === null) {
162
- const g = e.current.get(c);
163
- (g ? g.tabbar === null && g.content === null : !1) && e.current.delete(c);
221
+ }, pe = ({ children: t }) => {
222
+ const e = l.useRef(/* @__PURE__ */ new Map()), n = l.useCallback((c) => {
223
+ const d = e.current.get(c);
224
+ if (d)
225
+ return d;
226
+ const u = { group: null, tabbar: null, content: null };
227
+ return e.current.set(c, u), u;
228
+ }, []), r = l.useCallback(
229
+ (c, d) => {
230
+ const u = n(c);
231
+ if (u.group = d, d === null) {
232
+ const p = e.current.get(c);
233
+ (p ? p.tabbar === null && p.content === null : !1) && e.current.delete(c);
164
234
  }
165
235
  },
166
- [r]
236
+ [n]
167
237
  ), o = l.useCallback(
168
- (c, u) => {
169
- const d = r(c);
170
- if (d.tabbar = u, u === null) {
171
- const g = e.current.get(c);
172
- (g ? g.group === null && g.content === null : !1) && e.current.delete(c);
238
+ (c, d) => {
239
+ const u = n(c);
240
+ if (u.tabbar = d, d === null) {
241
+ const p = e.current.get(c);
242
+ (p ? p.group === null && p.content === null : !1) && e.current.delete(c);
173
243
  }
174
244
  },
175
- [r]
245
+ [n]
176
246
  ), s = l.useCallback(
177
- (c, u) => {
178
- const d = r(c);
179
- if (d.content = u, u === null) {
180
- const g = e.current.get(c);
181
- (g ? g.group === null && g.tabbar === null : !1) && e.current.delete(c);
247
+ (c, d) => {
248
+ const u = n(c);
249
+ if (u.content = d, d === null) {
250
+ const p = e.current.get(c);
251
+ (p ? p.group === null && p.tabbar === null : !1) && e.current.delete(c);
182
252
  }
183
253
  },
184
- [r]
185
- ), a = l.useCallback(() => e.current, []), i = l.useMemo(() => ({ setGroupEl: n, setTabbarEl: o, setContentEl: s, getAll: a }), [n, o, s, a]);
186
- return /* @__PURE__ */ m(ft.Provider, { value: i, children: t });
187
- }, ce = {
254
+ [n]
255
+ ), a = l.useCallback(() => e.current, []), i = l.useMemo(() => ({ setGroupEl: r, setTabbarEl: o, setContentEl: s, getAll: a }), [r, o, s, a]);
256
+ return /* @__PURE__ */ m(ht.Provider, { value: i, children: t });
257
+ }, fe = {
188
258
  display: "flex",
189
259
  flexDirection: "column",
190
260
  width: "100%",
191
261
  height: "100%"
192
- }, ue = {
262
+ }, ge = {
193
263
  flex: "1 1 auto",
194
264
  minWidth: 0,
195
265
  minHeight: 0,
196
266
  position: "relative",
197
267
  overflow: "hidden"
198
268
  };
199
- function le(t, e, r, n) {
200
- return t ? l.cloneElement(t, r, n) : e ? /* @__PURE__ */ m(e, { ...r, children: n }) : /* @__PURE__ */ m("div", { ...r, children: n });
269
+ function be(t, e, n, r) {
270
+ return t ? l.cloneElement(t, n, r) : e ? /* @__PURE__ */ m(e, { ...n, children: r }) : /* @__PURE__ */ m("div", { ...n, children: r });
201
271
  }
202
- function de(t, e, r, n) {
203
- return t ? l.cloneElement(t, r, n) : e ? /* @__PURE__ */ m(e, { ...r, children: n }) : /* @__PURE__ */ m("div", { ...r, children: n });
272
+ function he(t, e, n, r) {
273
+ return t ? l.cloneElement(t, n, r) : e ? /* @__PURE__ */ m(e, { ...n, children: r }) : /* @__PURE__ */ m("div", { ...n, children: r });
204
274
  }
205
- const pe = ({
275
+ const me = ({
206
276
  group: t,
207
277
  tabbar: e,
208
- content: r,
209
- onContentPointerDown: n,
278
+ content: n,
279
+ onContentPointerDown: r,
210
280
  groupRef: o,
211
281
  contentRef: s,
212
282
  component: a,
213
283
  element: i,
214
284
  contentComponent: c,
215
- contentElement: u
285
+ contentElement: d
216
286
  }) => {
217
- const d = {
287
+ const u = {
218
288
  ref: o,
219
- style: ce,
289
+ style: fe,
220
290
  "data-group-id": t.id
221
- }, v = le(u, c, {
291
+ }, g = be(d, c, {
222
292
  ref: s,
223
- style: ue,
293
+ style: ge,
224
294
  "data-dnd-zone": "content",
225
- onPointerDown: n
226
- }, r);
227
- return de(i, a, d, /* @__PURE__ */ H(et, { children: [
295
+ onPointerDown: r
296
+ }, n);
297
+ return he(i, a, u, /* @__PURE__ */ H(et, { children: [
228
298
  e,
229
- v
299
+ g
230
300
  ] }));
231
- }, gt = l.memo(pe, (t, e) => t.group.id !== e.group.id || t.group.activeTabId !== e.group.activeTabId || t.group.tabs.length !== e.group.tabs.length ? !1 : t.group.tabs === e.group.tabs);
232
- gt.displayName = "PanelGroupView";
233
- const V = (t, e, r) => {
234
- const n = t.left, o = t.top, s = t.width, a = t.height, i = e - n, c = r - o, u = s / 3, d = a / 3;
235
- return i > u && i < s - u && c > d && c < a - d ? "center" : i < c && i < s - i && c < a - c ? "left" : s - i < c && s - i < i && c < a - c ? "right" : c < i && c < a - c && i < s - i ? "top" : "bottom";
301
+ }, vt = l.memo(me, (t, e) => t.group.id !== e.group.id || t.group.activeTabId !== e.group.activeTabId || t.group.tabs.length !== e.group.tabs.length ? !1 : t.group.tabs === e.group.tabs);
302
+ vt.displayName = "PanelGroupView";
303
+ const K = (t, e, n) => {
304
+ const r = t.left, o = t.top, s = t.width, a = t.height, i = e - r, c = n - o, d = s / 3, u = a / 3;
305
+ return i > d && i < s - d && c > u && c < a - u ? "center" : i < c && i < s - i && c < a - c ? "left" : s - i < c && s - i < i && c < a - c ? "right" : c < i && c < a - c && i < s - i ? "top" : "bottom";
236
306
  };
237
307
  function A(t, e) {
238
308
  if (!e) {
239
- const n = (() => ({ type: t }));
240
- return Object.defineProperty(n, "type", {
309
+ const r = (() => ({ type: t }));
310
+ return Object.defineProperty(r, "type", {
241
311
  value: t,
242
312
  writable: !1,
243
313
  enumerable: !0
244
- }), n;
314
+ }), r;
245
315
  }
246
- const r = ((...n) => {
247
- const o = e(...n);
316
+ const n = ((...r) => {
317
+ const o = e(...r);
248
318
  return typeof o > "u" ? { type: t } : { type: t, payload: o };
249
319
  });
250
- return Object.defineProperty(r, "type", {
320
+ return Object.defineProperty(n, "type", {
251
321
  value: t,
252
322
  writable: !1,
253
323
  enumerable: !0
254
- }), r;
324
+ }), n;
255
325
  }
256
- const fe = (t, e) => {
257
- const r = {};
258
- return Object.keys(t).forEach((n) => {
259
- const o = t[n];
260
- r[n] = ((...s) => {
326
+ const ve = (t, e) => {
327
+ const n = {};
328
+ return Object.keys(t).forEach((r) => {
329
+ const o = t[r];
330
+ n[r] = ((...s) => {
261
331
  const a = o(...s);
262
332
  return e(a), a;
263
333
  });
264
- }), r;
265
- }, ht = (t, e) => {
266
- const r = {};
267
- return Object.keys(e).forEach((n) => {
268
- const o = e[n];
334
+ }), n;
335
+ }, It = (t, e) => {
336
+ const n = {};
337
+ return Object.keys(e).forEach((r) => {
338
+ const o = e[r];
269
339
  if (!o)
270
340
  return;
271
- const s = t[n];
341
+ const s = t[r];
272
342
  if (!s)
273
- throw new Error(`Missing action creator for key "${String(n)}"`);
274
- r[s.type] = o;
275
- }), r;
276
- }, mt = { phase: { kind: "idle" }, suggest: null, pointer: null, tabbarHover: null, draggingTabElement: null }, D = {
343
+ throw new Error(`Missing action creator for key "${String(r)}"`);
344
+ n[s.type] = o;
345
+ }), n;
346
+ }, wt = { phase: { kind: "idle" }, suggest: null, pointer: null, tabbarHover: null, draggingTabElement: null }, D = {
277
347
  startContent: A(
278
348
  "START_CONTENT",
279
349
  (t) => t
@@ -289,7 +359,7 @@ const fe = (t, e) => {
289
359
  (t) => t
290
360
  ),
291
361
  reset: A("RESET")
292
- }, be = ht(D, {
362
+ }, Ie = It(D, {
293
363
  startContent: (t, e) => ({
294
364
  phase: {
295
365
  kind: "content",
@@ -321,322 +391,322 @@ const fe = (t, e) => {
321
391
  setSuggest: (t, e) => ({ ...t, suggest: e.payload }),
322
392
  setPointer: (t, e) => ({ ...t, pointer: e.payload }),
323
393
  setTabbarHover: (t, e) => ({ ...t, tabbarHover: e.payload }),
324
- reset: () => mt
325
- }), ge = (t, e) => {
326
- const r = be[e.type];
327
- return r ? r(t, e, void 0) : t;
328
- }, vt = l.createContext(null), q = () => {
329
- const t = l.useContext(vt);
394
+ reset: () => wt
395
+ }), we = (t, e) => {
396
+ const n = Ie[e.type];
397
+ return n ? n(t, e, void 0) : t;
398
+ }, yt = l.createContext(null), W = () => {
399
+ const t = l.useContext(yt);
330
400
  if (!t)
331
401
  throw new Error("usePanelInteractions must be used within InteractionsProvider");
332
402
  return t;
333
- }, he = ({
403
+ }, ye = ({
334
404
  containerRef: t,
335
405
  dragThresholdPx: e,
336
- onCommitContentDrop: r,
337
- onCommitTabDrop: n,
406
+ onCommitContentDrop: n,
407
+ onCommitTabDrop: r,
338
408
  isContentZoneAllowed: o,
339
409
  children: s
340
410
  }) => {
341
- const [a, i] = l.useReducer(ge, mt), c = bt(), u = l.useCallback(() => {
342
- const b = Array.from(c.getAll().entries()), y = b.map(([p, G]) => ({ gid: p, el: G.content ?? G.group })).filter((p) => !!p.el).map((p) => ({ ...p, rect: p.el.getBoundingClientRect() })), f = b.map(([p, G]) => ({ gid: p, el: G.tabbar })).filter((p) => !!p.el).map((p) => ({ ...p, rect: p.el.getBoundingClientRect() })), I = b.map(([p, G]) => ({ gid: p, el: G.content ?? G.group })).filter((p) => !!p.el).map((p) => ({ ...p, rect: p.el.getBoundingClientRect() }));
343
- return { groups: y, tabbars: f, contents: I };
344
- }, [c]), d = J((b) => {
411
+ const [a, i] = l.useReducer(we, wt), c = mt(), d = l.useCallback(() => {
412
+ const w = Array.from(c.getAll().entries()), T = w.map(([f, S]) => ({ gid: f, el: S.content ?? S.group })).filter((f) => !!f.el).map((f) => ({ ...f, rect: f.el.getBoundingClientRect() })), b = w.map(([f, S]) => ({ gid: f, el: S.tabbar })).filter((f) => !!f.el).map((f) => ({ ...f, rect: f.el.getBoundingClientRect() })), I = w.map(([f, S]) => ({ gid: f, el: S.content ?? S.group })).filter((f) => !!f.el).map((f) => ({ ...f, rect: f.el.getBoundingClientRect() }));
413
+ return { groups: T, tabbars: b, contents: I };
414
+ }, [c]), u = J((w) => {
345
415
  if (!t.current)
346
416
  return;
347
- const f = b.clientX, I = b.clientY, p = a.phase;
348
- if (p.kind === "idle")
417
+ const b = w.clientX, I = w.clientY, f = a.phase;
418
+ if (f.kind === "idle")
349
419
  return;
350
- const G = Math.abs(f - p.startX), E = Math.abs(I - p.startY);
351
- if (G < e && E < e) {
420
+ const S = Math.abs(b - f.startX), C = Math.abs(I - f.startY);
421
+ if (S < e && C < e) {
352
422
  a.phase.kind === "content" && i(D.setSuggest(null)), i(D.setPointer(null)), i(D.setTabbarHover(null));
353
423
  return;
354
424
  }
355
- if (i(D.setPointer({ x: f, y: I })), p.kind === "content") {
356
- const S = p.cache.groups.find(({ rect: x }) => f >= x.left && f <= x.right && I >= x.top && I <= x.bottom);
357
- if (!S) {
425
+ if (i(D.setPointer({ x: b, y: I })), f.kind === "content") {
426
+ const G = f.cache.groups.find(({ rect: x }) => b >= x.left && b <= x.right && I >= x.top && I <= x.bottom);
427
+ if (!G) {
358
428
  i(D.setSuggest(null));
359
429
  return;
360
430
  }
361
- const P = V(S.rect, f, I);
362
- if (o && !o({ targetGroupId: S.gid, zone: P })) {
431
+ const R = K(G.rect, b, I);
432
+ if (o && !o({ targetGroupId: G.gid, zone: R })) {
363
433
  i(D.setSuggest(null));
364
434
  return;
365
435
  }
366
- i(D.setSuggest({ rect: S.rect, zone: P }));
436
+ i(D.setSuggest({ rect: G.rect, zone: R }));
367
437
  return;
368
438
  }
369
- if (p.kind === "tab") {
370
- const S = p.cache.tabbars.find(({ rect: R }) => f >= R.left && f <= R.right && I >= R.top && I <= R.bottom);
371
- if (S) {
372
- const k = Array.from(S.el.querySelectorAll("[role='tab']")).map((N) => N.getBoundingClientRect()), C = k.map((N) => N.left + N.width / 2), O = C.findIndex((N) => f < N), B = O === -1 ? C.length : O, Et = k.length === 0 ? S.rect.left + 8 : B === 0 ? k[0].left : B === k.length ? k[k.length - 1].right : (k[B - 1].right + k[B].left) / 2;
373
- i(D.setTabbarHover({ groupId: S.gid, index: B, rect: S.rect, insertX: Et }));
439
+ if (f.kind === "tab") {
440
+ const G = f.cache.tabbars.find(({ rect: E }) => b >= E.left && b <= E.right && I >= E.top && I <= E.bottom);
441
+ if (G) {
442
+ const k = Array.from(G.el.querySelectorAll("[role='tab']")).map((z) => z.getBoundingClientRect()), P = k.map((z) => z.left + z.width / 2), O = P.findIndex((z) => b < z), B = O === -1 ? P.length : O, At = k.length === 0 ? G.rect.left + 8 : B === 0 ? k[0].left : B === k.length ? k[k.length - 1].right : (k[B - 1].right + k[B].left) / 2;
443
+ i(D.setTabbarHover({ groupId: G.gid, index: B, rect: G.rect, insertX: At }));
374
444
  } else
375
445
  i(D.setTabbarHover(null));
376
- const P = p.cache.contents.find(({ rect: R }) => f >= R.left && f <= R.right && I >= R.top && I <= R.bottom);
377
- if (!P) {
446
+ const R = f.cache.contents.find(({ rect: E }) => b >= E.left && b <= E.right && I >= E.top && I <= E.bottom);
447
+ if (!R) {
378
448
  i(D.setSuggest(null));
379
449
  return;
380
450
  }
381
- const x = V(P.rect, f, I);
382
- if (o && !o({ targetGroupId: P.gid, zone: x })) {
451
+ const x = K(R.rect, b, I);
452
+ if (o && !o({ targetGroupId: R.gid, zone: x })) {
383
453
  i(D.setSuggest(null));
384
454
  return;
385
455
  }
386
- i(D.setSuggest({ rect: P.rect, zone: x }));
456
+ i(D.setSuggest({ rect: R.rect, zone: x }));
387
457
  }
388
- }), g = J((b) => {
389
- const y = t.current, f = a;
390
- if (i(D.reset()), !y)
458
+ }), p = J((w) => {
459
+ const T = t.current, b = a;
460
+ if (i(D.reset()), !T)
391
461
  return;
392
- const I = b.clientX, p = b.clientY;
393
- if (f.phase.kind === "idle")
462
+ const I = w.clientX, f = w.clientY;
463
+ if (b.phase.kind === "idle")
394
464
  return;
395
- const G = Math.abs(I - f.phase.startX), E = Math.abs(p - f.phase.startY);
396
- if (!(G < e && E < e)) {
397
- if (f.phase.kind === "content") {
398
- const S = f.phase.cache.groups.find(({ rect: R }) => I >= R.left && I <= R.right && p >= R.top && p <= R.bottom);
399
- if (!S)
465
+ const S = Math.abs(I - b.phase.startX), C = Math.abs(f - b.phase.startY);
466
+ if (!(S < e && C < e)) {
467
+ if (b.phase.kind === "content") {
468
+ const G = b.phase.cache.groups.find(({ rect: E }) => I >= E.left && I <= E.right && f >= E.top && f <= E.bottom);
469
+ if (!G)
400
470
  return;
401
- const P = S.gid ?? null;
402
- if (!P)
471
+ const R = G.gid ?? null;
472
+ if (!R)
403
473
  return;
404
- const x = V(S.rect, I, p);
405
- if (o && !o({ targetGroupId: P, zone: x }))
474
+ const x = K(G.rect, I, f);
475
+ if (o && !o({ targetGroupId: R, zone: x }))
406
476
  return;
407
- r({ fromGroupId: f.phase.fromGroupId, tabId: f.phase.tabId, targetGroupId: P, zone: x });
477
+ n({ fromGroupId: b.phase.fromGroupId, tabId: b.phase.tabId, targetGroupId: R, zone: x });
408
478
  return;
409
479
  }
410
- if (f.phase.kind === "tab") {
411
- const S = f.phase.cache.tabbars.find(({ rect: x }) => I >= x.left && I <= x.right && p >= x.top && p <= x.bottom);
412
- if (S) {
413
- const x = S.gid;
480
+ if (b.phase.kind === "tab") {
481
+ const G = b.phase.cache.tabbars.find(({ rect: x }) => I >= x.left && I <= x.right && f >= x.top && f <= x.bottom);
482
+ if (G) {
483
+ const x = G.gid;
414
484
  if (!x)
415
485
  return;
416
- const k = Array.from(S.el.querySelectorAll("[role='tab']")).map((B) => {
486
+ const k = Array.from(G.el.querySelectorAll("[role='tab']")).map((B) => {
417
487
  const Z = B.getBoundingClientRect();
418
488
  return Z.left + Z.width / 2;
419
- }), C = k.findIndex((B) => I < B), O = C === -1 ? k.length : C;
420
- n({ fromGroupId: f.phase.fromGroupId, tabId: f.phase.tabId, targetGroupId: x, targetIndex: O });
489
+ }), P = k.findIndex((B) => I < B), O = P === -1 ? k.length : P;
490
+ r({ fromGroupId: b.phase.fromGroupId, tabId: b.phase.tabId, targetGroupId: x, targetIndex: O });
421
491
  return;
422
492
  }
423
- const P = f.phase.cache.contents.find(({ rect: x }) => I >= x.left && I <= x.right && p >= x.top && p <= x.bottom);
424
- if (P) {
425
- const x = P.gid ?? null;
493
+ const R = b.phase.cache.contents.find(({ rect: x }) => I >= x.left && I <= x.right && f >= x.top && f <= x.bottom);
494
+ if (R) {
495
+ const x = R.gid ?? null;
426
496
  if (!x)
427
497
  return;
428
- const R = V(P.rect, I, p);
429
- if (o && !o({ targetGroupId: x, zone: R }))
498
+ const E = K(R.rect, I, f);
499
+ if (o && !o({ targetGroupId: x, zone: E }))
430
500
  return;
431
- r({ fromGroupId: f.phase.fromGroupId, tabId: f.phase.tabId, targetGroupId: x, zone: R });
501
+ n({ fromGroupId: b.phase.fromGroupId, tabId: b.phase.tabId, targetGroupId: x, zone: E });
432
502
  }
433
503
  }
434
504
  }
435
- }), v = J(() => {
505
+ }), g = J(() => {
436
506
  i(D.reset());
437
507
  });
438
508
  l.useEffect(() => {
439
509
  if (a.phase.kind !== "idle")
440
- return window.addEventListener("pointermove", d), window.addEventListener("pointerup", g, { once: !0 }), window.addEventListener("pointercancel", v, { once: !0 }), () => {
441
- window.removeEventListener("pointermove", d), window.removeEventListener("pointerup", g), window.removeEventListener("pointercancel", v);
510
+ return window.addEventListener("pointermove", u), window.addEventListener("pointerup", p, { once: !0 }), window.addEventListener("pointercancel", g, { once: !0 }), () => {
511
+ window.removeEventListener("pointermove", u), window.removeEventListener("pointerup", p), window.removeEventListener("pointercancel", g);
442
512
  };
443
513
  }, [a.phase.kind]);
444
- const T = l.useCallback((b, y, f) => {
445
- if (f.button !== 0)
514
+ const v = l.useCallback((w, T, b) => {
515
+ if (b.button !== 0)
446
516
  return;
447
- f.currentTarget.setPointerCapture(f.pointerId);
448
- const I = u();
449
- i(D.startContent({ x: f.clientX, y: f.clientY, groupId: b, tabId: y, cache: I }));
450
- }, [u]), h = l.useCallback((b, y, f) => {
451
- if (f.button !== 0)
517
+ b.currentTarget.setPointerCapture(b.pointerId);
518
+ const I = d();
519
+ i(D.startContent({ x: b.clientX, y: b.clientY, groupId: w, tabId: T, cache: I }));
520
+ }, [d]), h = l.useCallback((w, T, b) => {
521
+ if (b.button !== 0)
452
522
  return;
453
- const I = f.currentTarget;
454
- I && I.setPointerCapture(f.pointerId);
455
- const p = u();
456
- i(D.startTab({ x: f.clientX, y: f.clientY, groupId: y, tabId: b, cache: p, element: I }));
457
- }, [u]), w = l.useMemo(() => ({
523
+ const I = b.currentTarget;
524
+ I && I.setPointerCapture(b.pointerId);
525
+ const f = d();
526
+ i(D.startTab({ x: b.clientX, y: b.clientY, groupId: T, tabId: w, cache: f, element: I }));
527
+ }, [d]), y = l.useMemo(() => ({
458
528
  suggest: a.suggest,
459
529
  isTabDragging: a.phase.kind === "tab",
460
530
  draggingTabId: a.phase.kind === "tab" ? a.phase.tabId : null,
461
531
  dragPointer: a.pointer,
462
532
  tabbarHover: a.tabbarHover,
463
533
  draggingTabElement: a.draggingTabElement,
464
- onStartContentDrag: T,
534
+ onStartContentDrag: v,
465
535
  onStartTabDrag: h
466
- }), [a.suggest, a.pointer, a.tabbarHover, a.phase, a.draggingTabElement, T, h]);
467
- return /* @__PURE__ */ m(vt.Provider, { value: w, children: s });
468
- }, st = {
536
+ }), [a.suggest, a.pointer, a.tabbarHover, a.phase, a.draggingTabElement, v, h]);
537
+ return /* @__PURE__ */ m(yt.Provider, { value: y, children: s });
538
+ }, ct = {
469
539
  display: "inline-flex",
470
540
  alignItems: "center",
471
541
  userSelect: "none"
472
- }, me = ({
542
+ }, Te = ({
473
543
  groupId: t,
474
544
  tab: e,
475
- active: r,
476
- dragging: n,
545
+ active: n,
546
+ dragging: r,
477
547
  onClickTab: o,
478
548
  onStartDrag: s,
479
549
  onCloseTab: a,
480
550
  tabComponent: i,
481
551
  tabElement: c,
482
- onDoubleClick: u
552
+ onDoubleClick: d
483
553
  }) => {
484
- const d = l.useEffectEvent(() => {
554
+ const u = l.useEffectEvent(() => {
485
555
  o(e.id);
486
- }), g = l.useEffectEvent((w) => {
487
- s && w.button === 0 && s(e.id, t, w);
488
- }), v = () => {
489
- const w = !!a;
490
- return /* @__PURE__ */ m(l.Activity, { mode: w ? "visible" : "hidden", children: /* @__PURE__ */ m(
556
+ }), p = l.useEffectEvent((y) => {
557
+ s && y.button === 0 && s(e.id, t, y);
558
+ }), g = () => {
559
+ const y = !!a;
560
+ return /* @__PURE__ */ m(l.Activity, { mode: y ? "visible" : "hidden", children: /* @__PURE__ */ m(
491
561
  "button",
492
562
  {
493
563
  type: "button",
494
564
  "aria-label": `Close tab ${e.title}`,
495
- onClick: (b) => {
496
- a && (b.stopPropagation(), a(t, e.id));
565
+ onClick: (w) => {
566
+ a && (w.stopPropagation(), a(t, e.id));
497
567
  },
498
568
  style: { marginLeft: 6 },
499
- tabIndex: w ? void 0 : -1,
500
- disabled: !w,
501
- "aria-hidden": w ? void 0 : !0,
569
+ tabIndex: y ? void 0 : -1,
570
+ disabled: !y,
571
+ "aria-hidden": y ? void 0 : !0,
502
572
  children: "×"
503
573
  }
504
574
  ) });
505
- }, T = {
575
+ }, v = {
506
576
  role: "tab",
507
- "aria-selected": r,
508
- tabIndex: r ? 0 : -1,
509
- style: st,
510
- onClick: d,
511
- onPointerDown: g,
512
- onDoubleClick: u,
577
+ "aria-selected": n,
578
+ tabIndex: n ? 0 : -1,
579
+ style: ct,
580
+ onClick: u,
581
+ onPointerDown: p,
582
+ onDoubleClick: d,
513
583
  "data-tab-id": e.id,
514
- "data-active": r ? "true" : "false",
515
- "data-dragging": n ? "true" : "false",
584
+ "data-active": n ? "true" : "false",
585
+ "data-dragging": r ? "true" : "false",
516
586
  children: /* @__PURE__ */ H(et, { children: [
517
587
  /* @__PURE__ */ m("span", { children: e.title }),
518
- v()
588
+ g()
519
589
  ] })
520
590
  }, h = {
521
591
  type: "button",
522
592
  role: "tab",
523
- "aria-selected": r,
524
- tabIndex: r ? 0 : -1,
525
- style: st,
593
+ "aria-selected": n,
594
+ tabIndex: n ? 0 : -1,
595
+ style: ct,
526
596
  onClick: () => {
527
597
  o(e.id);
528
598
  },
529
- onPointerDown: (w) => {
530
- s && w.button === 0 && s(e.id, t, w);
599
+ onPointerDown: (y) => {
600
+ s && y.button === 0 && s(e.id, t, y);
531
601
  },
532
- onDoubleClick: u,
602
+ onDoubleClick: d,
533
603
  children: /* @__PURE__ */ m("span", { children: e.title })
534
604
  };
535
- return c ? c(h) : i ? /* @__PURE__ */ m(i, { ...h }) : /* @__PURE__ */ m("div", { ...T });
536
- }, ve = {
605
+ return c ? c(h) : i ? /* @__PURE__ */ m(i, { ...h }) : /* @__PURE__ */ m("div", { ...v });
606
+ }, Se = {
537
607
  display: "flex",
538
608
  alignItems: "center"
539
- }, Ie = {
609
+ }, xe = {
540
610
  flex: "1 1 auto",
541
611
  alignSelf: "stretch"
542
- }, we = ({
612
+ }, Ge = ({
543
613
  group: t,
544
614
  onClickTab: e,
545
- onStartDrag: r,
546
- rootRef: n,
615
+ onStartDrag: n,
616
+ rootRef: r,
547
617
  component: o,
548
618
  element: s,
549
619
  tabComponent: a,
550
620
  tabElement: i,
551
621
  onAddTab: c,
552
- onCloseTab: u,
553
- doubleClickToAdd: d
622
+ onCloseTab: d,
623
+ doubleClickToAdd: u
554
624
  }) => {
555
- const { isTabDragging: g, draggingTabId: v } = q(), T = l.useRef(null), h = l.useCallback(
556
- (p) => {
557
- if (T.current = p, !!n) {
558
- if (typeof n == "function") {
559
- n(p);
625
+ const { isTabDragging: p, draggingTabId: g } = W(), v = l.useRef(null), h = l.useCallback(
626
+ (f) => {
627
+ if (v.current = f, !!r) {
628
+ if (typeof r == "function") {
629
+ r(f);
560
630
  return;
561
631
  }
562
632
  try {
563
- n.current = p;
633
+ r.current = f;
564
634
  } catch {
565
635
  }
566
636
  }
567
637
  },
568
- [n]
569
- ), w = l.useEffectEvent((p) => {
570
- const G = T.current ?? p.currentTarget;
571
- if (!G)
638
+ [r]
639
+ ), y = l.useEffectEvent((f) => {
640
+ const S = v.current ?? f.currentTarget;
641
+ if (!S)
572
642
  return;
573
- const E = Array.from(G.querySelectorAll('[role="tab"]'));
574
- if (E.length === 0)
643
+ const C = Array.from(S.querySelectorAll('[role="tab"]'));
644
+ if (C.length === 0)
575
645
  return;
576
- const S = (C) => {
577
- const O = Math.max(0, Math.min(C, E.length - 1)), B = E[O];
646
+ const G = (P) => {
647
+ const O = Math.max(0, Math.min(P, C.length - 1)), B = C[O];
578
648
  B && B.focus();
579
- }, P = document.activeElement, x = P ? E.indexOf(P) : E.findIndex((C) => C.getAttribute("data-tab-id") === t.activeTabId);
580
- if (p.key === "ArrowRight") {
581
- p.preventDefault();
582
- const C = x >= 0 ? x + 1 : 0;
583
- S(C >= E.length ? 0 : C);
649
+ }, R = document.activeElement, x = R ? C.indexOf(R) : C.findIndex((P) => P.getAttribute("data-tab-id") === t.activeTabId);
650
+ if (f.key === "ArrowRight") {
651
+ f.preventDefault();
652
+ const P = x >= 0 ? x + 1 : 0;
653
+ G(P >= C.length ? 0 : P);
584
654
  return;
585
655
  }
586
- if (p.key === "ArrowLeft") {
587
- p.preventDefault();
588
- const C = x >= 0 ? x - 1 : E.length - 1;
589
- S(C < 0 ? E.length - 1 : C);
656
+ if (f.key === "ArrowLeft") {
657
+ f.preventDefault();
658
+ const P = x >= 0 ? x - 1 : C.length - 1;
659
+ G(P < 0 ? C.length - 1 : P);
590
660
  return;
591
661
  }
592
- if (p.key === "Home") {
593
- p.preventDefault(), S(0);
662
+ if (f.key === "Home") {
663
+ f.preventDefault(), G(0);
594
664
  return;
595
665
  }
596
- if (p.key === "End") {
597
- p.preventDefault(), S(E.length - 1);
666
+ if (f.key === "End") {
667
+ f.preventDefault(), G(C.length - 1);
598
668
  return;
599
669
  }
600
- if (p.key === "Enter" || p.key === " ") {
601
- p.preventDefault();
602
- const O = (x >= 0 ? E[x] : null)?.getAttribute("data-tab-id") ?? null;
670
+ if (f.key === "Enter" || f.key === " ") {
671
+ f.preventDefault();
672
+ const O = (x >= 0 ? C[x] : null)?.getAttribute("data-tab-id") ?? null;
603
673
  O && e(O);
604
674
  return;
605
675
  }
606
- if (p.key === "Delete" || p.key === "Backspace") {
607
- if (u) {
608
- p.preventDefault();
609
- const O = (x >= 0 ? E[x] : null)?.getAttribute("data-tab-id") ?? null;
610
- O && u(t.id, O);
676
+ if (f.key === "Delete" || f.key === "Backspace") {
677
+ if (d) {
678
+ f.preventDefault();
679
+ const O = (x >= 0 ? C[x] : null)?.getAttribute("data-tab-id") ?? null;
680
+ O && d(t.id, O);
611
681
  }
612
682
  return;
613
683
  }
614
- const R = (p.ctrlKey ? 1 : 0) + (p.metaKey ? 1 : 0) > 0, k = typeof p.key == "string" ? p.key.toLowerCase() : "";
615
- if (R && k === "t") {
616
- c && (p.preventDefault(), c(t.id));
684
+ const E = (f.ctrlKey ? 1 : 0) + (f.metaKey ? 1 : 0) > 0, k = typeof f.key == "string" ? f.key.toLowerCase() : "";
685
+ if (E && k === "t") {
686
+ c && (f.preventDefault(), c(t.id));
617
687
  return;
618
688
  }
619
689
  });
620
690
  l.useEffect(() => {
621
- const p = T.current;
622
- if (!p)
691
+ const f = v.current;
692
+ if (!f)
623
693
  return;
624
- const G = p.querySelector(`[role="tab"][data-tab-id="${t.activeTabId}"]`);
625
- if (G === document.activeElement)
694
+ const S = f.querySelector(`[role="tab"][data-tab-id="${t.activeTabId}"]`);
695
+ if (S === document.activeElement)
626
696
  return;
627
- !p.contains(document.activeElement) && G && G.focus();
697
+ !f.contains(document.activeElement) && S && S.focus();
628
698
  }, [t.activeTabId]);
629
- const b = {
630
- style: ve,
699
+ const w = {
700
+ style: Se,
631
701
  role: "tablist",
632
702
  "data-tabbar": "true",
633
703
  "data-group-id": t.id,
634
- "data-dragging": g ? "true" : "false",
635
- onKeyDown: w
636
- }, y = Dt({
704
+ "data-dragging": p ? "true" : "false",
705
+ onKeyDown: y
706
+ }, T = Ot({
637
707
  element: s,
638
708
  component: o
639
- }), f = () => c ? /* @__PURE__ */ m(
709
+ }), b = () => c ? /* @__PURE__ */ m(
640
710
  "button",
641
711
  {
642
712
  type: "button",
@@ -647,85 +717,84 @@ const fe = (t, e) => {
647
717
  children: "+"
648
718
  }
649
719
  ) : null, I = l.useCallback(() => {
650
- d && c && c(t.id);
651
- }, [d, c, t.id]);
652
- return /* @__PURE__ */ H(y, { ...b, ref: h, onDoubleClick: I, children: [
653
- t.tabs.map((p, G) => /* @__PURE__ */ m(
654
- me,
720
+ u && c && c(t.id);
721
+ }, [u, c, t.id]);
722
+ return /* @__PURE__ */ H(T, { ...w, ref: h, onDoubleClick: I, children: [
723
+ t.tabs.map((f, S) => /* @__PURE__ */ m(
724
+ Te,
655
725
  {
656
726
  groupId: t.id,
657
- tab: p,
658
- active: t.activeTabId === p.id,
659
- dragging: v === p.id,
727
+ tab: f,
728
+ active: t.activeTabId === f.id,
729
+ dragging: g === f.id,
660
730
  onClickTab: e,
661
- onStartDrag: r,
662
- onCloseTab: u,
731
+ onStartDrag: n,
732
+ onCloseTab: d,
663
733
  tabComponent: a,
664
734
  tabElement: i,
665
- onDoubleClick: (E) => E.stopPropagation()
735
+ onDoubleClick: (C) => C.stopPropagation()
666
736
  },
667
- `${t.id}:${p.id}:${G}`
737
+ `${t.id}:${f.id}:${S}`
668
738
  )),
669
- /* @__PURE__ */ m("span", { style: Ie }),
670
- f()
739
+ /* @__PURE__ */ m("span", { style: xe }),
740
+ b()
671
741
  ] });
672
- }, ye = ({ id: t, TabBarComponent: e, PanelGroupComponent: r }) => {
673
- const { getGroup: n, getGroupContent: o, onClickTab: s, onAddTab: a, onCloseTab: i, onStartContentDrag: c, onStartTabDrag: u, doubleClickToAdd: d } = se(), { setGroupEl: g, setTabbarEl: v, setContentEl: T } = bt(), h = l.useCallback(
674
- (G) => {
675
- g(t, G);
742
+ }, Ce = ({ id: t, TabBarComponent: e, PanelGroupComponent: n }) => {
743
+ const { getGroup: r, getGroupContent: o, onClickTab: s, onAddTab: a, onCloseTab: i, onStartTabDrag: c, doubleClickToAdd: d, registerContentContainer: u } = le(), { setGroupEl: p, setTabbarEl: g, setContentEl: v } = mt(), h = l.useCallback(
744
+ (S) => {
745
+ p(t, S);
676
746
  },
677
- [t, g]
678
- ), w = l.useCallback(
679
- (G) => {
680
- T(t, G);
747
+ [t, p]
748
+ ), y = l.useCallback(
749
+ (S) => {
750
+ v(t, S), u(t, S);
681
751
  },
682
- [t, T]
683
- ), b = l.useCallback(
684
- (G) => {
685
- v(t, G);
752
+ [t, v, u]
753
+ ), w = l.useCallback(
754
+ (S) => {
755
+ g(t, S);
686
756
  },
687
- [t, v]
688
- ), y = n(t);
689
- if (!y)
757
+ [t, g]
758
+ ), T = r(t);
759
+ if (!T)
690
760
  return null;
691
- const f = o(t);
761
+ const b = o(t);
692
762
  return /* @__PURE__ */ m(
693
- r ?? ((G) => /* @__PURE__ */ m(gt, { ...G })),
763
+ n ?? ((S) => /* @__PURE__ */ m(vt, { ...S })),
694
764
  {
695
- group: y,
765
+ group: T,
696
766
  tabbar: /* @__PURE__ */ m(
697
- e ?? we,
767
+ e ?? Ge,
698
768
  {
699
- rootRef: b,
700
- group: y,
701
- onClickTab: (G) => s(t, G),
769
+ rootRef: w,
770
+ group: T,
771
+ onClickTab: (S) => s(t, S),
702
772
  onAddTab: a,
703
773
  onCloseTab: i,
704
- onStartDrag: (G, E, S) => u(G, E, S),
774
+ onStartDrag: (S, C, G) => c(S, C, G),
705
775
  doubleClickToAdd: d
706
776
  }
707
777
  ),
708
- content: f,
778
+ content: b,
709
779
  groupRef: h,
710
- contentRef: w,
711
- onContentPointerDown: (G) => c(t, G)
780
+ contentRef: y
712
781
  }
713
782
  );
714
- }, Te = (t, e) => {
715
- const r = new Array(16);
716
- for (let n = 0; n < 4; n++)
783
+ }, Ee = (t, e) => {
784
+ const n = new Array(16);
785
+ for (let r = 0; r < 4; r++)
717
786
  for (let o = 0; o < 4; o++)
718
- r[n * 4 + o] = t[0 + o] * e[n * 4 + 0] + t[4 + o] * e[n * 4 + 1] + t[8 + o] * e[n * 4 + 2] + t[12 + o] * e[n * 4 + 3];
719
- return r;
720
- }, K = (t) => {
787
+ n[r * 4 + o] = t[0 + o] * e[r * 4 + 0] + t[4 + o] * e[r * 4 + 1] + t[8 + o] * e[r * 4 + 2] + t[12 + o] * e[r * 4 + 3];
788
+ return n;
789
+ }, U = (t) => {
721
790
  if (t.length !== 16)
722
791
  throw new Error("Matrix must have exactly 16 values");
723
- const e = Object.freeze([...t]), r = (n) => {
724
- const o = Te(e, n);
725
- return K(o);
792
+ const e = Object.freeze([...t]), n = (r) => {
793
+ const o = Ee(e, r);
794
+ return U(o);
726
795
  };
727
796
  return Object.freeze({
728
- translate: (n = 0, o = 0, s = 0) => r([
797
+ translate: (r = 0, o = 0, s = 0) => n([
729
798
  1,
730
799
  0,
731
800
  0,
@@ -738,12 +807,12 @@ const fe = (t, e) => {
738
807
  0,
739
808
  1,
740
809
  0,
741
- n,
810
+ r,
742
811
  o,
743
812
  s,
744
813
  1
745
814
  ]),
746
- translate3d: (n, o, s) => r([
815
+ translate3d: (r, o, s) => n([
747
816
  1,
748
817
  0,
749
818
  0,
@@ -756,12 +825,12 @@ const fe = (t, e) => {
756
825
  0,
757
826
  1,
758
827
  0,
759
- n,
828
+ r,
760
829
  o,
761
830
  s,
762
831
  1
763
832
  ]),
764
- translateX: (n) => r([
833
+ translateX: (r) => n([
765
834
  1,
766
835
  0,
767
836
  0,
@@ -774,12 +843,12 @@ const fe = (t, e) => {
774
843
  0,
775
844
  1,
776
845
  0,
777
- n,
846
+ r,
778
847
  0,
779
848
  0,
780
849
  1
781
850
  ]),
782
- translateY: (n) => r([
851
+ translateY: (r) => n([
783
852
  1,
784
853
  0,
785
854
  0,
@@ -793,11 +862,11 @@ const fe = (t, e) => {
793
862
  1,
794
863
  0,
795
864
  0,
796
- n,
865
+ r,
797
866
  0,
798
867
  1
799
868
  ]),
800
- translateZ: (n) => r([
869
+ translateZ: (r) => n([
801
870
  1,
802
871
  0,
803
872
  0,
@@ -812,11 +881,11 @@ const fe = (t, e) => {
812
881
  0,
813
882
  0,
814
883
  0,
815
- n,
884
+ r,
816
885
  1
817
886
  ]),
818
- scale: (n = 1, o = 1, s = 1) => r([
819
- n,
887
+ scale: (r = 1, o = 1, s = 1) => n([
888
+ r,
820
889
  0,
821
890
  0,
822
891
  0,
@@ -833,8 +902,8 @@ const fe = (t, e) => {
833
902
  0,
834
903
  1
835
904
  ]),
836
- scale3d: (n, o, s) => r([
837
- n,
905
+ scale3d: (r, o, s) => n([
906
+ r,
838
907
  0,
839
908
  0,
840
909
  0,
@@ -851,8 +920,8 @@ const fe = (t, e) => {
851
920
  0,
852
921
  1
853
922
  ]),
854
- scaleX: (n) => r([
855
- n,
923
+ scaleX: (r) => n([
924
+ r,
856
925
  0,
857
926
  0,
858
927
  0,
@@ -869,13 +938,13 @@ const fe = (t, e) => {
869
938
  0,
870
939
  1
871
940
  ]),
872
- scaleY: (n) => r([
941
+ scaleY: (r) => n([
873
942
  1,
874
943
  0,
875
944
  0,
876
945
  0,
877
946
  0,
878
- n,
947
+ r,
879
948
  0,
880
949
  0,
881
950
  0,
@@ -887,7 +956,7 @@ const fe = (t, e) => {
887
956
  0,
888
957
  1
889
958
  ]),
890
- scaleZ: (n) => r([
959
+ scaleZ: (r) => n([
891
960
  1,
892
961
  0,
893
962
  0,
@@ -898,16 +967,16 @@ const fe = (t, e) => {
898
967
  0,
899
968
  0,
900
969
  0,
901
- n,
970
+ r,
902
971
  0,
903
972
  0,
904
973
  0,
905
974
  0,
906
975
  1
907
976
  ]),
908
- rotateX: (n) => {
909
- const o = Math.cos(n), s = Math.sin(n);
910
- return r([
977
+ rotateX: (r) => {
978
+ const o = Math.cos(r), s = Math.sin(r);
979
+ return n([
911
980
  1,
912
981
  0,
913
982
  0,
@@ -926,9 +995,9 @@ const fe = (t, e) => {
926
995
  1
927
996
  ]);
928
997
  },
929
- rotateY: (n) => {
930
- const o = Math.cos(n), s = Math.sin(n);
931
- return r([
998
+ rotateY: (r) => {
999
+ const o = Math.cos(r), s = Math.sin(r);
1000
+ return n([
932
1001
  o,
933
1002
  0,
934
1003
  -s,
@@ -947,9 +1016,9 @@ const fe = (t, e) => {
947
1016
  1
948
1017
  ]);
949
1018
  },
950
- rotateZ: (n) => {
951
- const o = Math.cos(n), s = Math.sin(n);
952
- return r([
1019
+ rotateZ: (r) => {
1020
+ const o = Math.cos(r), s = Math.sin(r);
1021
+ return n([
953
1022
  o,
954
1023
  s,
955
1024
  0,
@@ -968,24 +1037,24 @@ const fe = (t, e) => {
968
1037
  1
969
1038
  ]);
970
1039
  },
971
- rotate: (n, o, s, a) => {
1040
+ rotate: (r, o, s, a) => {
972
1041
  const i = Math.sqrt(o * o + s * s + a * a);
973
1042
  if (i === 0)
974
- return K(e);
1043
+ return U(e);
975
1044
  o /= i, s /= i, a /= i;
976
- const c = Math.cos(n), u = Math.sin(n), d = 1 - c;
977
- return r([
978
- d * o * o + c,
979
- d * o * s + u * a,
980
- d * o * a - u * s,
1045
+ const c = Math.cos(r), d = Math.sin(r), u = 1 - c;
1046
+ return n([
1047
+ u * o * o + c,
1048
+ u * o * s + d * a,
1049
+ u * o * a - d * s,
981
1050
  0,
982
- d * o * s - u * a,
983
- d * s * s + c,
984
- d * s * a + u * o,
1051
+ u * o * s - d * a,
1052
+ u * s * s + c,
1053
+ u * s * a + d * o,
985
1054
  0,
986
- d * o * a + u * s,
987
- d * s * a - u * o,
988
- d * a * a + c,
1055
+ u * o * a + d * s,
1056
+ u * s * a - d * o,
1057
+ u * a * a + c,
989
1058
  0,
990
1059
  0,
991
1060
  0,
@@ -993,24 +1062,24 @@ const fe = (t, e) => {
993
1062
  1
994
1063
  ]);
995
1064
  },
996
- rotate3d: (n, o, s, a) => {
997
- const i = Math.sqrt(n * n + o * o + s * s);
1065
+ rotate3d: (r, o, s, a) => {
1066
+ const i = Math.sqrt(r * r + o * o + s * s);
998
1067
  if (i === 0)
999
- return K(e);
1000
- n /= i, o /= i, s /= i;
1001
- const c = Math.cos(a), u = Math.sin(a), d = 1 - c;
1002
- return r([
1003
- d * n * n + c,
1004
- d * n * o + u * s,
1005
- d * n * s - u * o,
1068
+ return U(e);
1069
+ r /= i, o /= i, s /= i;
1070
+ const c = Math.cos(a), d = Math.sin(a), u = 1 - c;
1071
+ return n([
1072
+ u * r * r + c,
1073
+ u * r * o + d * s,
1074
+ u * r * s - d * o,
1006
1075
  0,
1007
- d * n * o - u * s,
1008
- d * o * o + c,
1009
- d * o * s + u * n,
1076
+ u * r * o - d * s,
1077
+ u * o * o + c,
1078
+ u * o * s + d * r,
1010
1079
  0,
1011
- d * n * s + u * o,
1012
- d * o * s - u * n,
1013
- d * s * s + c,
1080
+ u * r * s + d * o,
1081
+ u * o * s - d * r,
1082
+ u * s * s + c,
1014
1083
  0,
1015
1084
  0,
1016
1085
  0,
@@ -1018,9 +1087,9 @@ const fe = (t, e) => {
1018
1087
  1
1019
1088
  ]);
1020
1089
  },
1021
- skew: (n = 0, o = 0) => {
1022
- const s = Math.tan(n), a = Math.tan(o);
1023
- return r([
1090
+ skew: (r = 0, o = 0) => {
1091
+ const s = Math.tan(r), a = Math.tan(o);
1092
+ return n([
1024
1093
  1,
1025
1094
  a,
1026
1095
  0,
@@ -1039,9 +1108,9 @@ const fe = (t, e) => {
1039
1108
  1
1040
1109
  ]);
1041
1110
  },
1042
- skewX: (n) => {
1043
- const o = Math.tan(n);
1044
- return r([
1111
+ skewX: (r) => {
1112
+ const o = Math.tan(r);
1113
+ return n([
1045
1114
  1,
1046
1115
  0,
1047
1116
  0,
@@ -1060,9 +1129,9 @@ const fe = (t, e) => {
1060
1129
  1
1061
1130
  ]);
1062
1131
  },
1063
- skewY: (n) => {
1064
- const o = Math.tan(n);
1065
- return r([
1132
+ skewY: (r) => {
1133
+ const o = Math.tan(r);
1134
+ return n([
1066
1135
  1,
1067
1136
  o,
1068
1137
  0,
@@ -1081,10 +1150,10 @@ const fe = (t, e) => {
1081
1150
  1
1082
1151
  ]);
1083
1152
  },
1084
- perspective: (n) => {
1085
- if (n === 0)
1153
+ perspective: (r) => {
1154
+ if (r === 0)
1086
1155
  throw new Error("Perspective distance cannot be zero");
1087
- return r([
1156
+ return n([
1088
1157
  1,
1089
1158
  0,
1090
1159
  0,
@@ -1096,7 +1165,7 @@ const fe = (t, e) => {
1096
1165
  0,
1097
1166
  0,
1098
1167
  1,
1099
- -1 / n,
1168
+ -1 / r,
1100
1169
  0,
1101
1170
  0,
1102
1171
  0,
@@ -1113,7 +1182,7 @@ const fe = (t, e) => {
1113
1182
  ].join(`
1114
1183
  `)
1115
1184
  });
1116
- }, Ge = () => K([
1185
+ }, Re = () => U([
1117
1186
  1,
1118
1187
  0,
1119
1188
  0,
@@ -1130,284 +1199,284 @@ const fe = (t, e) => {
1130
1199
  0,
1131
1200
  0,
1132
1201
  1
1133
- ]), xe = {
1202
+ ]), Pe = {
1134
1203
  position: "fixed",
1135
1204
  inset: 0,
1136
1205
  pointerEvents: "none",
1137
- zIndex: Lt
1138
- }, Se = {
1206
+ zIndex: $t
1207
+ }, De = {
1139
1208
  position: "absolute",
1140
- border: `${Nt} dashed ${zt}`,
1141
- background: Ht,
1142
- borderRadius: $t,
1209
+ border: `${Yt} dashed ${jt}`,
1210
+ background: Xt,
1211
+ borderRadius: Ft,
1143
1212
  transformOrigin: "top left"
1144
- }, L = (t, e) => e <= 0 ? 0 : _(t / e, 0), Ee = (t, e, r) => {
1145
- const { width: n, height: o } = t, s = r / 2, a = n > 0 ? n : 1, i = o > 0 ? o : 1, c = {
1146
- translateX: r,
1147
- translateY: r,
1148
- scaleX: L(_(n - r * 2, 0), a),
1149
- scaleY: L(_(o - r * 2, 0), i)
1150
- }, u = {
1151
- translateX: r,
1152
- translateY: r,
1153
- scaleX: L(_(n / 2 - r * 1.5, 0), a),
1154
- scaleY: L(_(o - r * 2, 0), i)
1213
+ }, L = (t, e) => e <= 0 ? 0 : M(t / e, 0), Ae = (t, e, n) => {
1214
+ const { width: r, height: o } = t, s = n / 2, a = r > 0 ? r : 1, i = o > 0 ? o : 1, c = {
1215
+ translateX: n,
1216
+ translateY: n,
1217
+ scaleX: L(M(r - n * 2, 0), a),
1218
+ scaleY: L(M(o - n * 2, 0), i)
1155
1219
  }, d = {
1156
- translateX: n / 2 + s,
1157
- translateY: r,
1158
- scaleX: L(_(n / 2 - r * 1.5, 0), a),
1159
- scaleY: L(_(o - r * 2, 0), i)
1220
+ translateX: n,
1221
+ translateY: n,
1222
+ scaleX: L(M(r / 2 - n * 1.5, 0), a),
1223
+ scaleY: L(M(o - n * 2, 0), i)
1224
+ }, u = {
1225
+ translateX: r / 2 + s,
1226
+ translateY: n,
1227
+ scaleX: L(M(r / 2 - n * 1.5, 0), a),
1228
+ scaleY: L(M(o - n * 2, 0), i)
1229
+ }, p = {
1230
+ translateX: n,
1231
+ translateY: n,
1232
+ scaleX: L(M(r - n * 2, 0), a),
1233
+ scaleY: L(M(o / 2 - n * 1.5, 0), i)
1160
1234
  }, g = {
1161
- translateX: r,
1162
- translateY: r,
1163
- scaleX: L(_(n - r * 2, 0), a),
1164
- scaleY: L(_(o / 2 - r * 1.5, 0), i)
1165
- }, v = {
1166
- translateX: r,
1235
+ translateX: n,
1167
1236
  translateY: o / 2 + s,
1168
- scaleX: L(_(n - r * 2, 0), a),
1169
- scaleY: L(_(o / 2 - r * 1.5, 0), i)
1170
- }, T = {
1237
+ scaleX: L(M(r - n * 2, 0), a),
1238
+ scaleY: L(M(o / 2 - n * 1.5, 0), i)
1239
+ }, v = {
1171
1240
  center: c,
1172
- left: u,
1173
- right: d,
1174
- top: g,
1175
- bottom: v
1176
- }, { translateX: h, translateY: w, scaleX: b, scaleY: y } = T[e];
1177
- return Ge().translate(h, w, 0).scale(b, y, 1).toCSS();
1178
- }, Re = (t, e) => {
1179
- const r = Xt;
1241
+ left: d,
1242
+ right: u,
1243
+ top: p,
1244
+ bottom: g
1245
+ }, { translateX: h, translateY: y, scaleX: w, scaleY: T } = v[e];
1246
+ return Re().translate(h, y, 0).scale(w, T, 1).toCSS();
1247
+ }, ke = (t, e) => {
1248
+ const n = Kt;
1180
1249
  return {
1181
- ...Se,
1250
+ ...De,
1182
1251
  left: t.left,
1183
1252
  top: t.top,
1184
1253
  width: t.width,
1185
1254
  height: t.height,
1186
- transform: Ee(t, e, r)
1255
+ transform: Ae(t, e, n)
1187
1256
  };
1188
- }, Pe = ({ suggest: t }) => {
1257
+ }, Me = ({ suggest: t }) => {
1189
1258
  if (!t)
1190
1259
  return null;
1191
- const { rect: e, zone: r } = t, n = Re(e, r);
1192
- return /* @__PURE__ */ m("div", { style: xe, children: /* @__PURE__ */ m("div", { style: n }) });
1193
- }, Ce = typeof window < "u" && typeof document < "u", De = (t) => {
1194
- const [e, r] = l.useState(null), [n, o] = l.useState(null);
1195
- return At(() => {
1196
- if (!Ce || !t) {
1197
- r(null), o(null);
1260
+ const { rect: e, zone: n } = t, r = ke(e, n);
1261
+ return /* @__PURE__ */ m("div", { style: Pe, children: /* @__PURE__ */ m("div", { style: r }) });
1262
+ }, _e = typeof window < "u" && typeof document < "u", Oe = (t) => {
1263
+ const [e, n] = l.useState(null), [r, o] = l.useState(null);
1264
+ return nt(() => {
1265
+ if (!_e || !t) {
1266
+ n(null), o(null);
1198
1267
  return;
1199
1268
  }
1200
1269
  const s = t.getBoundingClientRect();
1201
- r({ width: s.width, height: s.height }), o(t.outerHTML);
1202
- }, [t]), { html: n, size: e };
1203
- }, Ae = {
1270
+ n({ width: s.width, height: s.height }), o(t.outerHTML);
1271
+ }, [t]), { html: r, size: e };
1272
+ }, Be = {
1204
1273
  position: "fixed",
1205
1274
  inset: 0,
1206
1275
  pointerEvents: "none",
1207
- zIndex: qt
1208
- }, ke = {
1276
+ zIndex: Qt
1277
+ }, Le = {
1209
1278
  position: "absolute",
1210
- width: Ut,
1211
- borderRadius: Kt,
1212
- background: Vt,
1213
- boxShadow: jt
1214
- }, _e = () => {
1215
- const { isTabDragging: t, draggingTabId: e, dragPointer: r, tabbarHover: n, draggingTabElement: o } = q(), { html: s, size: a } = De(o), i = r !== null && e !== null, c = l.useMemo(() => {
1216
- if (!(!i || !r))
1279
+ width: Jt,
1280
+ borderRadius: Zt,
1281
+ background: qt,
1282
+ boxShadow: Wt
1283
+ }, He = () => {
1284
+ const { isTabDragging: t, draggingTabId: e, dragPointer: n, tabbarHover: r, draggingTabElement: o } = W(), { html: s, size: a } = Oe(o), i = n !== null && e !== null, c = l.useMemo(() => {
1285
+ if (!(!i || !n))
1217
1286
  return {
1218
1287
  position: "absolute",
1219
- left: r.x,
1220
- top: r.y,
1221
- transform: `translate(${Yt}, ${Ft})`,
1288
+ left: n.x,
1289
+ top: n.y,
1290
+ transform: `translate(${Ut}, ${Vt})`,
1222
1291
  pointerEvents: "none"
1223
1292
  };
1224
- }, [i, r]), u = l.useMemo(() => {
1293
+ }, [i, n]), d = l.useMemo(() => {
1225
1294
  if (!(!c || !o))
1226
1295
  return a ? { ...c, width: a.width, height: a.height } : c;
1227
- }, [c, o, a]), d = l.useMemo(() => {
1228
- if (n)
1296
+ }, [c, o, a]), u = l.useMemo(() => {
1297
+ if (r)
1229
1298
  return {
1230
- ...ke,
1231
- left: n.insertX,
1232
- top: n.rect.top + 4,
1233
- height: Math.max(0, n.rect.height - 8)
1299
+ ...Le,
1300
+ left: r.insertX,
1301
+ top: r.rect.top + 4,
1302
+ height: Math.max(0, r.rect.height - 8)
1234
1303
  };
1235
- }, [n]);
1236
- return t ? /* @__PURE__ */ H("div", { style: Ae, children: [
1237
- /* @__PURE__ */ m(l.Activity, { mode: u ? "visible" : "hidden", children: /* @__PURE__ */ m("div", { style: u, children: /* @__PURE__ */ m(
1304
+ }, [r]);
1305
+ return t ? /* @__PURE__ */ H("div", { style: Be, children: [
1306
+ /* @__PURE__ */ m(l.Activity, { mode: d ? "visible" : "hidden", children: /* @__PURE__ */ m("div", { style: d, children: /* @__PURE__ */ m(
1238
1307
  "div",
1239
1308
  {
1240
1309
  style: { width: "100%", height: "100%", pointerEvents: "none" },
1241
1310
  dangerouslySetInnerHTML: { __html: s ?? "" }
1242
1311
  }
1243
1312
  ) }) }),
1244
- /* @__PURE__ */ m(l.Activity, { mode: d ? "visible" : "hidden", children: /* @__PURE__ */ m("div", { style: d }) })
1313
+ /* @__PURE__ */ m(l.Activity, { mode: u ? "visible" : "hidden", children: /* @__PURE__ */ m("div", { style: u }) })
1245
1314
  ] }) : null;
1246
- }, M = (t) => t.type === "group", Y = (t, e = []) => {
1247
- if (M(t))
1315
+ }, _ = (t) => t.type === "group", Y = (t, e = []) => {
1316
+ if (_(t))
1248
1317
  return [...e, t.groupId];
1249
- const r = Y(t.a, e);
1250
- return Y(t.b, r);
1251
- }, W = (t, e) => e.reduce((r, n) => M(r) ? r : r[n], t), F = (t, e, r) => {
1318
+ const n = Y(t.a, e);
1319
+ return Y(t.b, n);
1320
+ }, q = (t, e) => e.reduce((n, r) => _(n) ? n : n[r], t), j = (t, e, n) => {
1252
1321
  if (e.length === 0)
1253
- return r;
1254
- const [n, ...o] = e;
1255
- return M(t) ? t : n === "a" ? { ...t, a: F(t.a, o, r) } : { ...t, b: F(t.b, o, r) };
1256
- }, U = (t, e, r = []) => {
1257
- if (M(t))
1322
+ return n;
1323
+ const [r, ...o] = e;
1324
+ return _(t) ? t : r === "a" ? { ...t, a: j(t.a, o, n) } : { ...t, b: j(t.b, o, n) };
1325
+ }, V = (t, e, n = []) => {
1326
+ if (_(t))
1258
1327
  return t.groupId === e ? { splitPath: null, side: null } : null;
1259
- if (M(t.a) && t.a.groupId === e)
1260
- return { splitPath: r, side: "a" };
1261
- if (M(t.b) && t.b.groupId === e)
1262
- return { splitPath: r, side: "b" };
1263
- const n = U(t.a, e, [...r, "a"]);
1264
- return n || U(t.b, e, [...r, "b"]);
1265
- }, It = (t, e, r, n) => {
1266
- const o = n(), s = U(t, e), a = {
1328
+ if (_(t.a) && t.a.groupId === e)
1329
+ return { splitPath: n, side: "a" };
1330
+ if (_(t.b) && t.b.groupId === e)
1331
+ return { splitPath: n, side: "b" };
1332
+ const r = V(t.a, e, [...n, "a"]);
1333
+ return r || V(t.b, e, [...n, "b"]);
1334
+ }, Tt = (t, e, n, r) => {
1335
+ const o = r(), s = V(t, e), a = {
1267
1336
  type: "split",
1268
- direction: r,
1337
+ direction: n,
1269
1338
  ratio: 0.5,
1270
1339
  a: { type: "group", groupId: e },
1271
1340
  b: { type: "group", groupId: o }
1272
1341
  };
1273
1342
  if (!s || s.splitPath === null)
1274
1343
  return { tree: a, newGroupId: o };
1275
- const i = s.splitPath, c = W(t, i);
1276
- if (M(c))
1344
+ const i = s.splitPath, c = q(t, i);
1345
+ if (_(c))
1277
1346
  return { tree: a, newGroupId: o };
1278
- const u = s.side === "a" ? { ...c, a } : { ...c, b: a };
1279
- return { tree: F(t, i, u), newGroupId: o };
1280
- }, Me = (t, e) => {
1281
- const r = U(t, e);
1282
- if (!r || r.splitPath === null)
1347
+ const d = s.side === "a" ? { ...c, a } : { ...c, b: a };
1348
+ return { tree: j(t, i, d), newGroupId: o };
1349
+ }, Ne = (t, e) => {
1350
+ const n = V(t, e);
1351
+ if (!n || n.splitPath === null)
1283
1352
  return { tree: t, survivorGroupId: e };
1284
- const n = r.splitPath, o = W(t, n);
1285
- if (M(o))
1353
+ const r = n.splitPath, o = q(t, r);
1354
+ if (_(o))
1286
1355
  return { tree: t, survivorGroupId: e };
1287
- const s = r.side === "a" ? o.b : o.a, a = F(t, n, s), i = M(s) ? s.groupId : Y(s)[0] ?? null;
1356
+ const s = n.side === "a" ? o.b : o.a, a = j(t, r, s), i = _(s) ? s.groupId : Y(s)[0] ?? null;
1288
1357
  return { tree: a, survivorGroupId: i };
1289
- }, Oe = (t, e, r) => {
1290
- const n = W(t, e);
1291
- if (M(n))
1358
+ }, ze = (t, e, n) => {
1359
+ const r = q(t, e);
1360
+ if (_(r))
1292
1361
  return t;
1293
- const o = { ...n, ratio: _(r, 0.05, 0.95) };
1294
- return F(t, e, o);
1362
+ const o = { ...r, ratio: M(n, 0.05, 0.95) };
1363
+ return j(t, e, o);
1295
1364
  }, Q = (t) => {
1296
1365
  if (Object.keys(t.groups).filter((o) => t.groups[o].tabIds.length === 0).length === 0)
1297
1366
  return t;
1298
- const n = (o, s) => {
1367
+ const r = (o, s) => {
1299
1368
  const a = o.groups[s];
1300
1369
  if (!a || a.tabs.length > 0 || Object.keys(o.groups).length <= 1)
1301
1370
  return o;
1302
- const { tree: c, survivorGroupId: u } = Me(o.tree, s), { [s]: d, ...g } = o.groups, v = Y(c), T = o.focusedGroupId === s ? u ?? v[0] ?? null : o.focusedGroupId;
1303
- return { ...o, tree: c, groups: g, groupOrder: v, focusedGroupId: T };
1371
+ const { tree: c, survivorGroupId: d } = Ne(o.tree, s), { [s]: u, ...p } = o.groups, g = Y(c), v = o.focusedGroupId === s ? d ?? g[0] ?? null : o.focusedGroupId;
1372
+ return { ...o, tree: c, groups: p, groupOrder: g, focusedGroupId: v };
1304
1373
  };
1305
- return t.groupOrder.reduce((o, s) => n(o, s), t);
1306
- }, Be = (t) => ({ id: t, tabIds: [], tabs: [], activeTabId: null }), it = (t, e, r, n) => {
1374
+ return t.groupOrder.reduce((o, s) => r(o, s), t);
1375
+ }, $e = (t) => ({ id: t, tabIds: [], tabs: [], activeTabId: null }), ut = (t, e, n, r) => {
1307
1376
  const o = { ...t.groups }, s = o[e];
1308
1377
  if (!s)
1309
1378
  throw new Error(`Group ${e} does not exist.`);
1310
- const a = { ...t.panels, [r.id]: r }, i = [...s.tabIds, r.id], c = n ? r.id : s.activeTabId ?? r.id, u = i.map((g) => a[g]), d = { ...s, tabIds: i, tabs: u, activeTabId: c };
1311
- return o[e] = d, { ...t, panels: a, groups: o };
1312
- }, Le = (t, e, r) => {
1313
- const n = { ...t.groups }, o = n[e];
1379
+ const a = { ...t.panels, [n.id]: n }, i = [...s.tabIds, n.id], c = r ? n.id : s.activeTabId ?? n.id, d = i.map((p) => a[p]), u = { ...s, tabIds: i, tabs: d, activeTabId: c };
1380
+ return o[e] = u, { ...t, panels: a, groups: o };
1381
+ }, Fe = (t, e, n) => {
1382
+ const r = { ...t.groups }, o = r[e];
1314
1383
  if (!o)
1315
1384
  throw new Error(`Group ${e} does not exist.`);
1316
- const s = o.tabIds.filter((c) => c !== r), a = s.map((c) => t.panels[c]), i = o.activeTabId === r ? s[0] ?? null : o.activeTabId;
1317
- return n[e] = { ...o, tabIds: s, tabs: a, activeTabId: i }, { ...t, groups: n };
1318
- }, at = (t, e, r, n, o) => {
1319
- const s = t.groups[e], a = t.groups[r];
1385
+ const s = o.tabIds.filter((c) => c !== n), a = s.map((c) => t.panels[c]), i = o.activeTabId === n ? s[0] ?? null : o.activeTabId;
1386
+ return r[e] = { ...o, tabIds: s, tabs: a, activeTabId: i }, { ...t, groups: r };
1387
+ }, lt = (t, e, n, r, o) => {
1388
+ const s = t.groups[e], a = t.groups[n];
1320
1389
  if (!s || !a)
1321
1390
  throw new Error("moveTab: source or target group is missing.");
1322
- const i = { ...t.groups }, c = s.tabIds.filter((g) => g !== n), u = [...a.tabIds.filter((g) => g !== n), n], d = s.activeTabId === n ? c[0] ?? null : s.activeTabId;
1323
- return i[e] = { ...s, tabIds: c, tabs: c.map((g) => t.panels[g]), activeTabId: d }, i[r] = { ...a, tabIds: u, tabs: u.map((g) => t.panels[g]), activeTabId: n }, { ...t, groups: i };
1324
- }, wt = (t, e, r) => {
1325
- const n = t.groups[e];
1326
- if (!n)
1391
+ const i = { ...t.groups }, c = s.tabIds.filter((p) => p !== r), d = [...a.tabIds.filter((p) => p !== r), r], u = s.activeTabId === r ? c[0] ?? null : s.activeTabId;
1392
+ return i[e] = { ...s, tabIds: c, tabs: c.map((p) => t.panels[p]), activeTabId: u }, i[n] = { ...a, tabIds: d, tabs: d.map((p) => t.panels[p]), activeTabId: r }, { ...t, groups: i };
1393
+ }, St = (t, e, n) => {
1394
+ const r = t.groups[e];
1395
+ if (!r)
1327
1396
  throw new Error(`setActiveTab: group ${e} not found.`);
1328
- if (!n.tabIds.some((s) => s === r))
1329
- throw new Error(`setActiveTab: tab ${r} not found in group ${e}.`);
1330
- const o = { ...t.groups, [e]: { ...n, activeTabId: r } };
1397
+ if (!r.tabIds.some((s) => s === n))
1398
+ throw new Error(`setActiveTab: tab ${n} not found in group ${e}.`);
1399
+ const o = { ...t.groups, [e]: { ...r, activeTabId: n } };
1331
1400
  return { ...t, groups: o, focusedGroupId: e };
1332
- }, ct = (t, e, r, n, o) => {
1401
+ }, dt = (t, e, n, r, o) => {
1333
1402
  const s = t.groups[e];
1334
1403
  if (!s)
1335
1404
  throw new Error(`addTabToGroupAtIndex: group ${e} not found.`);
1336
- const a = { ...t.panels, [r.id]: r }, i = s.tabIds.slice(), c = Math.max(0, Math.min(n, i.length));
1337
- i.splice(c, 0, r.id);
1338
- const u = i.map((v) => a[v]), d = o ? r.id : s.activeTabId ?? r.id, g = { ...t.groups, [e]: { ...s, tabIds: i, tabs: u, activeTabId: d } };
1339
- return { ...t, panels: a, groups: g };
1340
- }, $ = (t, e) => {
1405
+ const a = { ...t.panels, [n.id]: n }, i = s.tabIds.slice(), c = Math.max(0, Math.min(r, i.length));
1406
+ i.splice(c, 0, n.id);
1407
+ const d = i.map((g) => a[g]), u = o ? n.id : s.activeTabId ?? n.id, p = { ...t.groups, [e]: { ...s, tabIds: i, tabs: d, activeTabId: u } };
1408
+ return { ...t, panels: a, groups: p };
1409
+ }, N = (t, e) => {
1341
1410
  if (!t.groups[e])
1342
1411
  throw new Error(`setFocusedGroup: group ${e} not found.`);
1343
1412
  return { ...t, focusedGroupId: e };
1344
- }, $e = (t, e) => {
1345
- const r = e - 1, n = t.groupOrder[r];
1346
- return n ? $(t, n) : t;
1347
- }, He = (t) => {
1348
- const e = t.groupOrder, r = t.focusedGroupId;
1349
- if (!r) {
1413
+ }, Xe = (t, e) => {
1414
+ const n = e - 1, r = t.groupOrder[n];
1415
+ return r ? N(t, r) : t;
1416
+ }, Ye = (t) => {
1417
+ const e = t.groupOrder, n = t.focusedGroupId;
1418
+ if (!n) {
1350
1419
  const s = e[0];
1351
- return s ? $(t, s) : t;
1420
+ return s ? N(t, s) : t;
1352
1421
  }
1353
- const n = e.indexOf(r), o = e[(n + 1) % e.length];
1354
- return $(t, o);
1355
- }, Ne = (t) => {
1356
- const e = t.groupOrder, r = t.focusedGroupId;
1357
- if (!r) {
1422
+ const r = e.indexOf(n), o = e[(r + 1) % e.length];
1423
+ return N(t, o);
1424
+ }, je = (t) => {
1425
+ const e = t.groupOrder, n = t.focusedGroupId;
1426
+ if (!n) {
1358
1427
  const s = e[e.length - 1];
1359
- return s ? $(t, s) : t;
1428
+ return s ? N(t, s) : t;
1360
1429
  }
1361
- const n = e.indexOf(r), o = e[(n - 1 + e.length) % e.length];
1362
- return $(t, o);
1363
- }, yt = (t, e, r, n) => {
1364
- const { tree: o, newGroupId: s } = It(t.tree, e, r, n), a = { ...t.groups, [s]: Be(s) }, i = Y(o);
1430
+ const r = e.indexOf(n), o = e[(r - 1 + e.length) % e.length];
1431
+ return N(t, o);
1432
+ }, xt = (t, e, n, r) => {
1433
+ const { tree: o, newGroupId: s } = Tt(t.tree, e, n, r), a = { ...t.groups, [s]: $e(s) }, i = Y(o);
1365
1434
  return { ...t, tree: o, groups: a, groupOrder: i, focusedGroupId: s };
1366
- }, br = (t) => {
1367
- const r = { type: "group", groupId: "g_1" }, n = Object.fromEntries(t.map((i) => [i.id, i])), s = { g_1: { id: "g_1", tabIds: t.map((i) => i.id), tabs: t, activeTabId: t[0]?.id ?? null } };
1368
- return { tree: r, panels: n, groups: s, groupOrder: ["g_1"], focusedGroupId: "g_1" };
1369
- }, ze = l.createContext(null), Xe = ({ value: t, children: e }) => /* @__PURE__ */ m(ze.Provider, { value: t, children: e }), Tt = l.createContext(null), Ye = () => {
1370
- const t = l.useContext(Tt);
1435
+ }, Rn = (t) => {
1436
+ const n = { type: "group", groupId: "g_1" }, r = Object.fromEntries(t.map((i) => [i.id, i])), s = { g_1: { id: "g_1", tabIds: t.map((i) => i.id), tabs: t, activeTabId: t[0]?.id ?? null } };
1437
+ return { tree: n, panels: r, groups: s, groupOrder: ["g_1"], focusedGroupId: "g_1" };
1438
+ }, Ke = l.createContext(null), Ue = ({ value: t, children: e }) => /* @__PURE__ */ m(Ke.Provider, { value: t, children: e }), Gt = l.createContext(null), Ve = () => {
1439
+ const t = l.useContext(Gt);
1371
1440
  if (!t)
1372
1441
  throw new Error("useTree must be used within TreeProvider");
1373
1442
  return t;
1374
- }, Fe = ({ value: t, children: e }) => /* @__PURE__ */ m(Tt.Provider, { value: t, children: e }), je = l.createContext(null), Ve = ({ value: t, children: e }) => /* @__PURE__ */ m(je.Provider, { value: t, children: e }), z = (t) => {
1375
- const e = kt(t, Number.POSITIVE_INFINITY);
1376
- return _(e, 1);
1377
- }, Ke = (t) => typeof t == "object" && t !== null, Ue = (t) => Ke(t) ? "rows" in t ? !0 : "cols" in t : !1, Gt = (t) => {
1443
+ }, We = ({ value: t, children: e }) => /* @__PURE__ */ m(Gt.Provider, { value: t, children: e }), qe = l.createContext(null), Ze = ({ value: t, children: e }) => /* @__PURE__ */ m(qe.Provider, { value: t, children: e }), F = (t) => {
1444
+ const e = Bt(t, Number.POSITIVE_INFINITY);
1445
+ return M(e, 1);
1446
+ }, Je = (t) => typeof t == "object" && t !== null, Qe = (t) => Je(t) ? "rows" in t ? !0 : "cols" in t : !1, Ct = (t) => {
1378
1447
  if (!t)
1379
1448
  return {
1380
1449
  rows: Number.POSITIVE_INFINITY,
1381
1450
  cols: Number.POSITIVE_INFINITY
1382
1451
  };
1383
1452
  if (typeof t == "number") {
1384
- const r = z(t);
1385
- return { rows: r, cols: r };
1453
+ const n = F(t);
1454
+ return { rows: n, cols: n };
1386
1455
  }
1387
- if (Ue(t))
1456
+ if (Qe(t))
1388
1457
  return {
1389
- rows: z(t.rows),
1390
- cols: z(t.cols)
1458
+ rows: F(t.rows),
1459
+ cols: F(t.cols)
1391
1460
  };
1392
1461
  const e = t;
1393
1462
  return {
1394
- rows: z(e.maxHorizontal),
1395
- cols: z(e.maxVertical)
1463
+ rows: F(e.maxHorizontal),
1464
+ cols: F(e.maxVertical)
1396
1465
  };
1397
1466
  }, tt = (t) => {
1398
- if (M(t))
1467
+ if (_(t))
1399
1468
  return { horizontal: 1, vertical: 1 };
1400
- const e = tt(t.a), r = tt(t.b);
1401
- return t.direction === "horizontal" ? { horizontal: e.horizontal + r.horizontal, vertical: Math.max(e.vertical, r.vertical) } : { horizontal: Math.max(e.horizontal, r.horizontal), vertical: e.vertical + r.vertical };
1402
- }, qe = (t, e, r) => {
1403
- const { tree: n } = It(t, e, r, () => "__preview__");
1404
- return n;
1405
- }, rt = (t, e, r, n) => {
1406
- if (!Number.isFinite(n.rows) && !Number.isFinite(n.cols))
1469
+ const e = tt(t.a), n = tt(t.b);
1470
+ return t.direction === "horizontal" ? { horizontal: e.horizontal + n.horizontal, vertical: Math.max(e.vertical, n.vertical) } : { horizontal: Math.max(e.horizontal, n.horizontal), vertical: e.vertical + n.vertical };
1471
+ }, tn = (t, e, n) => {
1472
+ const { tree: r } = Tt(t, e, n, () => "__preview__");
1473
+ return r;
1474
+ }, rt = (t, e, n, r) => {
1475
+ if (!Number.isFinite(r.rows) && !Number.isFinite(r.cols))
1407
1476
  return !0;
1408
- const o = qe(t, e, r), s = tt(o);
1409
- return !(s.horizontal > n.rows || s.vertical > n.cols);
1410
- }, xt = {
1477
+ const o = tn(t, e, n), s = tt(o);
1478
+ return !(s.horizontal > r.rows || s.vertical > r.cols);
1479
+ }, Et = {
1411
1480
  splitFocused: A("panelState/splitFocused", (t) => ({ direction: t })),
1412
1481
  focusGroupIndex: A("panelState/focusGroupIndex", (t) => ({ index1Based: t })),
1413
1482
  focusNextGroup: A("panelState/focusNextGroup"),
@@ -1431,136 +1500,136 @@ const fe = (t, e) => {
1431
1500
  (t) => t
1432
1501
  ),
1433
1502
  adjustSplitRatio: A("panelState/adjustSplitRatio", (t) => t)
1434
- }, We = (t, e, r) => {
1435
- const n = t.groups[e.fromGroupId], o = t.groups[e.targetGroupId];
1436
- if (!n || !o || !n.tabs.find((g) => g.id === e.tabId))
1503
+ }, en = (t, e, n) => {
1504
+ const r = t.groups[e.fromGroupId], o = t.groups[e.targetGroupId];
1505
+ if (!r || !o || !r.tabs.find((p) => p.id === e.tabId))
1437
1506
  return t;
1438
1507
  if (e.zone === "center" && e.fromGroupId === e.targetGroupId)
1439
- return wt(t, e.fromGroupId, e.tabId);
1508
+ return St(t, e.fromGroupId, e.tabId);
1440
1509
  if (e.zone === "center") {
1441
- const g = at(t, e.fromGroupId, e.targetGroupId, e.tabId);
1442
- return $(g, e.targetGroupId);
1510
+ const p = lt(t, e.fromGroupId, e.targetGroupId, e.tabId);
1511
+ return N(p, e.targetGroupId);
1443
1512
  }
1444
1513
  const a = e.zone === "left" || e.zone === "right" ? "vertical" : "horizontal";
1445
- if (!rt(t.tree, e.targetGroupId, a, r.splitLimits))
1514
+ if (!rt(t.tree, e.targetGroupId, a, n.splitLimits))
1446
1515
  return t;
1447
- const i = r.createGroupId(), c = yt(t, e.targetGroupId, a, () => i), u = e.zone === "left" || e.zone === "top" ? e.targetGroupId : i, d = at(c, e.fromGroupId, u, e.tabId);
1448
- return $(d, u);
1449
- }, Ze = (t, e) => {
1450
- const r = t.groups[e.fromGroupId], n = t.groups[e.targetGroupId];
1451
- if (!r || !n || !t.panels[e.tabId])
1516
+ const i = n.createGroupId(), c = xt(t, e.targetGroupId, a, () => i), d = e.zone === "left" || e.zone === "top" ? e.targetGroupId : i, u = lt(c, e.fromGroupId, d, e.tabId);
1517
+ return N(u, d);
1518
+ }, nn = (t, e) => {
1519
+ const n = t.groups[e.fromGroupId], r = t.groups[e.targetGroupId];
1520
+ if (!n || !r || !t.panels[e.tabId])
1452
1521
  return t;
1453
1522
  if (e.fromGroupId === e.targetGroupId) {
1454
- const v = r.tabIds.filter((y) => y !== e.tabId), T = Math.max(0, Math.min(e.targetIndex, v.length)), h = v.slice(0, T).concat([e.tabId], v.slice(T)), w = h.map((y) => t.panels[y]).filter(Boolean), b = { ...t.groups, [e.fromGroupId]: { ...r, tabIds: h, tabs: w } };
1455
- return { ...t, groups: b };
1523
+ const g = n.tabIds.filter((T) => T !== e.tabId), v = Math.max(0, Math.min(e.targetIndex, g.length)), h = g.slice(0, v).concat([e.tabId], g.slice(v)), y = h.map((T) => t.panels[T]).filter(Boolean), w = { ...t.groups, [e.fromGroupId]: { ...n, tabIds: h, tabs: y } };
1524
+ return { ...t, groups: w };
1456
1525
  }
1457
- const s = { ...t.groups }, a = r.tabIds.filter((v) => v !== e.tabId), i = a.map((v) => t.panels[v]);
1526
+ const s = { ...t.groups }, a = n.tabIds.filter((g) => g !== e.tabId), i = a.map((g) => t.panels[g]);
1458
1527
  s[e.fromGroupId] = {
1459
- ...r,
1528
+ ...n,
1460
1529
  tabIds: a,
1461
1530
  tabs: i,
1462
- activeTabId: r.activeTabId === e.tabId ? i[0]?.id ?? null : r.activeTabId
1531
+ activeTabId: n.activeTabId === e.tabId ? i[0]?.id ?? null : n.activeTabId
1463
1532
  };
1464
- const c = n.tabIds.filter((v) => v !== e.tabId), u = Math.max(0, Math.min(e.targetIndex, c.length)), d = c.slice(0, u).concat([e.tabId], c.slice(u)), g = d.map((v) => t.panels[v]).filter(Boolean);
1465
- return s[e.targetGroupId] = { ...n, tabIds: d, tabs: g, activeTabId: e.tabId }, { ...t, groups: s, focusedGroupId: e.targetGroupId };
1466
- }, Je = ht(xt, {
1467
- splitFocused: (t, e, r) => {
1468
- const n = t.focusedGroupId ?? t.groupOrder[0] ?? null;
1469
- return !n || !rt(t.tree, n, e.payload.direction, r.splitLimits) ? t : yt(t, n, e.payload.direction, r.createGroupId);
1533
+ const c = r.tabIds.filter((g) => g !== e.tabId), d = Math.max(0, Math.min(e.targetIndex, c.length)), u = c.slice(0, d).concat([e.tabId], c.slice(d)), p = u.map((g) => t.panels[g]).filter(Boolean);
1534
+ return s[e.targetGroupId] = { ...r, tabIds: u, tabs: p, activeTabId: e.tabId }, { ...t, groups: s, focusedGroupId: e.targetGroupId };
1535
+ }, rn = It(Et, {
1536
+ splitFocused: (t, e, n) => {
1537
+ const r = t.focusedGroupId ?? t.groupOrder[0] ?? null;
1538
+ return !r || !rt(t.tree, r, e.payload.direction, n.splitLimits) ? t : xt(t, r, e.payload.direction, n.createGroupId);
1470
1539
  },
1471
- focusGroupIndex: (t, e) => $e(t, e.payload.index1Based),
1472
- focusNextGroup: (t) => He(t),
1473
- focusPrevGroup: (t) => Ne(t),
1474
- setActiveTab: (t, e) => wt(t, e.payload.groupId, e.payload.tabId),
1540
+ focusGroupIndex: (t, e) => Xe(t, e.payload.index1Based),
1541
+ focusNextGroup: (t) => Ye(t),
1542
+ focusPrevGroup: (t) => je(t),
1543
+ setActiveTab: (t, e) => St(t, e.payload.groupId, e.payload.tabId),
1475
1544
  addTab: (t, e) => {
1476
- const { groupId: r, tab: n, index: o, makeActive: s } = e.payload;
1477
- return typeof o == "number" ? ct(t, r, n, o, s ?? !0) : it(t, r, n, s ?? !0);
1545
+ const { groupId: n, tab: r, index: o, makeActive: s } = e.payload;
1546
+ return typeof o == "number" ? dt(t, n, r, o, s ?? !0) : ut(t, n, r, s ?? !0);
1478
1547
  },
1479
- addNewTab: (t, e, r) => {
1480
- if (!r.createPanelId)
1548
+ addNewTab: (t, e, n) => {
1549
+ if (!n.createPanelId)
1481
1550
  throw new Error("addNewTab requires PanelSystemProvider.createPanelId");
1482
- const o = { id: r.createPanelId(), title: e.payload.title, render: () => e.payload.title }, { groupId: s, index: a, makeActive: i } = e.payload;
1483
- return typeof a == "number" ? ct(t, s, o, a, i ?? !0) : it(t, s, o, i ?? !0);
1551
+ const o = { id: n.createPanelId(), title: e.payload.title, render: () => e.payload.title }, { groupId: s, index: a, makeActive: i } = e.payload;
1552
+ return typeof a == "number" ? dt(t, s, o, a, i ?? !0) : ut(t, s, o, i ?? !0);
1484
1553
  },
1485
- removeTab: (t, e) => Le(t, e.payload.groupId, e.payload.tabId),
1486
- contentDrop: (t, e, r) => We(t, e.payload, r),
1487
- tabDrop: (t, e) => Ze(t, e.payload),
1554
+ removeTab: (t, e) => Fe(t, e.payload.groupId, e.payload.tabId),
1555
+ contentDrop: (t, e, n) => en(t, e.payload, n),
1556
+ tabDrop: (t, e) => nn(t, e.payload),
1488
1557
  adjustSplitRatio: (t, e) => {
1489
- const r = W(t.tree, e.payload.path);
1490
- if (M(r))
1558
+ const n = q(t.tree, e.payload.path);
1559
+ if (_(n))
1491
1560
  return t;
1492
- const n = Oe(t.tree, e.payload.path, r.ratio + e.payload.deltaRatio);
1493
- return { ...t, tree: n };
1561
+ const r = ze(t.tree, e.payload.path, n.ratio + e.payload.deltaRatio);
1562
+ return { ...t, tree: r };
1494
1563
  }
1495
- }), ut = (t, e, r) => {
1496
- const n = Je[e.type];
1497
- if (!n)
1564
+ }), pt = (t, e, n) => {
1565
+ const r = rn[e.type];
1566
+ if (!r)
1498
1567
  return t;
1499
- const o = n(t, e, r);
1568
+ const o = r(t, e, n);
1500
1569
  return Q(o);
1501
- }, St = l.createContext(null), j = () => {
1502
- const t = l.useContext(St);
1570
+ }, Rt = l.createContext(null), $ = () => {
1571
+ const t = l.useContext(Rt);
1503
1572
  if (!t)
1504
1573
  throw new Error("usePanelSystem must be used within PanelSystemProvider");
1505
1574
  return t;
1506
- }, Qe = ({
1575
+ }, on = ({
1507
1576
  initialState: t,
1508
1577
  createGroupId: e,
1509
- createPanelId: r,
1510
- state: n,
1578
+ createPanelId: n,
1579
+ state: r,
1511
1580
  onStateChange: o,
1512
1581
  splitLimits: s,
1513
1582
  children: a
1514
1583
  }) => {
1515
- const i = l.useMemo(() => Q(t), [t]), c = l.useMemo(() => Gt(s), [s]), u = l.useRef({ createGroupId: e, splitLimits: c, createPanelId: r });
1516
- u.current.createGroupId = e, u.current.splitLimits = c, u.current.createPanelId = r;
1517
- const [d, g] = l.useReducer(
1518
- (G, E) => ut(G, E, u.current),
1584
+ const i = l.useMemo(() => Q(t), [t]), c = l.useMemo(() => Ct(s), [s]), d = l.useRef({ createGroupId: e, splitLimits: c, createPanelId: n });
1585
+ d.current.createGroupId = e, d.current.splitLimits = c, d.current.createPanelId = n;
1586
+ const [u, p] = l.useReducer(
1587
+ (S, C) => pt(S, C, d.current),
1519
1588
  i
1520
- ), v = l.useMemo(
1521
- () => n ? Q(n) : d,
1522
- [n, d]
1523
- ), T = l.useRef(v);
1524
- T.current = v;
1525
- const h = n !== void 0, w = l.useCallback(
1526
- (G) => {
1589
+ ), g = l.useMemo(
1590
+ () => r ? Q(r) : u,
1591
+ [r, u]
1592
+ ), v = l.useRef(g);
1593
+ v.current = g;
1594
+ const h = r !== void 0, y = l.useCallback(
1595
+ (S) => {
1527
1596
  if (h) {
1528
- const E = ut(T.current, G, u.current);
1529
- o?.(E);
1597
+ const C = pt(v.current, S, d.current);
1598
+ o?.(C);
1530
1599
  return;
1531
1600
  }
1532
- g(G);
1601
+ p(S);
1533
1602
  },
1534
- [h, o, g]
1535
- ), b = l.useMemo(() => fe(xt, w), [w]), y = l.useMemo(
1603
+ [h, o, p]
1604
+ ), w = l.useMemo(() => ve(Et, y), [y]), T = l.useMemo(
1536
1605
  () => ({
1537
- setActiveTab: b.setActiveTab,
1538
- tabDrop: b.tabDrop
1606
+ setActiveTab: w.setActiveTab,
1607
+ tabDrop: w.tabDrop
1539
1608
  }),
1540
- [b]
1541
- ), f = l.useMemo(
1609
+ [w]
1610
+ ), b = l.useMemo(
1542
1611
  () => ({
1543
- adjustSplitRatio: b.adjustSplitRatio
1612
+ adjustSplitRatio: w.adjustSplitRatio
1544
1613
  }),
1545
- [b]
1614
+ [w]
1546
1615
  ), I = l.useMemo(
1547
1616
  () => ({
1548
- focusGroupIndex: b.focusGroupIndex,
1549
- focusNextGroup: b.focusNextGroup,
1550
- focusPrevGroup: b.focusPrevGroup
1617
+ focusGroupIndex: w.focusGroupIndex,
1618
+ focusNextGroup: w.focusNextGroup,
1619
+ focusPrevGroup: w.focusPrevGroup
1551
1620
  }),
1552
- [b]
1553
- ), p = l.useMemo(
1621
+ [w]
1622
+ ), f = l.useMemo(
1554
1623
  () => ({
1555
- state: v,
1556
- dispatch: w,
1557
- actions: b
1624
+ state: g,
1625
+ dispatch: y,
1626
+ actions: w
1558
1627
  }),
1559
- [v, w, b]
1628
+ [g, y, w]
1560
1629
  );
1561
- return /* @__PURE__ */ m(St.Provider, { value: p, children: /* @__PURE__ */ m(Xe, { value: y, children: /* @__PURE__ */ m(Fe, { value: f, children: /* @__PURE__ */ m(Ve, { value: I, children: a }) }) }) });
1562
- }, tr = () => {
1563
- const { actions: t } = j();
1630
+ return /* @__PURE__ */ m(Rt.Provider, { value: f, children: /* @__PURE__ */ m(Ue, { value: T, children: /* @__PURE__ */ m(We, { value: b, children: /* @__PURE__ */ m(Ze, { value: I, children: a }) }) }) });
1631
+ }, sn = () => {
1632
+ const { actions: t } = $();
1564
1633
  return l.useMemo(
1565
1634
  () => ({
1566
1635
  splitFocused: (e) => {
@@ -1580,269 +1649,341 @@ const fe = (t, e) => {
1580
1649
  }),
1581
1650
  [t]
1582
1651
  );
1583
- }, er = () => {
1584
- const { actions: t } = j(), e = l.useCallback(
1585
- ({ fromGroupId: n, tabId: o, targetGroupId: s, zone: a }) => {
1586
- t.contentDrop({ fromGroupId: n, tabId: o, targetGroupId: s, zone: a });
1652
+ }, an = () => {
1653
+ const { actions: t } = $(), e = l.useCallback(
1654
+ ({ fromGroupId: r, tabId: o, targetGroupId: s, zone: a }) => {
1655
+ t.contentDrop({ fromGroupId: r, tabId: o, targetGroupId: s, zone: a });
1587
1656
  },
1588
1657
  [t]
1589
- ), r = l.useCallback(
1590
- ({ fromGroupId: n, tabId: o, targetGroupId: s, targetIndex: a }) => {
1591
- t.tabDrop({ fromGroupId: n, tabId: o, targetGroupId: s, targetIndex: a });
1658
+ ), n = l.useCallback(
1659
+ ({ fromGroupId: r, tabId: o, targetGroupId: s, targetIndex: a }) => {
1660
+ t.tabDrop({ fromGroupId: r, tabId: o, targetGroupId: s, targetIndex: a });
1592
1661
  },
1593
1662
  [t]
1594
1663
  );
1595
- return { onCommitContentDrop: e, onCommitTabDrop: r };
1596
- }, rr = () => {
1597
- const t = Jt(), e = tr();
1664
+ return { onCommitContentDrop: e, onCommitTabDrop: n };
1665
+ }, cn = () => {
1666
+ const t = re(), e = sn();
1598
1667
  return l.useEffect(() => {
1599
- ee(t, e);
1668
+ ie(t, e);
1600
1669
  }, [t, e]), null;
1601
- }, nr = ({
1670
+ }, Pt = l.createContext(null), un = () => {
1671
+ const t = l.useContext(Pt);
1672
+ if (!t)
1673
+ throw new Error("useContentRegistry must be used within ContentRegistryProvider");
1674
+ return t;
1675
+ }, ln = (t) => {
1676
+ const e = document.createElement("div");
1677
+ return e.setAttribute("data-panel-wrapper", t), e.style.display = "contents", e;
1678
+ }, dn = (t, e, n) => {
1679
+ const [r] = l.useState(() => ln(t));
1680
+ return nt(() => (r.style.display = n ? "contents" : "none", e && r.parentElement !== e && e.appendChild(r), () => {
1681
+ r.parentElement?.removeChild(r);
1682
+ }), [r, e, n]), r;
1683
+ }, Dt = l.memo(
1684
+ ({ panelId: t, content: e, placement: n, containerElement: r }) => {
1685
+ const o = n?.isActive ?? !1, s = dn(t, r, o);
1686
+ return ee(
1687
+ /* @__PURE__ */ m(l.Activity, { mode: o ? "visible" : "hidden", children: e }),
1688
+ s
1689
+ );
1690
+ }
1691
+ );
1692
+ Dt.displayName = "PanelContentHost";
1693
+ const pn = ({
1694
+ children: t,
1695
+ panels: e,
1696
+ placements: n
1697
+ }) => {
1698
+ const [r, o] = l.useState(/* @__PURE__ */ new Map()), s = l.useRef(/* @__PURE__ */ new Map()), a = l.useCallback((u, p) => {
1699
+ o((g) => {
1700
+ const v = new Map(g);
1701
+ return p ? v.set(u, p) : v.delete(u), v;
1702
+ });
1703
+ }, []), i = l.useMemo(
1704
+ () => ({ registerContentContainer: a }),
1705
+ [a]
1706
+ ), c = l.useCallback((u, p) => {
1707
+ const g = s.current.get(u);
1708
+ if (g)
1709
+ return g;
1710
+ const v = p.render(p.id);
1711
+ return s.current.set(u, v), v;
1712
+ }, []), d = Object.keys(e);
1713
+ return /* @__PURE__ */ H(Pt.Provider, { value: i, children: [
1714
+ t,
1715
+ d.map((u) => {
1716
+ const p = e[u];
1717
+ if (!p)
1718
+ return null;
1719
+ const g = n[u] ?? null, v = g ? r.get(g.groupId) ?? null : null, h = c(u, p);
1720
+ return /* @__PURE__ */ m(
1721
+ Dt,
1722
+ {
1723
+ panelId: u,
1724
+ content: h,
1725
+ placement: g,
1726
+ containerElement: v
1727
+ },
1728
+ u
1729
+ );
1730
+ })
1731
+ ] });
1732
+ }, fn = ({
1602
1733
  children: t,
1603
1734
  emptyContentComponent: e,
1604
- doubleClickToAdd: r
1735
+ doubleClickToAdd: n
1605
1736
  }) => {
1606
- const n = q(), { state: o, actions: s } = j(), a = l.useCallback(() => l.createElement("div", { style: { color: "#888", fontSize: 12, padding: 12 } }, "No tabs"), []), i = e ?? a, c = l.useCallback(
1607
- (b) => {
1608
- const y = o.groups[b];
1609
- if (!y)
1737
+ const r = W(), { state: o, actions: s } = $(), { registerContentContainer: a } = un(), i = l.useCallback(() => l.createElement("div", { style: { color: "#888", fontSize: 12, padding: 12 } }, "No tabs"), []), c = e ?? i, d = l.useCallback(
1738
+ (T) => {
1739
+ const b = o.groups[T];
1740
+ if (!b)
1610
1741
  return null;
1611
- const f = y.tabIds.map((I) => o.panels[I]).filter(Boolean);
1612
- return { ...y, tabs: f };
1742
+ const I = b.tabIds.map((f) => o.panels[f]).filter(Boolean);
1743
+ return { ...b, tabs: I };
1613
1744
  },
1614
1745
  [o.groups, o.panels]
1615
1746
  ), u = l.useCallback(
1616
- (b) => {
1617
- const y = o.groups[b];
1618
- if (!y)
1619
- return /* @__PURE__ */ m(i, {});
1620
- const f = y.activeTabId;
1621
- if (!f)
1622
- return /* @__PURE__ */ m(i, {});
1623
- const I = o.panels[f];
1624
- return I ? I.render() : /* @__PURE__ */ m(i, {});
1747
+ (T) => {
1748
+ const b = o.groups[T];
1749
+ return !b || b.tabIds.length === 0 ? /* @__PURE__ */ m(c, {}) : null;
1625
1750
  },
1626
- [o.groups, o.panels, i]
1627
- ), d = l.useCallback((b, y) => {
1628
- s.setActiveTab(b, y);
1629
- }, [s]), g = l.useCallback((b) => {
1630
- s.addNewTab({ groupId: b, title: "New Tab", makeActive: !0 });
1631
- }, [s]), v = l.useCallback((b, y) => {
1632
- s.removeTab(b, y);
1633
- }, [s]), T = l.useCallback((b, y, f) => {
1634
- s.setActiveTab(y, b), n.onStartTabDrag(b, y, f);
1635
- }, [s, n]), h = l.useCallback((b, y) => {
1636
- const f = o.groups[b];
1637
- !f || !f.activeTabId || n.onStartContentDrag(b, f.activeTabId, y);
1638
- }, [o.groups, n]), w = l.useMemo(
1639
- () => ({ getGroup: c, getGroupContent: u, onClickTab: d, onAddTab: g, onCloseTab: v, onStartTabDrag: T, onStartContentDrag: h, doubleClickToAdd: r }),
1640
- [c, u, d, g, v, T, h, r]
1751
+ [o.groups, c]
1752
+ ), p = l.useCallback((T, b) => {
1753
+ s.setActiveTab(T, b);
1754
+ }, [s]), g = l.useCallback((T) => {
1755
+ s.addNewTab({ groupId: T, title: "New Tab", makeActive: !0 });
1756
+ }, [s]), v = l.useCallback((T, b) => {
1757
+ s.removeTab(T, b);
1758
+ }, [s]), h = l.useCallback((T, b, I) => {
1759
+ s.setActiveTab(b, T), r.onStartTabDrag(T, b, I);
1760
+ }, [s, r]), y = l.useCallback((T, b) => {
1761
+ const I = o.groups[T];
1762
+ !I || !I.activeTabId || r.onStartContentDrag(T, I.activeTabId, b);
1763
+ }, [o.groups, r]), w = l.useMemo(
1764
+ () => ({ getGroup: d, getGroupContent: u, onClickTab: p, onAddTab: g, onCloseTab: v, onStartTabDrag: h, onStartContentDrag: y, doubleClickToAdd: n, registerContentContainer: a }),
1765
+ [d, u, p, g, v, h, y, n, a]
1641
1766
  );
1642
- return /* @__PURE__ */ m(ie, { value: w, children: t });
1643
- }, X = (t, e, r, n) => {
1644
- if (M(t))
1645
- return n;
1646
- const o = t.direction, s = o === "vertical" ? r.x + r.w * t.ratio : r.y + r.h * t.ratio;
1647
- if (n.push({ path: e, direction: o, parentRect: r, linePos: s }), o === "vertical") {
1648
- const c = r.w * t.ratio, u = r.w - c;
1649
- return X(t.a, [...e, "a"], { x: r.x, y: r.y, w: c, h: r.h }, n), X(t.b, [...e, "b"], { x: r.x + c, y: r.y, w: u, h: r.h }, n), n;
1767
+ return /* @__PURE__ */ m(de, { value: w, children: t });
1768
+ }, gn = ({
1769
+ children: t,
1770
+ emptyContentComponent: e,
1771
+ doubleClickToAdd: n
1772
+ }) => {
1773
+ const { state: r } = $(), o = l.useMemo(() => {
1774
+ const s = {};
1775
+ for (const [a, i] of Object.entries(r.groups))
1776
+ for (const c of i.tabIds)
1777
+ s[c] = {
1778
+ groupId: a,
1779
+ isActive: c === i.activeTabId
1780
+ };
1781
+ return s;
1782
+ }, [r.groups]);
1783
+ return /* @__PURE__ */ m(pn, { panels: r.panels, placements: o, children: /* @__PURE__ */ m(fn, { emptyContentComponent: e, doubleClickToAdd: n, children: t }) });
1784
+ }, X = (t, e, n, r) => {
1785
+ if (_(t))
1786
+ return r;
1787
+ const o = t.direction, s = o === "vertical" ? n.x + n.w * t.ratio : n.y + n.h * t.ratio;
1788
+ if (r.push({ path: e, direction: o, parentRect: n, linePos: s }), o === "vertical") {
1789
+ const c = n.w * t.ratio, d = n.w - c;
1790
+ return X(t.a, [...e, "a"], { x: n.x, y: n.y, w: c, h: n.h }, r), X(t.b, [...e, "b"], { x: n.x + c, y: n.y, w: d, h: n.h }, r), r;
1650
1791
  }
1651
- const a = r.h * t.ratio, i = r.h - a;
1652
- return X(t.a, [...e, "a"], { x: r.x, y: r.y, w: r.w, h: a }, n), X(t.b, [...e, "b"], { x: r.x, y: r.y + a, w: r.w, h: i }, n), n;
1653
- }, or = ({ containerRef: t }) => {
1654
- const { state: e } = j(), { adjustSplitRatio: r } = Ye(), n = l.useMemo(() => X(e.tree, [], { x: 0, y: 0, w: 100, h: 100 }, []), [e.tree]), [o, s] = l.useState(null);
1655
- if (l.useLayoutEffect(() => {
1792
+ const a = n.h * t.ratio, i = n.h - a;
1793
+ return X(t.a, [...e, "a"], { x: n.x, y: n.y, w: n.w, h: a }, r), X(t.b, [...e, "b"], { x: n.x, y: n.y + a, w: n.w, h: i }, r), r;
1794
+ }, bn = ({ containerRef: t }) => {
1795
+ const { state: e } = $(), { adjustSplitRatio: n } = Ve(), r = l.useMemo(() => X(e.tree, [], { x: 0, y: 0, w: 100, h: 100 }, []), [e.tree]), [o, s] = l.useState(null);
1796
+ if (nt(() => {
1656
1797
  const i = t.current;
1657
1798
  if (!i)
1658
1799
  return;
1659
1800
  const c = () => {
1660
- const T = i.getBoundingClientRect();
1661
- s({ left: T.left, top: T.top, width: T.width, height: T.height });
1801
+ const v = i.getBoundingClientRect();
1802
+ s({ left: v.left, top: v.top, width: v.width, height: v.height });
1662
1803
  };
1663
1804
  c();
1664
- function u() {
1805
+ function d() {
1665
1806
  try {
1666
- const T = window.ResizeObserver;
1667
- return typeof T == "function" ? T : null;
1807
+ const v = window.ResizeObserver;
1808
+ return typeof v == "function" ? v : null;
1668
1809
  } catch {
1669
1810
  return null;
1670
1811
  }
1671
1812
  }
1672
- const d = u(), g = d ? new d(() => c()) : null;
1673
- g && g.observe(i);
1674
- const v = () => c();
1675
- return window.addEventListener("scroll", v, !0), () => {
1676
- window.removeEventListener("scroll", v, !0), g && g.disconnect();
1813
+ const u = d(), p = u ? new u(() => c()) : null;
1814
+ p && p.observe(i);
1815
+ const g = () => c();
1816
+ return window.addEventListener("scroll", g, !0), () => {
1817
+ window.removeEventListener("scroll", g, !0), p && p.disconnect();
1677
1818
  };
1678
1819
  }, [t, e.tree]), !o)
1679
1820
  return null;
1680
1821
  const a = (i, c) => {
1681
- const u = {
1822
+ const d = {
1682
1823
  left: o.left + o.width * i.parentRect.x / 100,
1683
1824
  top: o.top + o.height * i.parentRect.y / 100,
1684
1825
  width: o.width * i.parentRect.w / 100,
1685
1826
  height: o.height * i.parentRect.h / 100
1686
- }, d = Wt;
1827
+ }, u = te;
1687
1828
  if (i.direction === "vertical") {
1688
- const h = u.left + u.width * (i.linePos - i.parentRect.x) / i.parentRect.w, w = {
1829
+ const h = d.left + d.width * (i.linePos - i.parentRect.x) / i.parentRect.w, y = {
1689
1830
  position: "fixed",
1690
- left: `calc(${Math.round(h)}px - ${d} / 2)`,
1691
- top: Math.round(u.top),
1692
- width: d,
1693
- height: Math.round(u.height),
1831
+ left: `calc(${Math.round(h)}px - ${u} / 2)`,
1832
+ top: Math.round(d.top),
1833
+ width: u,
1834
+ height: Math.round(d.height),
1694
1835
  cursor: "col-resize",
1695
1836
  pointerEvents: "auto"
1696
1837
  };
1697
- return /* @__PURE__ */ m("div", { style: w, children: /* @__PURE__ */ m(nt, { direction: "vertical", onResize: (y) => {
1698
- const f = o.width * i.parentRect.w / 100, I = f === 0 ? 0 : y / f;
1699
- r({ path: i.path, deltaRatio: I });
1838
+ return /* @__PURE__ */ m("div", { style: y, children: /* @__PURE__ */ m(ot, { direction: "vertical", onResize: (T) => {
1839
+ const b = o.width * i.parentRect.w / 100, I = b === 0 ? 0 : T / b;
1840
+ n({ path: i.path, deltaRatio: I });
1700
1841
  } }) }, `split-${c}`);
1701
1842
  }
1702
- const g = u.top + u.height * (i.linePos - i.parentRect.y) / i.parentRect.h, v = {
1843
+ const p = d.top + d.height * (i.linePos - i.parentRect.y) / i.parentRect.h, g = {
1703
1844
  position: "fixed",
1704
- left: Math.round(u.left),
1705
- top: `calc(${Math.round(g)}px - ${d} / 2)`,
1706
- width: Math.round(u.width),
1707
- height: d,
1845
+ left: Math.round(d.left),
1846
+ top: `calc(${Math.round(p)}px - ${u} / 2)`,
1847
+ width: Math.round(d.width),
1848
+ height: u,
1708
1849
  cursor: "row-resize",
1709
1850
  pointerEvents: "auto"
1710
1851
  };
1711
- return /* @__PURE__ */ m("div", { style: v, children: /* @__PURE__ */ m(nt, { direction: "horizontal", onResize: (h) => {
1712
- const w = o.height * i.parentRect.h / 100, b = w === 0 ? 0 : h / w;
1713
- r({ path: i.path, deltaRatio: b });
1852
+ return /* @__PURE__ */ m("div", { style: g, children: /* @__PURE__ */ m(ot, { direction: "horizontal", onResize: (h) => {
1853
+ const y = o.height * i.parentRect.h / 100, w = y === 0 ? 0 : h / y;
1854
+ n({ path: i.path, deltaRatio: w });
1714
1855
  } }) }, `split-${c}`);
1715
1856
  };
1716
- return /* @__PURE__ */ m("div", { style: { position: "fixed", inset: 0, pointerEvents: "none" }, children: n.map((i, c) => a(i, c)) });
1717
- }, sr = {
1857
+ return /* @__PURE__ */ m("div", { style: { position: "fixed", inset: 0, pointerEvents: "none" }, children: r.map((i, c) => a(i, c)) });
1858
+ }, hn = {
1718
1859
  position: "relative",
1719
1860
  display: "flex",
1720
1861
  width: "100%",
1721
1862
  height: "100%"
1722
- }, ir = ({
1863
+ }, mn = ({
1723
1864
  state: t,
1724
1865
  layoutMode: e,
1725
- gridTracksInteractive: r,
1726
- view: n,
1866
+ gridTracksInteractive: n,
1867
+ view: r,
1727
1868
  tabBarComponent: o,
1728
1869
  panelGroupComponent: s
1729
1870
  }) => {
1730
- const a = (c) => n ? /* @__PURE__ */ m(n, { groupId: c }) : /* @__PURE__ */ m(ye, { id: c, TabBarComponent: o, PanelGroupComponent: s });
1871
+ const a = (c) => r ? /* @__PURE__ */ m(r, { groupId: c }) : /* @__PURE__ */ m(Ce, { id: c, TabBarComponent: o, PanelGroupComponent: s });
1731
1872
  if (e === "grid") {
1732
- const c = oe(t, a, !!r);
1733
- return /* @__PURE__ */ m(ot, { config: c.config, layers: c.layers });
1873
+ const c = ue(t, a, !!n);
1874
+ return /* @__PURE__ */ m(st, { config: c.config, layers: c.layers });
1734
1875
  }
1735
- const i = ne(t, a);
1736
- return /* @__PURE__ */ m(ot, { config: i.config, layers: i.layers });
1737
- }, ar = ({
1876
+ const i = ce(t, a);
1877
+ return /* @__PURE__ */ m(st, { config: i.config, layers: i.layers });
1878
+ }, vn = ({
1738
1879
  containerRef: t,
1739
1880
  layoutMode: e,
1740
- gridTracksInteractive: r,
1741
- dragThresholdPx: n,
1881
+ gridTracksInteractive: n,
1882
+ dragThresholdPx: r,
1742
1883
  view: o,
1743
1884
  style: s,
1744
1885
  className: a,
1745
1886
  tabBarComponent: i,
1746
1887
  panelGroupComponent: c,
1747
- splitLimits: u,
1748
- emptyContentComponent: d,
1749
- doubleClickToAdd: g
1888
+ splitLimits: d,
1889
+ emptyContentComponent: u,
1890
+ doubleClickToAdd: p
1750
1891
  }) => {
1751
- const { state: v } = j(), { onCommitContentDrop: T, onCommitTabDrop: h } = er(), w = l.useMemo(() => ({ ...sr, ...s }), [s]), b = l.useCallback(
1752
- ({ targetGroupId: y, zone: f }) => {
1753
- if (f === "center")
1892
+ const { state: g } = $(), { onCommitContentDrop: v, onCommitTabDrop: h } = an(), y = l.useMemo(() => ({ ...hn, ...s }), [s]), w = l.useCallback(
1893
+ ({ targetGroupId: T, zone: b }) => {
1894
+ if (b === "center")
1754
1895
  return !0;
1755
- const I = f === "left" || f === "right" ? "vertical" : "horizontal";
1756
- return rt(v.tree, y, I, u);
1896
+ const I = b === "left" || b === "right" ? "vertical" : "horizontal";
1897
+ return rt(g.tree, T, I, d);
1757
1898
  },
1758
- [v.tree, u]
1899
+ [g.tree, d]
1759
1900
  );
1760
- return /* @__PURE__ */ m(ae, { children: /* @__PURE__ */ H(
1761
- he,
1901
+ return /* @__PURE__ */ m(pe, { children: /* @__PURE__ */ H(
1902
+ ye,
1762
1903
  {
1763
1904
  containerRef: t,
1764
- dragThresholdPx: n,
1765
- onCommitContentDrop: T,
1905
+ dragThresholdPx: r,
1906
+ onCommitContentDrop: v,
1766
1907
  onCommitTabDrop: h,
1767
- isContentZoneAllowed: b,
1908
+ isContentZoneAllowed: w,
1768
1909
  children: [
1769
- /* @__PURE__ */ m(nr, { emptyContentComponent: d, doubleClickToAdd: g, children: /* @__PURE__ */ m("div", { ref: t, className: a, style: w, children: /* @__PURE__ */ m(
1770
- ir,
1910
+ /* @__PURE__ */ m(gn, { emptyContentComponent: u, doubleClickToAdd: p, children: /* @__PURE__ */ m("div", { ref: t, className: a, style: y, children: /* @__PURE__ */ m(
1911
+ mn,
1771
1912
  {
1772
- state: v,
1913
+ state: g,
1773
1914
  layoutMode: e,
1774
- gridTracksInteractive: r,
1915
+ gridTracksInteractive: n,
1775
1916
  view: o,
1776
1917
  tabBarComponent: i,
1777
1918
  panelGroupComponent: c
1778
1919
  }
1779
1920
  ) }) }),
1780
- /* @__PURE__ */ m(or, { containerRef: t }),
1781
- /* @__PURE__ */ m(cr, {})
1921
+ /* @__PURE__ */ m(bn, { containerRef: t }),
1922
+ /* @__PURE__ */ m(In, {})
1782
1923
  ]
1783
1924
  }
1784
1925
  ) });
1785
- }, cr = () => {
1786
- const t = q();
1926
+ }, In = () => {
1927
+ const t = W();
1787
1928
  return /* @__PURE__ */ H(et, { children: [
1788
- /* @__PURE__ */ m(Pe, { suggest: t.suggest }),
1789
- /* @__PURE__ */ m(_e, {})
1929
+ /* @__PURE__ */ m(Me, { suggest: t.suggest }),
1930
+ /* @__PURE__ */ m(He, {})
1790
1931
  ] });
1791
- }, gr = ({
1932
+ }, Pn = ({
1792
1933
  initialState: t,
1793
1934
  createGroupId: e,
1794
- createPanelId: r,
1795
- layoutMode: n,
1935
+ createPanelId: n,
1936
+ layoutMode: r,
1796
1937
  gridTracksInteractive: o,
1797
1938
  dragThresholdPx: s,
1798
1939
  view: a,
1799
1940
  emptyContentComponent: i,
1800
1941
  state: c,
1801
- onStateChange: u,
1802
- className: d,
1803
- style: g,
1804
- tabBarComponent: v,
1805
- panelGroupComponent: T,
1942
+ onStateChange: d,
1943
+ className: u,
1944
+ style: p,
1945
+ tabBarComponent: g,
1946
+ panelGroupComponent: v,
1806
1947
  splitLimits: h,
1807
- doubleClickToAdd: w
1948
+ doubleClickToAdd: y
1808
1949
  }) => {
1809
1950
  if (!t)
1810
1951
  throw new Error("PanelSystem requires initialState.");
1811
1952
  if (!e)
1812
1953
  throw new Error("PanelSystem requires explicit createGroupId function.");
1813
- if (!n)
1954
+ if (!r)
1814
1955
  throw new Error("PanelSystem requires explicit layoutMode ('absolute' | 'grid').");
1815
- if (n === "grid" && o === void 0)
1956
+ if (r === "grid" && o === void 0)
1816
1957
  throw new Error("PanelSystem(layoutMode='grid') requires explicit 'gridTracksInteractive' flag.");
1817
1958
  if (s === void 0)
1818
1959
  throw new Error("PanelSystem requires explicit 'dragThresholdPx' value.");
1819
- const b = l.useRef(null), y = l.useMemo(() => Gt(h), [h]);
1960
+ const w = l.useRef(null), T = l.useMemo(() => Ct(h), [h]);
1820
1961
  return /* @__PURE__ */ m(
1821
- Qe,
1962
+ on,
1822
1963
  {
1823
1964
  initialState: t,
1824
1965
  createGroupId: e,
1825
- createPanelId: r,
1966
+ createPanelId: n,
1826
1967
  state: c,
1827
- onStateChange: u,
1968
+ onStateChange: d,
1828
1969
  splitLimits: h,
1829
- children: /* @__PURE__ */ H(te, { children: [
1830
- /* @__PURE__ */ m(rr, {}),
1970
+ children: /* @__PURE__ */ H(se, { children: [
1971
+ /* @__PURE__ */ m(cn, {}),
1831
1972
  /* @__PURE__ */ m(
1832
- ar,
1973
+ vn,
1833
1974
  {
1834
- containerRef: b,
1835
- layoutMode: n,
1975
+ containerRef: w,
1976
+ layoutMode: r,
1836
1977
  gridTracksInteractive: o,
1837
1978
  dragThresholdPx: s,
1838
1979
  view: a,
1839
- style: g,
1840
- className: d,
1841
- tabBarComponent: v,
1842
- panelGroupComponent: T,
1843
- splitLimits: y,
1980
+ style: p,
1981
+ className: u,
1982
+ tabBarComponent: g,
1983
+ panelGroupComponent: v,
1984
+ splitLimits: T,
1844
1985
  emptyContentComponent: i,
1845
- doubleClickToAdd: w
1986
+ doubleClickToAdd: y
1846
1987
  }
1847
1988
  )
1848
1989
  ] })
@@ -1850,16 +1991,18 @@ const fe = (t, e) => {
1850
1991
  );
1851
1992
  };
1852
1993
  export {
1853
- Gr as CSS_VAR_PREFIX,
1854
- vr as Drawer,
1855
- Ir as DrawerLayers,
1856
- ot as GridLayout,
1857
- pr as HorizontalDivider,
1858
- gr as PanelSystem,
1859
- nt as ResizeHandle,
1860
- br as buildInitialState,
1861
- wr as runTransition,
1862
- fr as useLayerDragHandle,
1863
- yr as useTransitionState
1994
+ Hn as CSS_VAR_PREFIX,
1995
+ kn as Drawer,
1996
+ Mn as DrawerLayers,
1997
+ _n as FloatingWindow,
1998
+ st as GridLayout,
1999
+ Gn as HorizontalDivider,
2000
+ Pn as PanelSystem,
2001
+ ot as ResizeHandle,
2002
+ Rn as buildInitialState,
2003
+ On as runTransition,
2004
+ En as useFloatingState,
2005
+ Cn as useLayerDragHandle,
2006
+ Bn as useTransitionState
1864
2007
  };
1865
2008
  //# sourceMappingURL=index.js.map