@pasquelin/panels 0.1.1 → 0.2.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.
package/dist/index.js CHANGED
@@ -1,238 +1,263 @@
1
- import { jsx as d, jsxs as m, Fragment as B } from "react/jsx-runtime";
2
- import k, { useEffect as K, useLayoutEffect as Mn, useState as tn, useMemo as w, useContext as fn, createContext as pn, useRef as j, useCallback as z, memo as hn, Fragment as Rn, Children as Cn, isValidElement as En } from "react";
3
- import { c as v } from "./cx-CcykAxZN.js";
4
- const en = (n) => {
1
+ import { jsx as u, jsxs as m, Fragment as B } from "react/jsx-runtime";
2
+ import F, { useEffect as nn, useLayoutEffect as kn, useState as W, useMemo as y, useContext as tn, createContext as en, useRef as H, useCallback as I, memo as Sn, Fragment as Dn, Children as jn, isValidElement as Hn } from "react";
3
+ import { c as w } from "./cx-CcykAxZN.js";
4
+ const an = (n) => {
5
5
  let t;
6
- const e = /* @__PURE__ */ new Set(), o = (u, a) => {
7
- const f = typeof u == "function" ? u(t) : u;
6
+ const e = /* @__PURE__ */ new Set(), o = (a, d) => {
7
+ const f = typeof a == "function" ? a(t) : a;
8
8
  if (!Object.is(f, t)) {
9
- const p = t;
10
- t = a ?? (typeof f != "object" || f === null) ? f : Object.assign({}, t, f), e.forEach((g) => g(t, p));
9
+ const h = t;
10
+ t = d ?? (typeof f != "object" || f === null) ? f : Object.assign({}, t, f), e.forEach((g) => g(t, h));
11
11
  }
12
- }, s = () => t, c = { setState: o, getState: s, getInitialState: () => l, subscribe: (u) => (e.add(u), () => e.delete(u)) }, l = t = n(o, s, c);
13
- return c;
14
- }, Ln = ((n) => n ? en(n) : en), On = (n) => n;
15
- function Tn(n, t = On) {
16
- const e = k.useSyncExternalStore(
12
+ }, c = () => t, i = { setState: o, getState: c, getInitialState: () => l, subscribe: (a) => (e.add(a), () => e.delete(a)) }, l = t = n(o, c, i);
13
+ return i;
14
+ }, Un = ((n) => n ? an(n) : an), Vn = (n) => n;
15
+ function Yn(n, t = Vn) {
16
+ const e = F.useSyncExternalStore(
17
17
  n.subscribe,
18
- k.useCallback(() => t(n.getState()), [n, t]),
19
- k.useCallback(() => t(n.getInitialState()), [n, t])
18
+ F.useCallback(() => t(n.getState()), [n, t]),
19
+ F.useCallback(() => t(n.getInitialState()), [n, t])
20
20
  );
21
- return k.useDebugValue(e), e;
21
+ return F.useDebugValue(e), e;
22
22
  }
23
- const C = ["left", "right", "top", "bottomLeft", "bottomRight"], $ = ["primary", "secondary"], kn = ["bottomLeft", "bottomRight"];
24
- function U(n) {
23
+ const U = ["left", "right", "top", "bottomLeft", "bottomRight"], Nn = ["primary", "secondary"], on = "default", $n = ["bottomLeft", "bottomRight"];
24
+ function rn(n) {
25
25
  return n === "bottomLeft" || n === "bottomRight";
26
26
  }
27
- function E(n) {
28
- return n === "top" || U(n);
27
+ function M(n) {
28
+ return n === "top" || rn(n);
29
29
  }
30
- const V = {
30
+ const G = {
31
31
  left: { column: ["left", "top"], band: "bottomLeft" },
32
32
  right: { column: ["right"], band: "bottomRight" }
33
33
  };
34
- function on(n) {
34
+ function un(n) {
35
35
  return n === "left" || n === "top";
36
36
  }
37
- const F = 140, gn = 240, R = 100, Bn = {
37
+ const A = 140, Pn = 240, Z = 100, Wn = {
38
38
  left: 320,
39
39
  right: 260,
40
40
  top: 180,
41
41
  bottomLeft: 240,
42
42
  bottomRight: 240
43
- }, mn = "bottomRight";
44
- function A(n) {
45
- return U(n) ? mn : n;
43
+ }, _n = "bottomRight";
44
+ function k(n) {
45
+ return rn(n) ? _n : n;
46
46
  }
47
- const M = {
47
+ const x = {
48
48
  left: "right",
49
49
  right: "left",
50
50
  // The band as a whole faces the top strip: either half of it takes the same height off.
51
- top: mn,
51
+ top: _n,
52
52
  bottomLeft: "top",
53
53
  bottomRight: "top"
54
54
  };
55
- function bn(n, t, e) {
55
+ function In(n, t, e) {
56
56
  return Math.min(Math.max(n, t), e);
57
57
  }
58
- function yn(n, t, e) {
59
- const o = Math.max(F, Math.round(t - e - gn));
60
- return bn(Math.round(n), F, o);
58
+ function xn(n, t, e) {
59
+ const o = Math.max(A, Math.round(t - e - Pn));
60
+ return In(Math.round(n), A, o);
61
61
  }
62
62
  function D(n, t) {
63
- const e = Math.max(R, Math.round(t - R));
64
- return bn(Math.round(n), R, e);
65
- }
66
- function H(n, t) {
67
- const e = n[t];
68
- return e !== void 0 && (e.primary !== void 0 || e.secondary !== void 0);
69
- }
70
- function Fn(n) {
71
- return H(n, "bottomLeft") || H(n, "bottomRight");
72
- }
73
- function vn(n, t, e, o) {
74
- return (U(e) ? Fn(t) : H(t, e)) ? n.sizes[A(e)] ?? o(e) : 0;
75
- }
76
- function An(n, t, e, o, s) {
77
- const r = { ...n.sizes }, i = { ...n.splits };
78
- for (const l of C) {
79
- const u = r[l];
80
- if (u === void 0) continue;
81
- const a = E(l) ? o : e;
82
- r[l] = yn(u, a, vn(n, t, M[l], s));
83
- const f = i[l];
84
- f !== void 0 && (i[l] = D(f, E(l) ? e : o));
63
+ const e = Math.max(Z, Math.round(t - Z));
64
+ return In(Math.round(n), Z, e);
65
+ }
66
+ function Cn(n, t, e, o) {
67
+ return e(t) ? n.sizes[k(t)] ?? o(t) : 0;
68
+ }
69
+ function Gn(n, t, e, o, c) {
70
+ const s = { ...n.sizes }, r = { ...n.splits };
71
+ for (const l of U) {
72
+ const a = s[l];
73
+ if (a !== void 0) {
74
+ const f = M(l) ? e : t, h = Cn(n, x[l], o, c);
75
+ s[l] = xn(a, f, h);
76
+ }
77
+ const d = r[l];
78
+ d !== void 0 && (r[l] = D(d, M(l) ? t : e));
85
79
  }
86
- const c = n.bandSplit === void 0 ? void 0 : D(n.bandSplit, e);
87
- return { sizes: r, splits: i, bandSplit: c };
88
- }
89
- function Dn(n, t, e) {
90
- const o = e - gn, s = n + t;
91
- if (s <= o) return [n, t];
92
- const r = (u) => u === 0 ? 0 : F, i = r(n) + r(t);
93
- if (o <= i)
94
- return [Math.min(n, r(n)), Math.min(t, r(t))];
95
- const c = o / s, l = Math.max(r(n), Math.round(n * c));
96
- return [l, Math.max(r(t), Math.round(o - l))];
80
+ const i = n.bandSplit === void 0 ? void 0 : D(n.bandSplit, t);
81
+ return { sizes: s, splits: r, bandSplit: i };
97
82
  }
98
- function Hn(n, t, e) {
99
- return n.find((o) => o.zone === t && o.slot === e)?.id;
100
- }
101
- function N(n, t) {
102
- return t === void 0 ? void 0 : n.find((e) => e.id === t);
103
- }
104
- function Z(n, t) {
105
- const e = n.open[t], o = e?.primary;
106
- return o !== void 0 && N(n.registry, o)?.solo === !0 ? { primary: o } : { primary: o, secondary: e?.secondary };
107
- }
108
- function jn(n, t) {
109
- return U(t) ? kn.some((e) => W(n, e)) : W(n, t);
110
- }
111
- function W(n, t) {
112
- const e = Z(n, t);
83
+ function Jn(n, t, e) {
84
+ const o = e - Pn, c = n + t;
85
+ if (c <= o) return [n, t];
86
+ const s = (a) => a === 0 ? 0 : A, r = s(n) + s(t);
87
+ if (o <= r)
88
+ return [Math.min(n, s(n)), Math.min(t, s(t))];
89
+ const i = o / c, l = Math.max(s(n), Math.round(n * i));
90
+ return [l, Math.max(s(t), Math.round(o - l))];
91
+ }
92
+ function z(n) {
93
+ return n.views[n.view] ?? {};
94
+ }
95
+ function $(n, t) {
96
+ const e = { ...t ?? {} };
97
+ for (const o of U)
98
+ for (const c of Nn)
99
+ e[o]?.[c] === void 0 && Zn(n, o, c) !== void 0 && (e[o] = { ...e[o], [c]: null });
100
+ return e;
101
+ }
102
+ function J(n, t) {
103
+ return Object.hasOwn(n.views, t);
104
+ }
105
+ function Zn(n, t, e) {
106
+ return n.find((o) => o.zone === t && o.slot === e);
107
+ }
108
+ function C(n, t) {
109
+ return t == null ? void 0 : n.find((e) => e.id === t);
110
+ }
111
+ function dn(n, t, e) {
112
+ const o = z(n)[t];
113
+ if (!o || !(e in o)) return;
114
+ const c = C(n.registry, o[e]);
115
+ return c?.zone === t && c.slot === e ? c : Zn(n.registry, t, e);
116
+ }
117
+ function E(n, t) {
118
+ const e = dn(n, t, "primary");
119
+ return e?.solo === !0 ? { primary: e } : { primary: e, secondary: dn(n, t, "secondary") };
120
+ }
121
+ function L(n, t) {
122
+ const { primary: e, secondary: o } = E(n, t);
123
+ return { primary: e?.id, secondary: o?.id };
124
+ }
125
+ function X(n, t) {
126
+ return rn(t) ? $n.some((e) => j(n, e)) : j(n, t);
127
+ }
128
+ function j(n, t) {
129
+ const e = L(n, t);
113
130
  return e.primary !== void 0 || e.secondary !== void 0;
114
131
  }
115
- function G(n, t, e) {
116
- return Math.max(Bn[t], N(n, e)?.opens ?? 0);
117
- }
118
- function Un(n, t, e, o) {
119
- const s = n.open[t] ?? {}, r = { ...n.stashed };
120
- if (N(n.registry, o)?.solo === !0)
121
- return r[t] = s, [{ [e]: o }, r];
122
- const i = s.primary;
123
- if (!(i !== void 0 && N(n.registry, i)?.solo === !0)) return [{ ...s, [e]: o }, n.stashed];
124
- const l = r[t] ?? {};
125
- return delete r[t], [{ ...l, [e]: o }, r];
126
- }
127
- function Yn(n, t, e) {
128
- const o = n.open[t] ?? {}, s = o[e], r = n.stashed[t];
129
- if (r && s !== void 0 && N(n.registry, s)?.solo === !0) {
130
- const c = { ...n.stashed };
131
- return delete c[t], [r, c];
132
+ function K(n, t) {
133
+ return Math.max(Wn[n], t?.opens ?? 0);
134
+ }
135
+ function Xn(n, t, e, o) {
136
+ const { slot: c, id: s } = e, r = z(n)[t] ?? {}, i = { ...n.stashed };
137
+ if (e.solo === !0 && c === "primary")
138
+ return i[t] = r, [{ [c]: s }, i];
139
+ if (o?.solo !== !0) return [{ ...r, [c]: s }, n.stashed];
140
+ const l = i[t];
141
+ if (delete i[t], l) return [{ ...l, [c]: s }, i];
142
+ const a = { ...r, [c]: s };
143
+ return c !== o.slot && delete a[o.slot], [a, i];
144
+ }
145
+ function Kn(n, t, e) {
146
+ const o = z(n)[t] ?? {}, c = o[e], s = n.stashed[t];
147
+ if (s && c !== void 0 && C(n.registry, c)?.solo === !0) {
148
+ const i = { ...n.stashed };
149
+ return delete i[t], [s, i];
132
150
  }
133
- const i = { ...o };
134
- return delete i[e], [i, n.stashed];
135
- }
136
- const rn = { sizes: {}, splits: {} };
137
- function $n(n = {}) {
138
- const t = n.initial;
139
- return Ln()((e, o) => ({
151
+ const r = { ...o };
152
+ return delete r[e], [r, n.stashed];
153
+ }
154
+ const fn = { sizes: {}, splits: {} };
155
+ function qn(n = {}) {
156
+ const t = n.initial, e = (o, c) => ({
157
+ ...o.views,
158
+ [o.view]: c
159
+ });
160
+ return Un()((o, c) => ({
140
161
  registry: [],
141
- open: t?.open ?? {},
142
- lengths: t?.lengths ?? rn,
162
+ view: n.view ?? on,
163
+ views: t?.views ?? {},
164
+ lengths: t?.lengths ?? fn,
143
165
  focusedZone: null,
144
166
  stashed: {},
145
- settled: t?.open !== void 0,
146
167
  available: { width: 0, height: 0 },
147
- register: (s) => e((r) => ({ registry: [...r.registry.filter((c) => c.id !== s.id), s] })),
148
- unregister: (s) => e((r) => {
149
- const i = { ...r.open };
150
- for (const c of C) {
151
- const l = i[c];
152
- if (l)
153
- for (const u of $) {
154
- if (l[u] !== s) continue;
155
- const a = { ...l };
156
- delete a[u], i[c] = a;
157
- }
158
- }
159
- return { registry: r.registry.filter((c) => c.id !== s), open: i };
168
+ // The arrangement is left ALONE by a panel leaving the list: the half naming it falls back
169
+ // to what is still declared — see `resolve` — and names it again the day it comes back.
170
+ declare: (s) => o({ registry: s }),
171
+ // Having an entry in `views` IS the record of having been settled. No second field can then
172
+ // disagree about which views have been opened, or fall out of step when a reset clears them.
173
+ // Having an entry in `views` IS the record of having been settled. No second field can then
174
+ // disagree about which views have been opened, or fall out of step when a reset clears them.
175
+ settle: (s) => o((r) => {
176
+ const i = s ?? r.defaults;
177
+ return J(r, r.view) ? i === r.defaults ? r : { defaults: i } : { views: e(r, $(r.registry, i)), defaults: i };
160
178
  }),
161
- settle: (s) => e((r) => {
162
- if (r.settled) return r;
163
- const i = { ...s ?? {} };
164
- for (const c of C)
165
- for (const l of $) {
166
- if (i[c]?.[l] !== void 0) continue;
167
- const u = Hn(r.registry, c, l);
168
- u !== void 0 && (i[c] = { ...i[c] ?? {}, [l]: u });
169
- }
170
- return { open: i, settled: !0 };
179
+ // Settles the view it arrives at, rather than leaving that to the next render: a project
180
+ // driving the chassis from outside React would otherwise land on an empty frame.
181
+ setView: (s) => o((r) => r.view === s ? r : {
182
+ view: s,
183
+ views: J(r, s) ? r.views : { ...r.views, [s]: $(r.registry, r.defaults) },
184
+ // Session state, and it belongs to the view being left: a zone accented on arrival is
185
+ // a zone nobody clicked, and a stash given back in another view would reopen a half
186
+ // there.
187
+ focusedZone: null,
188
+ stashed: {}
171
189
  }),
172
- show: (s) => e((r) => {
173
- const i = N(r.registry, s);
190
+ show: (s) => o((r) => {
191
+ const i = C(r.registry, s);
174
192
  if (!i) return r;
175
- const { zone: c, slot: l } = i;
176
- if (r.open[c]?.[l] === s) return { focusedZone: c };
177
- const [u, a] = Un(r, c, l, s);
178
- return { open: { ...r.open, [c]: u }, stashed: a, focusedZone: c };
193
+ const { zone: l } = i, a = E(r, l);
194
+ if (a[i.slot]?.id === s) return { focusedZone: l };
195
+ const [d, f] = Xn(r, l, i, a.primary);
196
+ return {
197
+ views: e(r, { ...z(r), [l]: d }),
198
+ stashed: f,
199
+ focusedZone: l
200
+ };
179
201
  }),
180
- close: (s, r) => e((i) => {
181
- const [c, l] = Yn(i, s, r), u = { ...i.open, [s]: c };
202
+ close: (s, r) => o((i) => {
203
+ const [l, a] = Kn(i, s, r), d = e(i, { ...z(i), [s]: l }), f = j({ registry: i.registry, view: i.view, views: d }, s);
182
204
  return {
183
- open: u,
184
- stashed: l,
185
- focusedZone: !H(u, s) && i.focusedZone === s ? null : i.focusedZone
205
+ views: d,
206
+ stashed: a,
207
+ focusedZone: !f && i.focusedZone === s ? null : i.focusedZone
186
208
  };
187
209
  }),
188
210
  toggle: (s) => {
189
- const r = o(), i = N(r.registry, s);
190
- if (!i) return;
191
- Z(r, i.zone)[i.slot] === s ? r.close(i.zone, i.slot) : r.show(s);
211
+ const r = c(), i = C(r.registry, s);
212
+ i && (L(r, i.zone)[i.slot] === s ? r.close(i.zone, i.slot) : r.show(s));
192
213
  },
193
- focus: (s) => e((r) => r.focusedZone === s ? r : { focusedZone: s }),
214
+ focus: (s) => o((r) => r.focusedZone === s ? r : { focusedZone: s }),
194
215
  // Guarded: a drag past the ceiling clamps to the same number for as long as the pointer
195
216
  // keeps going, and every write notifies every subscriber.
196
- resize: (s, r, i) => e((c) => {
197
- const l = vn(
198
- c.lengths,
199
- c.open,
200
- M[s],
201
- (f) => G(c.registry, f, Z(c, f).primary)
202
- ), u = yn(r, i, l), a = A(s);
203
- return u === c.lengths.sizes[a] ? c : { lengths: { ...c.lengths, sizes: { ...c.lengths.sizes, [a]: u } } };
217
+ resize: (s, r, i) => o((l) => {
218
+ const a = Cn(
219
+ l.lengths,
220
+ x[s],
221
+ (h) => X(l, h),
222
+ (h) => K(h, E(l, h).primary)
223
+ ), d = xn(r, i, a), f = k(s);
224
+ return d === l.lengths.sizes[f] ? l : { lengths: { ...l.lengths, sizes: { ...l.lengths.sizes, [f]: d } } };
204
225
  }),
205
- resplit: (s, r, i) => e((c) => {
206
- const l = D(r, i);
207
- return l === c.lengths.splits[s] ? c : { lengths: { ...c.lengths, splits: { ...c.lengths.splits, [s]: l } } };
226
+ resplit: (s, r, i) => o((l) => {
227
+ const a = D(r, i);
228
+ return a === l.lengths.splits[s] ? l : { lengths: { ...l.lengths, splits: { ...l.lengths.splits, [s]: a } } };
208
229
  }),
209
- resplitBand: (s, r) => e((i) => {
210
- const c = D(s, r);
211
- return c === i.lengths.bandSplit ? i : { lengths: { ...i.lengths, bandSplit: c } };
230
+ resplitBand: (s, r) => o((i) => {
231
+ const l = D(s, r);
232
+ return l === i.lengths.bandSplit ? i : { lengths: { ...i.lengths, bandSplit: l } };
212
233
  }),
213
- fit: (s, r) => e((i) => ({
234
+ fit: (s, r) => o((i) => ({
214
235
  available: { width: s, height: r },
215
- lengths: An(
236
+ lengths: Gn(
216
237
  i.lengths,
217
- i.open,
218
238
  s,
219
239
  r,
220
- (c) => G(i.registry, c, Z(i, c).primary)
240
+ (l) => X(i, l),
241
+ (l) => K(l, E(i, l).primary)
221
242
  )
222
243
  })),
223
- reset: () => e((s) => ({
224
- open: {},
225
- lengths: rn,
244
+ // Every view, not just the one in front: a reset the reader asked for must not leave the
245
+ // arrangement they were escaping waiting for them one click away.
246
+ reset: () => o((s) => ({
247
+ // The view in front is settled on the spot, not left for the next render: nothing
248
+ // re-renders the provider when a button inside the chassis is what asked for the reset,
249
+ // so the frame stayed blank — and the arrangement being escaped stayed on disk.
250
+ views: { [s.view]: $(s.registry, s.defaults) },
251
+ lengths: fn,
226
252
  focusedZone: null,
227
253
  // Left behind, a solo panel closed after a reset would give back the zone the reset
228
254
  // had just cleared.
229
255
  stashed: {},
230
- settled: !1,
231
256
  registry: s.registry
232
257
  }))
233
258
  }));
234
259
  }
235
- const mt = () => {
260
+ const Ct = () => {
236
261
  const n = /* @__PURE__ */ new Map();
237
262
  return {
238
263
  read: (t) => n.get(t) ?? null,
@@ -240,7 +265,7 @@ const mt = () => {
240
265
  n.set(t, e);
241
266
  }
242
267
  };
243
- }, Vn = () => ({
268
+ }, Qn = () => ({
244
269
  read: (n) => {
245
270
  try {
246
271
  return globalThis.localStorage?.getItem(n) ?? null;
@@ -254,135 +279,198 @@ const mt = () => {
254
279
  } catch {
255
280
  }
256
281
  }
257
- }), Sn = 1;
258
- function I(n) {
282
+ }), En = 2;
283
+ function _(n) {
259
284
  return typeof n == "object" && n !== null && !Array.isArray(n);
260
285
  }
261
- function Wn(n) {
286
+ function hn(n) {
262
287
  const t = {};
263
- for (const e of C) {
288
+ for (const e of U) {
264
289
  const o = n[e];
265
- if (I(o))
266
- for (const s of $) {
267
- const r = o[s];
268
- typeof r == "string" && (t[e] = { ...t[e], [s]: r });
290
+ if (_(o))
291
+ for (const c of Nn) {
292
+ const s = o[c];
293
+ s !== null && typeof s != "string" || (t[e] = { ...t[e], [c]: s });
269
294
  }
270
295
  }
271
296
  return t;
272
297
  }
273
- function sn(n) {
298
+ function pn(n) {
274
299
  const t = {};
275
- for (const e of C) {
300
+ for (const e of U) {
276
301
  const o = n[e];
277
302
  typeof o == "number" && Number.isFinite(o) && (t[e] = o);
278
303
  }
279
304
  return t;
280
305
  }
281
- function Gn(n, t) {
282
- const e = n.read(t);
283
- if (e === null) return;
284
- let o;
306
+ function nt(n, t) {
307
+ if (n.version === 1)
308
+ return _(n.open) ? { [t]: hn(n.open) } : void 0;
309
+ if (n.version !== En || !_(n.views)) return;
310
+ const e = /* @__PURE__ */ Object.create(null);
311
+ for (const [o, c] of Object.entries(n.views))
312
+ _(c) && (e[o] = hn(c));
313
+ return e;
314
+ }
315
+ function tt(n, t, e = on) {
316
+ const o = n.read(t);
317
+ if (o === null) return;
318
+ let c;
285
319
  try {
286
- o = JSON.parse(e);
320
+ c = JSON.parse(o);
287
321
  } catch {
288
322
  return;
289
323
  }
290
- if (!I(o) || o.version !== Sn || !I(o.open) || !I(o.lengths)) return;
291
- const s = o.lengths;
292
- if (!I(s.sizes) || !I(s.splits)) return;
293
- const r = s.bandSplit;
324
+ if (!_(c) || !_(c.lengths)) return;
325
+ const s = nt(c, e);
326
+ if (!s) return;
327
+ const r = c.lengths;
328
+ if (!_(r.sizes) || !_(r.splits)) return;
329
+ const i = r.bandSplit;
294
330
  return {
295
- open: Wn(o.open),
331
+ views: s,
296
332
  lengths: {
297
- sizes: sn(s.sizes),
298
- splits: sn(s.splits),
299
- bandSplit: typeof r == "number" && Number.isFinite(r) ? r : void 0
333
+ sizes: pn(r.sizes),
334
+ splits: pn(r.splits),
335
+ bandSplit: typeof i == "number" && Number.isFinite(i) ? i : void 0
300
336
  }
301
337
  };
302
338
  }
303
- function Jn(n, t, e) {
304
- const o = { version: Sn, ...e };
339
+ function et(n, t, e) {
340
+ const o = {
341
+ version: En,
342
+ views: e.views,
343
+ lengths: e.lengths
344
+ };
305
345
  n.write(t, JSON.stringify(o));
306
346
  }
307
- const wn = typeof globalThis.document > "u" ? K : Mn, Nn = pn(null);
308
- function Xn({
347
+ const Mn = typeof globalThis.document > "u" ? nn : kn, zn = en(null);
348
+ function ot({
309
349
  store: n,
310
350
  storageKey: t = "panels:layout",
311
351
  storage: e,
312
352
  defaultOpen: o,
353
+ view: c,
313
354
  children: s
314
355
  }) {
315
- const [r] = tn(
316
- () => e === null ? null : e ?? Vn()
317
- ), [i] = tn(
318
- () => n ?? $n({
319
- initial: r ? Gn(r, t) : void 0
320
- })
321
- );
322
- return wn(() => {
323
- i.getState().settle(o);
324
- }, [i, o]), K(() => {
325
- if (r)
326
- return i.subscribe((c) => {
327
- c.settled && Jn(r, t, { open: c.open, lengths: c.lengths });
328
- });
329
- }, [r, i, t]), /* @__PURE__ */ d(Nn.Provider, { value: i, children: s });
330
- }
331
- function L() {
332
- const n = fn(Nn);
356
+ const [r] = W(
357
+ () => e === null ? null : e ?? Qn()
358
+ ), [i] = W(() => {
359
+ const l = c ?? on, a = r ? tt(r, t, l) : void 0;
360
+ return n ? (a && n.setState(a), n) : qn({ view: l, initial: a });
361
+ });
362
+ return Mn(() => {
363
+ const l = i.getState();
364
+ c !== void 0 && l.setView(c), l.settle(o);
365
+ }), nn(() => {
366
+ if (!r) return;
367
+ let l;
368
+ return i.subscribe((a) => {
369
+ J(a, a.view) && (l?.views === a.views && l.lengths === a.lengths || (l = { views: a.views, lengths: a.lengths }, et(r, t, a)));
370
+ });
371
+ }, [r, i, t]), /* @__PURE__ */ u(zn.Provider, { value: i, children: s });
372
+ }
373
+ function O() {
374
+ const n = tn(zn);
333
375
  if (!n) throw new Error("usePanelsStore must be used inside a <Panels> or <PanelsProvider>");
334
376
  return n;
335
377
  }
336
- function S(n) {
337
- const t = L();
338
- return Tn(t, n);
378
+ function b(n) {
379
+ const t = O();
380
+ return Yn(t, n);
339
381
  }
340
- function O() {
341
- const n = L();
342
- return w(() => {
343
- const { show: t, close: e, toggle: o, focus: s, resize: r, resplit: i, resplitBand: c, fit: l, reset: u } = n.getState();
344
- return { show: t, close: e, toggle: o, focus: s, resize: r, resplit: i, resplitBand: c, fit: l, reset: u };
382
+ function R() {
383
+ const n = O();
384
+ return y(() => {
385
+ const { show: t, close: e, toggle: o, focus: c, resize: s, resplit: r, resplitBand: i, fit: l, reset: a } = n.getState();
386
+ return { show: t, close: e, toggle: o, focus: c, resize: s, resplit: r, resplitBand: i, fit: l, reset: a };
345
387
  }, [n]);
346
388
  }
347
- function Kn(n) {
348
- const t = L();
349
- K(() => {
389
+ function rt({
390
+ icon: n,
391
+ label: t,
392
+ active: e,
393
+ accented: o,
394
+ acts: c,
395
+ className: s,
396
+ children: r,
397
+ ref: i,
398
+ ...l
399
+ }) {
400
+ return /* @__PURE__ */ m(
401
+ "button",
402
+ {
403
+ type: "button",
404
+ ref: i,
405
+ "aria-label": t,
406
+ "aria-pressed": c ? void 0 : e,
407
+ className: w(
408
+ "pnl-icon-button",
409
+ e && "pnl-icon-button--active",
410
+ o && "pnl-icon-button--accented",
411
+ s
412
+ ),
413
+ ...l,
414
+ children: [
415
+ n !== void 0 && /* @__PURE__ */ u("span", { className: "pnl-icon-button__glyph", children: n }),
416
+ r
417
+ ]
418
+ }
419
+ );
420
+ }
421
+ const q = { IconButton: rt }, Ln = en(q), st = Ln.Provider;
422
+ function On() {
423
+ return tn(Ln);
424
+ }
425
+ function it(n) {
426
+ return n === void 0 ? q : { ...q, ...n };
427
+ }
428
+ function ct(n) {
429
+ const t = O();
430
+ nn(() => {
350
431
  const e = n.current;
351
432
  if (!e) return;
352
433
  const o = () => {
353
- const { clientWidth: r, clientHeight: i } = e;
354
- r === 0 || i === 0 || t.getState().fit(r, i);
434
+ const { clientWidth: s, clientHeight: r } = e;
435
+ s === 0 || r === 0 || t.getState().fit(s, r);
355
436
  };
356
437
  if (o(), typeof ResizeObserver > "u") return;
357
- const s = new ResizeObserver(o);
358
- return s.observe(e), () => s.disconnect();
438
+ const c = new ResizeObserver(o);
439
+ return c.observe(e), () => c.disconnect();
359
440
  }, [n, t]);
360
441
  }
361
442
  function T() {
362
- const n = S((e) => e.registry), t = S((e) => e.open);
363
- return w(() => ({ registry: n, open: t }), [n, t]);
443
+ const n = b((o) => o.registry), t = b((o) => o.view), e = b((o) => o.views[o.view]);
444
+ return y(
445
+ () => ({ registry: n, view: t, views: e === void 0 ? {} : { [t]: e } }),
446
+ [n, t, e]
447
+ );
364
448
  }
365
- function J(n) {
449
+ function lt(n) {
366
450
  const t = T();
367
- return w(() => Z(t, n), [t, n]);
451
+ return y(() => L(t, n), [t, n]);
368
452
  }
369
- function cn(n) {
453
+ function mn(n) {
370
454
  const t = T();
371
- return w(() => W(t, n), [t, n]);
455
+ return y(() => E(t, n), [t, n]);
372
456
  }
373
- function qn(n) {
457
+ function gn(n) {
374
458
  const t = T();
375
- return w(() => jn(t, n), [t, n]);
459
+ return y(() => j(t, n), [t, n]);
376
460
  }
377
- function Qn() {
461
+ function at(n) {
462
+ const t = T();
463
+ return y(() => X(t, n), [t, n]);
464
+ }
465
+ function ut() {
378
466
  return {
379
- left: cn(V.left.band),
380
- right: cn(V.right.band)
467
+ left: gn(G.left.band),
468
+ right: gn(G.right.band)
381
469
  };
382
470
  }
383
- function nt() {
384
- const n = j(null);
385
- return w(() => ({
471
+ function dt() {
472
+ const n = H(null);
473
+ return y(() => ({
386
474
  start: (e, o) => {
387
475
  e.currentTarget.setPointerCapture(e.pointerId), n.current = { ...o, pointerId: e.pointerId };
388
476
  },
@@ -392,223 +480,174 @@ function nt() {
392
480
  }
393
481
  }), []);
394
482
  }
395
- function X({
483
+ function Q({
396
484
  axis: n,
397
485
  invert: t = !1,
398
486
  size: e,
399
487
  onSize: o,
400
- measure: s,
401
- label: r,
402
- min: i,
403
- max: c,
488
+ measure: c,
489
+ label: s,
490
+ min: r,
491
+ max: i,
404
492
  step: l = 16,
405
- className: u
493
+ className: a
406
494
  }) {
407
- const a = nt(), f = j(null), p = n === "vertical", g = z(
408
- (h) => (p ? h?.clientHeight : h?.clientWidth) ?? 0,
409
- [p]
410
- ), b = z(
411
- (h) => {
412
- const y = a.matching(h);
413
- if (!y) return;
414
- const Y = (p ? h.clientY : h.clientX) - y.position;
415
- o(y.size + Y * (t ? -1 : 1), y.available);
495
+ const d = dt(), f = H(null), h = n === "vertical", g = I(
496
+ (p) => (h ? p?.clientHeight : p?.clientWidth) ?? 0,
497
+ [h]
498
+ ), N = I(
499
+ (p) => {
500
+ const S = d.matching(p);
501
+ if (!S) return;
502
+ const Y = (h ? p.clientY : p.clientX) - S.position;
503
+ o(S.size + Y * (t ? -1 : 1), S.available);
416
504
  },
417
- [a, t, p, o]
418
- ), P = z(
419
- (h) => {
420
- const y = p ? "ArrowUp" : "ArrowLeft", _ = p ? "ArrowDown" : "ArrowRight";
421
- if (h.key !== y && h.key !== _) return;
422
- const Y = g(f.current?.parentElement), Zn = e ?? s?.() ?? 0, In = h.key === _ ? 1 : -1;
423
- h.preventDefault(), o(Zn + l * In * (t ? -1 : 1), Y);
505
+ [d, t, h, o]
506
+ ), v = I(
507
+ (p) => {
508
+ const S = h ? "ArrowUp" : "ArrowLeft", V = h ? "ArrowDown" : "ArrowRight";
509
+ if (p.key !== S && p.key !== V) return;
510
+ const Y = g(f.current?.parentElement), Bn = e ?? c?.() ?? 0, An = p.key === V ? 1 : -1;
511
+ p.preventDefault(), o(Bn + l * An * (t ? -1 : 1), Y);
424
512
  },
425
- [t, p, s, o, g, e, l]
513
+ [t, h, c, o, g, e, l]
426
514
  );
427
- return /* @__PURE__ */ d(
515
+ return /* @__PURE__ */ u(
428
516
  "div",
429
517
  {
430
518
  ref: f,
431
519
  role: "separator",
432
520
  tabIndex: 0,
433
- "aria-label": r,
434
- "aria-orientation": p ? "horizontal" : "vertical",
521
+ "aria-label": s,
522
+ "aria-orientation": h ? "horizontal" : "vertical",
435
523
  "aria-valuenow": e === void 0 ? void 0 : Math.round(e),
436
- "aria-valuemin": i,
437
- "aria-valuemax": c,
438
- onPointerDown: (h) => {
439
- a.start(h, {
440
- position: p ? h.clientY : h.clientX,
441
- size: e ?? s?.() ?? 0,
442
- available: g(h.currentTarget.parentElement)
524
+ "aria-valuemin": r,
525
+ "aria-valuemax": i,
526
+ onPointerDown: (p) => {
527
+ d.start(p, {
528
+ position: h ? p.clientY : p.clientX,
529
+ size: e ?? c?.() ?? 0,
530
+ available: g(p.currentTarget.parentElement)
443
531
  });
444
532
  },
445
- onPointerMove: b,
446
- onPointerUp: a.cancel,
447
- onPointerCancel: a.cancel,
448
- onLostPointerCapture: a.cancel,
449
- onKeyDown: P,
450
- className: v("pnl-handle", p ? "pnl-handle--row" : "pnl-handle--col", u)
533
+ onPointerMove: N,
534
+ onPointerUp: d.cancel,
535
+ onPointerCancel: d.cancel,
536
+ onLostPointerCapture: d.cancel,
537
+ onKeyDown: v,
538
+ className: w("pnl-handle", h ? "pnl-handle--row" : "pnl-handle--col", a)
451
539
  }
452
540
  );
453
541
  }
454
- function ln(n, t, e, o, s) {
455
- return s ? e ?? G(n, o, t) : 0;
456
- }
457
- function tt(n) {
458
- const t = T(), e = J(n), o = J(M[n]), s = qn(M[n]), r = S(
459
- (a) => a.lengths.sizes[A(n)]
460
- ), i = S(
461
- (a) => a.lengths.sizes[A(M[n])]
462
- ), c = S((a) => a.lengths.splits[n]), l = S(
463
- (a) => E(n) ? a.available.height : a.available.width
464
- ), u = S((a) => a.focusedZone === n);
465
- return w(() => {
466
- const { registry: a } = t, f = N(a, e.primary), p = N(a, e.secondary), g = f !== void 0 || p !== void 0, b = ln(a, e.primary, r, n, g), P = ln(
467
- a,
468
- o.primary,
469
- i,
470
- M[n],
471
- s
472
- );
542
+ function vn(n, t, e, o) {
543
+ return o ? t ?? K(e, n) : 0;
544
+ }
545
+ function ft(n) {
546
+ const t = mn(n), e = mn(x[n]), o = at(x[n]), c = b(
547
+ (a) => a.lengths.sizes[k(n)]
548
+ ), s = b(
549
+ (a) => a.lengths.sizes[k(x[n])]
550
+ ), r = b((a) => a.lengths.splits[n]), i = b(
551
+ (a) => M(n) ? a.available.height : a.available.width
552
+ ), l = b((a) => a.focusedZone === n);
553
+ return y(() => {
554
+ const { primary: a, secondary: d } = t, f = a !== void 0 || d !== void 0, h = vn(a, c, n, f), g = vn(e.primary, s, x[n], o);
473
555
  return {
474
- primary: f,
475
- secondary: p,
476
- draws: g,
556
+ primary: a,
557
+ secondary: d,
558
+ draws: f,
477
559
  // Zero until the container has been measured: bounding against nothing would collapse
478
560
  // every zone to its floor on the very first paint.
479
- size: l === 0 ? b : Dn(b, P, l)[0],
480
- split: c,
481
- focused: u
561
+ size: i === 0 ? h : Jn(h, g, i)[0],
562
+ split: r,
563
+ focused: l
482
564
  };
483
- }, [
484
- t,
485
- e,
486
- o,
487
- s,
488
- r,
489
- i,
490
- l,
491
- c,
492
- u,
493
- n
494
- ]);
495
- }
496
- function et(n) {
497
- const t = S((e) => e.registry);
498
- return w(() => [
565
+ }, [t, e, o, c, s, i, r, l, n]);
566
+ }
567
+ function ht(n) {
568
+ const t = b((e) => e.registry);
569
+ return y(() => [
499
570
  ["primary", t.filter((o) => o.zone === n && o.slot === "primary")],
500
571
  ["secondary", t.filter((o) => o.zone === n && o.slot === "secondary")]
501
572
  ].filter(([, o]) => o.length > 0), [t, n]);
502
573
  }
503
- const Pn = pn(/* @__PURE__ */ new Map()), ot = Pn.Provider;
504
- function rt(n) {
505
- return fn(Pn).get(n);
574
+ const Rn = en(/* @__PURE__ */ new Map()), pt = Rn.Provider;
575
+ function mt(n) {
576
+ return tn(Rn).get(n);
506
577
  }
507
- function st({
578
+ function gt({
508
579
  title: n,
509
580
  children: t,
510
581
  fillActions: e,
511
582
  trailing: o,
512
- className: s
583
+ className: c
513
584
  }) {
514
- return /* @__PURE__ */ m("header", { className: v("pnl-header", s), children: [
515
- /* @__PURE__ */ d("span", { className: v("pnl-header__title", e && "pnl-header__title--fixed"), children: n }),
516
- /* @__PURE__ */ d("span", { className: v("pnl-header__actions", e && "pnl-header__actions--fill"), children: t }),
517
- /* @__PURE__ */ d("span", { className: "pnl-header__trailing", children: o })
585
+ return /* @__PURE__ */ m("header", { className: w("pnl-header", c), children: [
586
+ /* @__PURE__ */ u("span", { className: w("pnl-header__title", e && "pnl-header__title--fixed"), children: n }),
587
+ /* @__PURE__ */ u("span", { className: w("pnl-header__actions", e && "pnl-header__actions--fill"), children: t }),
588
+ /* @__PURE__ */ u("span", { className: "pnl-header__trailing", children: o })
518
589
  ] });
519
590
  }
520
- function q({ orientation: n = "vertical", className: t }) {
521
- return /* @__PURE__ */ d(
591
+ function sn({ orientation: n = "vertical", className: t }) {
592
+ return /* @__PURE__ */ u(
522
593
  "span",
523
594
  {
524
595
  "aria-hidden": "true",
525
- className: v("pnl-separator", `pnl-separator--${n}`, t)
596
+ className: w("pnl-separator", `pnl-separator--${n}`, t)
526
597
  }
527
598
  );
528
599
  }
529
- function _n({ children: n, className: t, ...e }) {
530
- return /* @__PURE__ */ d("section", { className: v("pnl-surface", t), ...e, children: n });
600
+ function Tn({ children: n, className: t, ...e }) {
601
+ return /* @__PURE__ */ u("section", { className: w("pnl-surface", t), ...e, children: n });
531
602
  }
532
- function xn({
533
- icon: n,
534
- label: t,
535
- active: e,
536
- accented: o,
537
- acts: s,
538
- className: r,
539
- children: i,
540
- ref: c,
541
- ...l
542
- }) {
543
- return /* @__PURE__ */ m(
544
- "button",
545
- {
546
- type: "button",
547
- ref: c,
548
- "aria-label": t,
549
- "aria-pressed": s ? void 0 : e,
550
- className: v(
551
- "pnl-icon-button",
552
- e && "pnl-icon-button--active",
553
- o && "pnl-icon-button--accented",
554
- r
555
- ),
556
- ...l,
557
- children: [
558
- n !== void 0 && /* @__PURE__ */ d("span", { className: "pnl-icon-button__glyph", children: n }),
559
- i
560
- ]
561
- }
562
- );
563
- }
564
- function it({
603
+ function vt({
565
604
  panel: n,
566
605
  length: t,
567
606
  closeLabel: e,
568
607
  onFocus: o
569
608
  }) {
570
- const { close: s } = O(), r = rt(n.id);
609
+ const { close: c } = R(), { IconButton: s } = On(), r = mt(n.id);
571
610
  return (
572
611
  // The zone owns its length: a half given one keeps it, the other takes what is left. Both
573
612
  // sized here would make the pair overflow the zone the user dragged.
574
613
  /* @__PURE__ */ m(
575
- _n,
614
+ Tn,
576
615
  {
577
616
  "aria-label": n.title,
578
617
  onPointerDownCapture: o,
579
618
  className: t === void 0 ? "pnl-surface--fill" : "pnl-surface--give",
580
619
  style: t === void 0 ? void 0 : { flexBasis: t },
581
620
  children: [
582
- /* @__PURE__ */ d(
583
- st,
621
+ /* @__PURE__ */ u(
622
+ gt,
584
623
  {
585
624
  title: n.title,
586
- fillActions: r?.actions !== void 0 && E(n.zone),
625
+ fillActions: r?.actions !== void 0 && M(n.zone),
587
626
  trailing: /* @__PURE__ */ m(B, { children: [
588
- r?.actions !== void 0 && /* @__PURE__ */ d(q, {}),
589
- /* @__PURE__ */ d(
590
- xn,
627
+ r?.actions !== void 0 && /* @__PURE__ */ u(sn, {}),
628
+ /* @__PURE__ */ u(
629
+ s,
591
630
  {
592
631
  label: e,
593
632
  acts: !0,
594
- onClick: () => s(n.zone, n.slot),
633
+ onClick: () => c(n.zone, n.slot),
595
634
  className: "pnl-icon-button--header",
596
- icon: /* @__PURE__ */ d(ct, {})
635
+ icon: /* @__PURE__ */ u(bt, {})
597
636
  }
598
637
  )
599
638
  ] }),
600
639
  children: r?.actions
601
640
  }
602
641
  ),
603
- /* @__PURE__ */ d("div", { className: v("pnl-body"), children: r?.content })
642
+ /* @__PURE__ */ u("div", { className: w("pnl-body"), children: r?.content })
604
643
  ]
605
644
  }
606
645
  )
607
646
  );
608
647
  }
609
- const an = hn(it);
610
- function ct() {
611
- return /* @__PURE__ */ d("svg", { viewBox: "0 0 24 24", width: "14", height: "14", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ d(
648
+ const bn = Sn(vt);
649
+ function bt() {
650
+ return /* @__PURE__ */ u("svg", { viewBox: "0 0 24 24", width: "14", height: "14", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ u(
612
651
  "path",
613
652
  {
614
653
  fill: "currentColor",
@@ -616,320 +655,324 @@ function ct() {
616
655
  }
617
656
  ) });
618
657
  }
619
- function lt({ zone: n, labels: t }) {
620
- const e = tt(n), { focus: o, resize: s, resplit: r } = O(), i = j(null), c = z(() => o(n), [o, n]), l = E(n), u = z(
621
- () => l ? i.current?.clientHeight ?? 0 : i.current?.clientWidth ?? 0,
658
+ function wt({ zone: n, labels: t }) {
659
+ const e = ft(n), { focus: o, resize: c, resplit: s } = R(), r = H(null), i = I(() => o(n), [o, n]), l = M(n), a = I(
660
+ () => l ? r.current?.clientHeight ?? 0 : r.current?.clientWidth ?? 0,
622
661
  [l]
623
662
  );
624
663
  if (!e.draws) return null;
625
- const { primary: a, secondary: f, size: p, split: g } = e, b = /* @__PURE__ */ m(
664
+ const { primary: d, secondary: f, size: h, split: g } = e, N = /* @__PURE__ */ m(
626
665
  "div",
627
666
  {
628
- ref: i,
629
- className: v("pnl-zone", l ? "pnl-zone--row" : "pnl-zone--col"),
630
- style: { [l ? "height" : "width"]: p },
667
+ ref: r,
668
+ className: w("pnl-zone", l ? "pnl-zone--row" : "pnl-zone--col"),
669
+ style: { [l ? "height" : "width"]: h },
631
670
  children: [
632
- a && /* @__PURE__ */ d(an, { panel: a, closeLabel: t.closePanel, onFocus: c }),
633
- a && f && /* @__PURE__ */ d(
634
- X,
671
+ d && /* @__PURE__ */ u(bn, { panel: d, closeLabel: t.closePanel, onFocus: i }),
672
+ d && f && /* @__PURE__ */ u(
673
+ Q,
635
674
  {
636
675
  axis: l ? "horizontal" : "vertical",
637
676
  invert: !0,
638
677
  size: g,
639
- min: R,
678
+ min: Z,
640
679
  label: t.resizeSplit,
641
- onSize: (h, y) => r(n, h, y)
680
+ onSize: (p, S) => s(n, p, S)
642
681
  }
643
682
  ),
644
- f && /* @__PURE__ */ d(
645
- an,
683
+ f && /* @__PURE__ */ u(
684
+ bn,
646
685
  {
647
686
  panel: f,
648
- length: a && g !== void 0 ? g : void 0,
687
+ length: d && g !== void 0 ? g : void 0,
649
688
  closeLabel: t.closePanel,
650
- onFocus: c
689
+ onFocus: i
651
690
  }
652
691
  )
653
692
  ]
654
693
  }
655
- ), P = /* @__PURE__ */ d(
656
- X,
694
+ ), v = /* @__PURE__ */ u(
695
+ Q,
657
696
  {
658
697
  axis: l ? "vertical" : "horizontal",
659
- invert: !on(n),
660
- size: p,
661
- min: F,
662
- measure: u,
698
+ invert: !un(n),
699
+ size: h,
700
+ min: A,
701
+ measure: a,
663
702
  label: t.resizeZone,
664
- onSize: (h, y) => s(n, h, y)
703
+ onSize: (p, S) => c(n, p, S)
665
704
  }
666
705
  );
667
- return on(n) ? /* @__PURE__ */ m(B, { children: [
668
- b,
669
- P
706
+ return un(n) ? /* @__PURE__ */ m(B, { children: [
707
+ N,
708
+ v
670
709
  ] }) : /* @__PURE__ */ m(B, { children: [
671
- P,
672
- b
710
+ v,
711
+ N
673
712
  ] });
674
713
  }
675
- const x = hn(lt);
676
- function at({ left: n, right: t, labels: e }) {
677
- const o = S((i) => i.lengths.bandSplit), { resplitBand: s } = O(), r = z(
678
- (i, c) => s(i, c),
679
- [s]
714
+ const P = Sn(wt);
715
+ function yt({ left: n, right: t, labels: e }) {
716
+ const o = b((r) => r.lengths.bandSplit), { resplitBand: c } = R(), s = I(
717
+ (r, i) => c(r, i),
718
+ [c]
680
719
  );
681
- return !n && !t ? null : !n || !t ? /* @__PURE__ */ d(x, { zone: n ? "bottomLeft" : "bottomRight", labels: e }) : /* @__PURE__ */ m("div", { className: "pnl-band", children: [
682
- /* @__PURE__ */ d(
720
+ return !n && !t ? null : !n || !t ? /* @__PURE__ */ u(P, { zone: n ? "bottomLeft" : "bottomRight", labels: e }) : /* @__PURE__ */ m("div", { className: "pnl-band", children: [
721
+ /* @__PURE__ */ u(
683
722
  "div",
684
723
  {
685
- className: v("pnl-band__half", o === void 0 && "pnl-band__half--even"),
724
+ className: w("pnl-band__half", o === void 0 && "pnl-band__half--even"),
686
725
  style: o === void 0 ? void 0 : { width: o },
687
- children: /* @__PURE__ */ d(x, { zone: "bottomLeft", labels: e })
726
+ children: /* @__PURE__ */ u(P, { zone: "bottomLeft", labels: e })
688
727
  }
689
728
  ),
690
- /* @__PURE__ */ d(
691
- X,
729
+ /* @__PURE__ */ u(
730
+ Q,
692
731
  {
693
732
  axis: "horizontal",
694
733
  size: o,
695
- min: R,
734
+ min: Z,
696
735
  label: e.resizeBand,
697
- onSize: r
736
+ onSize: s
698
737
  }
699
738
  ),
700
- /* @__PURE__ */ d("div", { className: "pnl-band__half pnl-band__half--rest", children: /* @__PURE__ */ d(x, { zone: "bottomRight", labels: e }) })
739
+ /* @__PURE__ */ u("div", { className: "pnl-band__half pnl-band__half--rest", children: /* @__PURE__ */ u(P, { zone: "bottomRight", labels: e }) })
701
740
  ] });
702
741
  }
703
- function Q(n) {
742
+ function cn(n) {
704
743
  return null;
705
744
  }
706
- Q.displayName = "Panels.Center";
707
- const ut = {
745
+ cn.displayName = "Panels.Center";
746
+ const St = {
708
747
  closePanel: "Close panel",
709
748
  resizeZone: "Resize panel area",
710
749
  resizeSplit: "Resize the two panels",
711
750
  resizeBand: "Resize the bottom panels"
712
751
  };
713
- function nn(n) {
752
+ function ln(n) {
714
753
  return null;
715
754
  }
716
- nn.displayName = "Panels.Panel";
717
- function un({ side: n, header: t, className: e }) {
718
- const { column: o, band: s } = V[n];
755
+ ln.displayName = "Panels.Panel";
756
+ function wn({ side: n, header: t, className: e }) {
757
+ const { column: o, band: c } = G[n];
719
758
  return /* @__PURE__ */ m(
720
759
  "div",
721
760
  {
722
761
  role: "toolbar",
723
762
  "aria-orientation": "vertical",
724
- className: v("pnl-rail", `pnl-rail--${n}`, e),
763
+ className: w("pnl-rail", `pnl-rail--${n}`, e),
725
764
  children: [
726
765
  /* @__PURE__ */ m("div", { className: "pnl-rail__group", children: [
727
766
  t !== void 0 && /* @__PURE__ */ m(B, { children: [
728
767
  t,
729
- /* @__PURE__ */ d(q, { orientation: "horizontal" })
768
+ /* @__PURE__ */ u(sn, { orientation: "horizontal" })
730
769
  ] }),
731
- o.map((r) => /* @__PURE__ */ d(dn, { zone: r }, r))
770
+ o.map((s) => /* @__PURE__ */ u(yn, { zone: s }, s))
732
771
  ] }),
733
- /* @__PURE__ */ d(dn, { zone: s })
772
+ /* @__PURE__ */ u(yn, { zone: c })
734
773
  ]
735
774
  }
736
775
  );
737
776
  }
738
- function dn({ zone: n }) {
739
- const t = et(n), e = J(n), o = S((r) => r.focusedZone === n), { toggle: s } = O();
740
- return t.length === 0 ? null : /* @__PURE__ */ d("div", { className: "pnl-rail__group", children: t.map(([r, i], c) => /* @__PURE__ */ m(Rn, { children: [
741
- c > 0 && /* @__PURE__ */ d(q, { orientation: "horizontal" }),
742
- i.map((l) => {
743
- const u = e[r] === l.id;
744
- return /* @__PURE__ */ d(
745
- xn,
777
+ function yn({ zone: n }) {
778
+ const t = ht(n), e = lt(n), o = b((r) => r.focusedZone === n), { toggle: c } = R(), { IconButton: s } = On();
779
+ return t.length === 0 ? null : /* @__PURE__ */ u("div", { className: "pnl-rail__group", children: t.map(([r, i], l) => /* @__PURE__ */ m(Dn, { children: [
780
+ l > 0 && /* @__PURE__ */ u(sn, { orientation: "horizontal" }),
781
+ i.map((a) => {
782
+ const d = e[r] === a.id;
783
+ return /* @__PURE__ */ u(
784
+ s,
746
785
  {
747
- icon: l.icon,
748
- label: l.title,
749
- active: u,
750
- accented: u && o,
751
- onClick: () => s(l.id),
786
+ icon: a.icon,
787
+ label: a.title,
788
+ active: d,
789
+ accented: d && o,
790
+ onClick: () => c(a.id),
752
791
  className: "pnl-rail__button"
753
792
  },
754
- l.id
793
+ a.id
755
794
  );
756
795
  })
757
796
  ] }, `${n}:${r}`)) });
758
797
  }
759
- function dt(n) {
798
+ function Nt(n) {
760
799
  const t = [], e = /* @__PURE__ */ new Map(), o = [];
761
- let s = null;
762
- for (const r of Cn.toArray(n)) {
763
- if (!En(r)) {
764
- o.push(r);
800
+ let c = null;
801
+ for (const s of jn.toArray(n)) {
802
+ if (!Hn(s)) {
803
+ o.push(s);
765
804
  continue;
766
805
  }
767
- if (r.type === Q) {
768
- s = r;
806
+ if (s.type === cn) {
807
+ c = s;
769
808
  continue;
770
809
  }
771
- if (r.type !== nn) {
772
- o.push(r);
810
+ if (s.type !== ln) {
811
+ o.push(s);
773
812
  continue;
774
813
  }
775
- const i = r.props, { id: c, zone: l, slot: u = "primary", title: a, icon: f, opens: p, solo: g, actions: b, children: P } = i;
776
- t.push({ id: c, zone: l, slot: u, title: a, icon: f, opens: p, solo: g }), e.set(c, { content: P, actions: b });
814
+ const r = s.props, { id: i, zone: l, slot: a = "primary", title: d, icon: f, opens: h, solo: g, actions: N, children: v } = r;
815
+ t.push({ id: i, zone: l, slot: a, title: d, icon: f, opens: h, solo: g }), e.set(i, { content: v, actions: N });
777
816
  }
778
- return { specs: t, content: e, centre: s, loose: o };
817
+ return { specs: t, content: e, centre: c, loose: o };
779
818
  }
780
- function zn({
819
+ function Fn({
781
820
  header: n,
782
821
  footer: t,
783
822
  railHeader: e,
784
823
  labels: o,
785
- theme: s,
786
- className: r,
824
+ theme: c,
825
+ className: s,
826
+ components: r,
787
827
  children: i,
788
- ...c
828
+ ...l
789
829
  }) {
790
- return /* @__PURE__ */ d(Xn, { ...c, children: /* @__PURE__ */ d(
791
- ft,
830
+ return /* @__PURE__ */ u(ot, { ...l, children: /* @__PURE__ */ u(
831
+ Pt,
792
832
  {
793
833
  header: n,
794
834
  footer: t,
795
835
  railHeader: e,
796
836
  labels: o,
797
- theme: s,
798
- className: r,
837
+ theme: c,
838
+ className: s,
839
+ components: r,
799
840
  children: i
800
841
  }
801
842
  ) });
802
843
  }
803
- function ft({
844
+ function Pt({
804
845
  header: n,
805
846
  footer: t,
806
847
  railHeader: e,
807
848
  labels: o,
808
- theme: s,
809
- className: r,
849
+ theme: c,
850
+ className: s,
851
+ components: r,
810
852
  children: i
811
853
  }) {
812
- const c = L(), l = j(null);
813
- Kn(l);
814
- const { specs: u, content: a, centre: f, loose: p } = w(() => dt(i), [i]), g = w(() => ({ ...ut, ...o }), [o]);
815
- wn(() => {
816
- const { register: P, unregister: h } = c.getState();
817
- for (const _ of u) P(_);
818
- const y = new Set(u.map((_) => _.id));
819
- for (const _ of c.getState().registry)
820
- y.has(_.id) || h(_.id);
821
- }, [c, u]);
822
- const b = Qn();
823
- return /* @__PURE__ */ d(ot, { value: a, children: /* @__PURE__ */ m("div", { "data-pnl-theme": s, className: v("pnl-root", r), children: [
854
+ const l = O(), a = H(null);
855
+ ct(a);
856
+ const [d] = W(() => it(r)), { specs: f, content: h, centre: g, loose: N } = y(() => Nt(i), [i]), v = y(() => ({ ...St, ...o }), [o]);
857
+ Mn(() => {
858
+ l.getState().declare(f);
859
+ }, [l, f]);
860
+ const p = ut();
861
+ return /* @__PURE__ */ u(st, { value: d, children: /* @__PURE__ */ u(pt, { value: h, children: /* @__PURE__ */ m("div", { "data-pnl-theme": c, className: w("pnl-root", s), children: [
824
862
  n,
825
863
  /* @__PURE__ */ m("div", { className: "pnl-middle", children: [
826
- /* @__PURE__ */ d(un, { side: "left", header: e }),
827
- /* @__PURE__ */ m("div", { ref: l, className: "pnl-columns", children: [
828
- /* @__PURE__ */ d(x, { zone: "top", labels: g }),
864
+ /* @__PURE__ */ u(wn, { side: "left", header: e }),
865
+ /* @__PURE__ */ m("div", { ref: a, className: "pnl-columns", children: [
866
+ /* @__PURE__ */ u(P, { zone: "top", labels: v }),
829
867
  /* @__PURE__ */ m("div", { className: "pnl-row", children: [
830
- !b.left && /* @__PURE__ */ d(x, { zone: "left", labels: g }),
868
+ !p.left && /* @__PURE__ */ u(P, { zone: "left", labels: v }),
831
869
  /* @__PURE__ */ m("div", { className: "pnl-stack", children: [
832
870
  /* @__PURE__ */ m("div", { className: "pnl-row", children: [
833
- b.left && /* @__PURE__ */ d(x, { zone: "left", labels: g }),
834
- /* @__PURE__ */ d(_n, { className: "pnl-centre", children: f?.props.children }),
835
- b.right && /* @__PURE__ */ d(x, { zone: "right", labels: g })
871
+ p.left && /* @__PURE__ */ u(P, { zone: "left", labels: v }),
872
+ /* @__PURE__ */ u(Tn, { className: "pnl-centre", children: g?.props.children }),
873
+ p.right && /* @__PURE__ */ u(P, { zone: "right", labels: v })
836
874
  ] }),
837
- /* @__PURE__ */ d(at, { left: b.left, right: b.right, labels: g })
875
+ /* @__PURE__ */ u(yt, { left: p.left, right: p.right, labels: v })
838
876
  ] }),
839
- !b.right && /* @__PURE__ */ d(x, { zone: "right", labels: g })
877
+ !p.right && /* @__PURE__ */ u(P, { zone: "right", labels: v })
840
878
  ] })
841
879
  ] }),
842
- /* @__PURE__ */ d(un, { side: "right" })
880
+ /* @__PURE__ */ u(wn, { side: "right" })
843
881
  ] }),
844
882
  t,
845
- p
846
- ] }) });
847
- }
848
- zn.Panel = nn;
849
- zn.Center = Q;
850
- function bt() {
851
- const n = L(), t = T(), e = S((i) => i.focusedZone), o = O(), s = z(
852
- (i) => {
853
- const c = N(t.registry, i);
854
- return c !== void 0 && Z(t, c.zone)[c.slot] === i;
883
+ N
884
+ ] }) }) });
885
+ }
886
+ Fn.Panel = ln;
887
+ Fn.Center = cn;
888
+ function Zt() {
889
+ const n = O(), t = T(), e = b((r) => r.focusedZone), o = R(), c = I(
890
+ (r) => {
891
+ const i = C(t.registry, r);
892
+ return i !== void 0 && L(t, i.zone)[i.slot] === r;
855
893
  },
856
894
  [t]
857
- ), r = z(
858
- (i) => {
859
- const c = N(t.registry, i);
860
- !c || Z(t, c.zone)[c.slot] !== i || n.getState().close(c.zone, c.slot);
895
+ ), s = I(
896
+ (r) => {
897
+ const i = C(t.registry, r);
898
+ !i || L(t, i.zone)[i.slot] !== r || n.getState().close(i.zone, i.slot);
861
899
  },
862
900
  [t, n]
863
901
  );
864
- return w(
902
+ return y(
865
903
  () => ({
866
904
  panels: t.registry,
867
905
  reveal: o.show,
868
- close: r,
906
+ close: s,
869
907
  toggle: o.toggle,
870
- isShown: s,
908
+ isShown: c,
871
909
  focusedZone: e,
872
910
  reset: o.reset
873
911
  }),
874
- [t, o.show, o.toggle, o.reset, r, s, e]
912
+ [t, o.show, o.toggle, o.reset, s, c, e]
875
913
  );
876
914
  }
877
915
  export {
878
- kn as BOTTOM_ZONES,
879
- at as Band,
880
- Q as Center,
881
- ot as ContentProvider,
882
- ut as DEFAULT_LABELS,
883
- Bn as DEFAULT_SIZES,
884
- xn as IconButton,
885
- Sn as LAYOUT_VERSION,
886
- gn as MIN_CENTER,
887
- F as MIN_SIZE,
888
- R as MIN_SPLIT,
889
- nn as Panel,
890
- an as PanelFrame,
891
- st as PanelHeader,
892
- zn as Panels,
893
- Xn as PanelsProvider,
894
- un as Rail,
895
- dn as RailZone,
896
- X as ResizeHandle,
897
- $ as SLOTS,
898
- q as Separator,
899
- _n as Surface,
900
- C as ZONES,
901
- V as ZONES_BY_SIDE,
902
- x as ZoneEdge,
903
- Vn as browserStorage,
904
- $n as createPanelsStore,
905
- v as cx,
916
+ $n as BOTTOM_ZONES,
917
+ yt as Band,
918
+ cn as Center,
919
+ pt as ContentProvider,
920
+ St as DEFAULT_LABELS,
921
+ Wn as DEFAULT_SIZES,
922
+ on as DEFAULT_VIEW,
923
+ rt as IconButton,
924
+ En as LAYOUT_VERSION,
925
+ Pn as MIN_CENTER,
926
+ A as MIN_SIZE,
927
+ Z as MIN_SPLIT,
928
+ ln as Panel,
929
+ bn as PanelFrame,
930
+ gt as PanelHeader,
931
+ Fn as Panels,
932
+ ot as PanelsProvider,
933
+ wn as Rail,
934
+ yn as RailZone,
935
+ Q as ResizeHandle,
936
+ Nn as SLOTS,
937
+ sn as Separator,
938
+ Tn as Surface,
939
+ U as ZONES,
940
+ G as ZONES_BY_SIDE,
941
+ P as ZoneEdge,
942
+ Qn as browserStorage,
943
+ qn as createPanelsStore,
944
+ w as cx,
906
945
  D as fitSplit,
907
- yn as fitZoneSize,
908
- U as isBottom,
909
- E as isHorizontal,
910
- on as isLeading,
911
- mt as memoryStorage,
912
- Gn as readLayout,
913
- Dn as sharedSizes,
914
- Z as shownIn,
915
- A as sizeKeyOf,
916
- N as specOf,
917
- G as undraggedSizeOf,
946
+ xn as fitZoneSize,
947
+ rn as isBottom,
948
+ M as isHorizontal,
949
+ un as isLeading,
950
+ Ct as memoryStorage,
951
+ z as openOf,
952
+ tt as readLayout,
953
+ Jn as sharedSizes,
954
+ L as shownIn,
955
+ E as shownSpecsIn,
956
+ k as sizeKeyOf,
957
+ C as specOf,
958
+ K as undraggedSizeOf,
918
959
  T as useArrangement,
919
- Qn as useBandHalves,
920
- Kn as useContainerFit,
921
- rt as usePanelContent,
922
- bt as usePanels,
923
- O as usePanelsActions,
924
- S as usePanelsState,
925
- L as usePanelsStore,
926
- nt as usePointerDrag,
927
- J as useShownIn,
928
- tt as useZone,
929
- cn as useZoneDraws,
930
- et as useZonePanels,
931
- qn as useZoneTakesRoom,
932
- Jn as writeLayout,
933
- W as zoneDraws,
934
- jn as zoneTakesRoom
960
+ ut as useBandHalves,
961
+ ct as useContainerFit,
962
+ mt as usePanelContent,
963
+ Zt as usePanels,
964
+ R as usePanelsActions,
965
+ On as usePanelsComponents,
966
+ b as usePanelsState,
967
+ O as usePanelsStore,
968
+ dt as usePointerDrag,
969
+ lt as useShownIn,
970
+ mn as useShownSpecsIn,
971
+ ft as useZone,
972
+ gn as useZoneDraws,
973
+ ht as useZonePanels,
974
+ at as useZoneTakesRoom,
975
+ et as writeLayout,
976
+ j as zoneDraws,
977
+ X as zoneTakesRoom
935
978
  };