react-bwin 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +1,34 @@
1
- import g, { useRef as x, useEffect as $ } from "react";
2
- var F = Object.defineProperty, U = (e, t, i) => t in e ? F(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i, E = (e, t, i) => U(e, typeof t != "symbol" ? t + "" : t, i);
1
+ import g, { useRef as M, useEffect as L } from "react";
2
+ var q = Object.defineProperty, U = (e, t, i) => t in e ? q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i, b = (e, t, i) => U(e, typeof t != "symbol" ? t + "" : t, i);
3
3
  function X(e = 0.7, t = 128) {
4
- const i = 256 - t, n = Math.floor(Math.random() * i + t), o = Math.floor(Math.random() * i + t), s = Math.floor(Math.random() * i + t), r = Math.max(0.5, Math.random() * e);
5
- return `rgba(${n}, ${o}, ${s}, ${r})`;
4
+ const i = 256 - t, n = Math.floor(Math.random() * i + t), s = Math.floor(Math.random() * i + t), o = Math.floor(Math.random() * i + t), h = Math.max(0.5, Math.random() * e);
5
+ return `rgba(${n}, ${s}, ${o}, ${h})`;
6
6
  }
7
- function P(e = 2, t = 3) {
7
+ function D(e = 2, t = 3) {
8
8
  if (e < 0 || t < 0)
9
9
  throw new Error("Parameters must be non-negative numbers");
10
10
  const i = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", n = "0123456789";
11
- let o = "";
12
- for (let s = 0; s < e; s++) {
13
- const r = Math.floor(Math.random() * i.length);
14
- o += i[r];
11
+ let s = "";
12
+ for (let o = 0; o < e; o++) {
13
+ const h = Math.floor(Math.random() * i.length);
14
+ s += i[h];
15
15
  }
16
- o += "-";
17
- for (let s = 0; s < t; s++) {
18
- const r = Math.floor(Math.random() * n.length);
19
- o += n[r];
16
+ s += "-";
17
+ for (let o = 0; o < t; o++) {
18
+ const h = Math.floor(Math.random() * n.length);
19
+ s += n[h];
20
20
  }
21
- return o;
21
+ return s;
22
22
  }
23
- function v(e, t) {
23
+ function N(e, t) {
24
24
  for (; t.firstChild; )
25
25
  e.append(t.firstChild);
26
26
  }
27
27
  function Y(e, t) {
28
28
  const i = document.createElement("div");
29
- v(i, e), v(e, t), v(t, i);
29
+ N(i, e), N(e, t), N(t, i);
30
30
  }
31
- function R(e) {
31
+ function z(e) {
32
32
  if (typeof e == "number" && !isNaN(e))
33
33
  return e;
34
34
  if (typeof e == "string") {
@@ -64,7 +64,7 @@ function V(e) {
64
64
  const t = document.createElement("template");
65
65
  return t.innerHTML = e.trim(), t.content;
66
66
  }
67
- function C(e) {
67
+ function v(e) {
68
68
  if (e == null || e === "")
69
69
  return null;
70
70
  if (typeof e == "string")
@@ -76,7 +76,11 @@ function C(e) {
76
76
  }
77
77
  return e instanceof Node ? e : document.createTextNode(String(e));
78
78
  }
79
- const h = {
79
+ function R(e) {
80
+ const t = parseFloat(e.style.left) || 0, i = parseFloat(e.style.top) || 0, n = parseFloat(e.style.width) || 0, s = parseFloat(e.style.height) || 0;
81
+ return { left: t, top: i, width: n, height: s };
82
+ }
83
+ const r = {
80
84
  Top: "top",
81
85
  Right: "right",
82
86
  Bottom: "bottom",
@@ -88,14 +92,14 @@ const h = {
88
92
  };
89
93
  function Z(e) {
90
94
  switch (e) {
91
- case h.Top:
92
- return h.Bottom;
93
- case h.Right:
94
- return h.Left;
95
- case h.Bottom:
96
- return h.Top;
97
- case h.Left:
98
- return h.Right;
95
+ case r.Top:
96
+ return r.Bottom;
97
+ case r.Right:
98
+ return r.Left;
99
+ case r.Bottom:
100
+ return r.Top;
101
+ case r.Left:
102
+ return r.Right;
99
103
  default:
100
104
  throw new Error(`[bwin] Invalid position: ${e}`);
101
105
  }
@@ -113,37 +117,37 @@ function et({ width: e, height: t, y: i }) {
113
117
  return e - e / t * i;
114
118
  }
115
119
  function it(e, { clientX: t, clientY: i }) {
116
- const n = e.getBoundingClientRect(), { width: o, height: s } = n, r = t - n.left, a = i - n.top;
117
- if (r < 0 || r > o || a < 0 || a > s)
118
- return h.Outside;
119
- const l = 0.3, c = J({ width: o, height: s, x: r }), d = tt({ width: o, height: s, x: r }), p = Q({ width: o, height: s, y: a }), u = et({ width: o, height: s, y: a });
120
- return r < o * (0.5 - l / 2) && a > c && a < d ? h.Left : r > o * (0.5 + l / 2) && a < c && a > d ? h.Right : a < s * (0.5 - l / 2) && r > p && r < u ? h.Top : a > s * (0.5 + l / 2) && r < p && r > u ? h.Bottom : r > o * (0.5 - l / 2) && r < o * (0.5 + l / 2) && a > s * (0.5 - l / 2) && a < s * (0.5 + l / 2) ? h.Center : h.Unknown;
120
+ const n = e.getBoundingClientRect(), { width: s, height: o } = n, h = t - n.left, a = i - n.top;
121
+ if (h < 0 || h > s || a < 0 || a > o)
122
+ return r.Outside;
123
+ const d = 0.3, l = J({ width: s, height: o, x: h }), c = tt({ width: s, height: o, x: h }), p = Q({ width: s, height: o, y: a }), u = et({ width: s, height: o, y: a });
124
+ return h < s * (0.5 - d / 2) && a > l && a < c ? r.Left : h > s * (0.5 + d / 2) && a < l && a > c ? r.Right : a < o * (0.5 - d / 2) && h > p && h < u ? r.Top : a > o * (0.5 + d / 2) && h < p && h > u ? r.Bottom : h > s * (0.5 - d / 2) && h < s * (0.5 + d / 2) && a > o * (0.5 - d / 2) && a < o * (0.5 + d / 2) ? r.Center : r.Unknown;
121
125
  }
122
- const y = {
123
- top: 0,
126
+ const nt = 100, st = 100, E = {
124
127
  left: 0,
125
- width: 100,
126
- height: 100,
128
+ top: 0,
129
+ width: 150,
130
+ height: 150,
127
131
  // Initial min values, real min width/height is calculated based on children
128
- minWidth: 50,
129
- minHeight: 50
132
+ minWidth: nt,
133
+ minHeight: st
130
134
  };
131
135
  class m {
132
136
  constructor({
133
- top: t = y.top,
134
- left: i = y.left,
135
- width: n = y.width,
136
- height: o = y.height,
137
- minWidth: s = y.minWidth,
138
- minHeight: r = y.minHeight,
137
+ left: t = E.left,
138
+ top: i = E.top,
139
+ width: n = E.width,
140
+ height: s = E.height,
141
+ minWidth: o = E.minWidth,
142
+ minHeight: h = E.minHeight,
139
143
  domNode: a = null,
140
- store: l = {},
141
- position: c,
142
- id: d
143
- } = y) {
144
- if (this.id = d ?? P(), !c)
144
+ store: d = {},
145
+ position: l,
146
+ id: c
147
+ } = E) {
148
+ if (this.id = c ?? D(), !l)
145
149
  throw new Error("[bwin] Sash position is required");
146
- this.position = c, this.domNode = a, this._top = t, this._left = i, this._width = n, this._height = o, this.children = [], this.minWidth = s, this.minHeight = r, this.store = l;
150
+ this.position = l, this.domNode = a, this._top = i, this._left = t, this._width = n, this._height = s, this.children = [], this.minWidth = o, this.minHeight = h, this.store = d;
147
151
  }
148
152
  walk(t) {
149
153
  this.children.forEach((i) => i.walk(t)), t(this);
@@ -157,31 +161,31 @@ class m {
157
161
  }
158
162
  isLeftRightSplit() {
159
163
  return this.children.some(
160
- (t) => t.position === h.Left || t.position === h.Right
164
+ (t) => t.position === r.Left || t.position === r.Right
161
165
  );
162
166
  }
163
167
  isTopBottomSplit() {
164
168
  return this.children.some(
165
- (t) => t.position === h.Top || t.position === h.Bottom
169
+ (t) => t.position === r.Top || t.position === r.Bottom
166
170
  );
167
171
  }
168
172
  get leftChild() {
169
- return this.children.find((t) => t.position === h.Left);
173
+ return this.children.find((t) => t.position === r.Left);
170
174
  }
171
175
  get rightChild() {
172
- return this.children.find((t) => t.position === h.Right);
176
+ return this.children.find((t) => t.position === r.Right);
173
177
  }
174
178
  get topChild() {
175
- return this.children.find((t) => t.position === h.Top);
179
+ return this.children.find((t) => t.position === r.Top);
176
180
  }
177
181
  get bottomChild() {
178
- return this.children.find((t) => t.position === h.Bottom);
182
+ return this.children.find((t) => t.position === r.Bottom);
179
183
  }
180
184
  getChildren() {
181
- let t = null, i = null, n = null, o = null;
182
- for (const s of this.children)
183
- s.position === h.Left ? t = s : s.position === h.Right ? i = s : s.position === h.Top ? n = s : s.position === h.Bottom && (o = s);
184
- return [n, i, o, t];
185
+ let t = null, i = null, n = null, s = null;
186
+ for (const o of this.children)
187
+ o.position === r.Left ? t = o : o.position === r.Right ? i = o : o.position === r.Top ? n = o : o.position === r.Bottom && (s = o);
188
+ return [n, i, s, t];
185
189
  }
186
190
  getAllLeafDescendants() {
187
191
  const t = [];
@@ -192,27 +196,27 @@ class m {
192
196
  calcMinWidth() {
193
197
  if (this.isLeaf())
194
198
  return this.minWidth;
195
- const [t, i, n, o] = this.getChildren();
196
- if (o && i) {
197
- const s = o.calcMinWidth() + i.calcMinWidth();
198
- return Math.max(this.minWidth, s);
199
+ const [t, i, n, s] = this.getChildren();
200
+ if (s && i) {
201
+ const o = s.calcMinWidth() + i.calcMinWidth();
202
+ return Math.max(this.minWidth, o);
199
203
  }
200
204
  if (t && n) {
201
- const s = Math.max(t.calcMinWidth(), n.calcMinWidth());
202
- return Math.max(this.minWidth, s);
205
+ const o = Math.max(t.calcMinWidth(), n.calcMinWidth());
206
+ return Math.max(this.minWidth, o);
203
207
  }
204
208
  }
205
209
  calcMinHeight() {
206
210
  if (this.isLeaf())
207
211
  return this.minHeight;
208
- const [t, i, n, o] = this.getChildren();
209
- if (o && i) {
210
- const s = Math.max(o.calcMinHeight(), i.calcMinHeight());
211
- return Math.max(this.minHeight, s);
212
+ const [t, i, n, s] = this.getChildren();
213
+ if (s && i) {
214
+ const o = Math.max(s.calcMinHeight(), i.calcMinHeight());
215
+ return Math.max(this.minHeight, o);
212
216
  }
213
217
  if (t && n) {
214
- const s = t.calcMinHeight() + n.calcMinHeight();
215
- return Math.max(this.minHeight, s);
218
+ const o = t.calcMinHeight() + n.calcMinHeight();
219
+ return Math.max(this.minHeight, o);
216
220
  }
217
221
  }
218
222
  // Get self or descendant by id
@@ -257,8 +261,8 @@ class m {
257
261
  set top(t) {
258
262
  const i = t - this._top;
259
263
  this._top = t;
260
- const [n, o, s, r] = this.getChildren();
261
- n && s && (n.top += i, s.top += i), r && o && (r.top += i, o.top += i);
264
+ const [n, s, o, h] = this.getChildren();
265
+ n && o && (n.top += i, o.top += i), h && s && (h.top += i, s.top += i);
262
266
  }
263
267
  get left() {
264
268
  return this._left;
@@ -266,8 +270,8 @@ class m {
266
270
  set left(t) {
267
271
  const i = t - this._left;
268
272
  this._left = t;
269
- const [n, o, s, r] = this.getChildren();
270
- r && o && (r.left += i, o.left += i), n && s && (n.left += i, s.left += i);
273
+ const [n, s, o, h] = this.getChildren();
274
+ h && s && (h.left += i, s.left += i), n && o && (n.left += i, o.left += i);
271
275
  }
272
276
  get width() {
273
277
  return this._width;
@@ -275,14 +279,14 @@ class m {
275
279
  set width(t) {
276
280
  const i = t - this._width;
277
281
  this._width = t;
278
- const [n, o, s, r] = this.getChildren();
279
- if (r && o) {
280
- const a = r.width + o.width, l = i * (r.width / a), c = a + i;
281
- let d = r.width + l, p = c - d, u = o.left + l;
282
- const f = r.calcMinWidth(), w = o.calcMinWidth();
283
- d < f && p > w ? (d = f, p = c - d, u = r.left + d) : p < w && d > f && (p = w, d = c - p, u = r.left + d), r.width = d, o.width = p, o.left = u;
282
+ const [n, s, o, h] = this.getChildren();
283
+ if (h && s) {
284
+ const a = h.width + s.width, d = i * (h.width / a), l = a + i;
285
+ let c = h.width + d, p = l - c, u = s.left + d;
286
+ const f = h.calcMinWidth(), w = s.calcMinWidth();
287
+ c < f && p > w ? (c = f, p = l - c, u = h.left + c) : p < w && c > f && (p = w, c = l - p, u = h.left + c), h.width = c, s.width = p, s.left = u;
284
288
  }
285
- n && s && (n.width += i, s.width += i);
289
+ n && o && (n.width += i, o.width += i);
286
290
  }
287
291
  get height() {
288
292
  return this._height;
@@ -290,33 +294,33 @@ class m {
290
294
  set height(t) {
291
295
  const i = t - this._height;
292
296
  this._height = t;
293
- const [n, o, s, r] = this.getChildren();
294
- if (n && s) {
295
- const a = n.height + s.height, l = i * (n.height / a), c = a + i;
296
- let d = n.height + l, p = c - d, u = s.top + l;
297
- const f = n.calcMinHeight(), w = s.calcMinHeight();
298
- d < f && p > w ? (d = f, p = c - d, u = n.top + d) : p < w && d > f && (p = w, d = c - p, u = n.top + d), n.height = d, s.height = p, s.top = u;
297
+ const [n, s, o, h] = this.getChildren();
298
+ if (n && o) {
299
+ const a = n.height + o.height, d = i * (n.height / a), l = a + i;
300
+ let c = n.height + d, p = l - c, u = o.top + d;
301
+ const f = n.calcMinHeight(), w = o.calcMinHeight();
302
+ c < f && p > w ? (c = f, p = l - c, u = n.top + c) : p < w && c > f && (p = w, c = l - p, u = n.top + c), n.height = c, o.height = p, o.top = u;
299
303
  }
300
- r && o && (r.height += i, o.height += i);
304
+ h && s && (h.height += i, s.height += i);
301
305
  }
302
306
  }
303
- const L = {
307
+ const B = {
304
308
  size: "50%",
305
- position: h.Left
309
+ position: r.Left
306
310
  };
307
- class M {
311
+ class P {
308
312
  constructor({
309
313
  parentRect: t,
310
314
  children: i,
311
315
  siblingConfigNode: n,
312
- id: o,
313
- minWidth: s,
314
- minHeight: r,
316
+ id: s,
317
+ minWidth: o,
318
+ minHeight: h,
315
319
  position: a,
316
- size: l,
317
- ...c
320
+ size: d,
321
+ ...l
318
322
  }) {
319
- E(this, "left"), E(this, "top"), E(this, "width"), E(this, "height"), this.parentRect = t, this.children = i, this.siblingConfigNode = n, this.id = o, this.minWidth = s, this.minHeight = r, this.position = this.getPosition(a), this.size = this.getSize(l), this.nonCoreData = c, this.setBounds();
323
+ b(this, "left"), b(this, "top"), b(this, "width"), b(this, "height"), this.parentRect = t, this.children = i, this.siblingConfigNode = n, this.id = s, this.minWidth = o, this.minHeight = h, this.position = this.getPosition(a), this.size = this.getSize(d), this.nonCoreData = l, this.setBounds();
320
324
  }
321
325
  getPosition(t) {
322
326
  if (!this.siblingConfigNode)
@@ -330,40 +334,40 @@ class M {
330
334
  }
331
335
  getSize(t) {
332
336
  if (!this.siblingConfigNode)
333
- return R(t);
337
+ return z(t);
334
338
  if (!t) {
335
339
  if (this.siblingConfigNode.size < 1)
336
340
  return 1 - this.siblingConfigNode.size;
337
- if (this.siblingConfigNode.position === h.Left || this.siblingConfigNode.position === h.Right)
341
+ if (this.siblingConfigNode.position === r.Left || this.siblingConfigNode.position === r.Right)
338
342
  return this.parentRect.width - this.siblingConfigNode.width;
339
- if (this.siblingConfigNode.position === h.Top || this.siblingConfigNode.position === h.Bottom)
343
+ if (this.siblingConfigNode.position === r.Top || this.siblingConfigNode.position === r.Bottom)
340
344
  return this.parentRect.height - this.siblingConfigNode.height;
341
345
  }
342
- const i = R(t);
346
+ const i = z(t);
343
347
  if (i < 1) {
344
348
  if (i + this.siblingConfigNode.size !== 1)
345
349
  throw new Error("[bwin] Sum of sibling sizes is not equal to 1");
346
350
  } else {
347
- if ((this.position === h.Left || this.position === h.Right) && i + this.siblingConfigNode.size !== this.parentRect.width)
351
+ if ((this.position === r.Left || this.position === r.Right) && i + this.siblingConfigNode.size !== this.parentRect.width)
348
352
  throw new Error("[bwin] Sum of sibling sizes is not equal to parent width");
349
- if ((this.position === h.Top || this.position === h.Bottom) && i + this.siblingConfigNode.size !== this.parentRect.height)
353
+ if ((this.position === r.Top || this.position === r.Bottom) && i + this.siblingConfigNode.size !== this.parentRect.height)
350
354
  throw new Error("[bwin] Sum of sibling sizes is not equal to parent height");
351
355
  }
352
356
  return i;
353
357
  }
354
358
  setBounds() {
355
- if (this.position === h.Root)
359
+ if (this.position === r.Root)
356
360
  this.left = 0, this.top = 0, this.width = this.parentRect.width, this.height = this.parentRect.height;
357
- else if (this.position === h.Left) {
361
+ else if (this.position === r.Left) {
358
362
  const t = this.size < 1 ? this.parentRect.width * this.size : this.size;
359
363
  this.left = this.parentRect.left, this.top = this.parentRect.top, this.width = t, this.height = this.parentRect.height;
360
- } else if (this.position === h.Right) {
364
+ } else if (this.position === r.Right) {
361
365
  const t = this.size < 1 ? this.parentRect.width * this.size : this.size;
362
366
  this.left = this.parentRect.left + this.parentRect.width - t, this.top = this.parentRect.top, this.width = t, this.height = this.parentRect.height;
363
- } else if (this.position === h.Top) {
367
+ } else if (this.position === r.Top) {
364
368
  const t = this.size < 1 ? this.parentRect.height * this.size : this.size;
365
369
  this.left = this.parentRect.left, this.top = this.parentRect.top, this.width = this.parentRect.width, this.height = t;
366
- } else if (this.position === h.Bottom) {
370
+ } else if (this.position === r.Bottom) {
367
371
  const t = this.size < 1 ? this.parentRect.height * this.size : this.size;
368
372
  this.left = this.parentRect.left, this.top = this.parentRect.top + this.parentRect.height - t, this.width = this.parentRect.width, this.height = t;
369
373
  }
@@ -389,7 +393,7 @@ class M {
389
393
  children: t
390
394
  };
391
395
  if (typeof t == "string" || typeof t == "number") {
392
- const i = R(t);
396
+ const i = z(t);
393
397
  if (isNaN(i))
394
398
  throw new Error(`[bwin] Invalid size value: ${i}`);
395
399
  return {
@@ -401,28 +405,28 @@ class M {
401
405
  throw new Error(`[bwin] Invalid config value: ${t}`);
402
406
  }
403
407
  }
404
- createPrimaryConfigNode({ size: t, position: i, children: n, id: o, minWidth: s, minHeight: r, ...a }) {
405
- return new M({
408
+ createPrimaryConfigNode({ size: t, position: i, children: n, id: s, minWidth: o, minHeight: h, ...a }) {
409
+ return new P({
406
410
  parentRect: this,
407
- size: t ?? L.size,
408
- position: i ?? L.position,
411
+ size: t ?? B.size,
412
+ position: i ?? B.position,
409
413
  children: n,
410
- id: o,
411
- minWidth: s,
412
- minHeight: r,
414
+ id: s,
415
+ minWidth: o,
416
+ minHeight: h,
413
417
  ...a
414
418
  });
415
419
  }
416
- createSecondaryConfigNode({ size: t, position: i, children: n, id: o, minWidth: s, minHeight: r, ...a }, l) {
417
- return new M({
420
+ createSecondaryConfigNode({ size: t, position: i, children: n, id: s, minWidth: o, minHeight: h, ...a }, d) {
421
+ return new P({
418
422
  parentRect: this,
419
423
  size: t,
420
424
  position: i,
421
425
  children: n,
422
- siblingConfigNode: l,
423
- id: o,
424
- minWidth: s,
425
- minHeight: r,
426
+ siblingConfigNode: d,
427
+ id: s,
428
+ minWidth: o,
429
+ minHeight: h,
426
430
  ...a
427
431
  });
428
432
  }
@@ -431,60 +435,154 @@ class M {
431
435
  if (!Array.isArray(this.children) || this.children.length === 0)
432
436
  return t;
433
437
  const i = this.normConfig(this.children[0]), n = this.normConfig(this.children.at(1));
434
- let o, s;
435
- return !i.size && !i.position && n ? (n.position || (n.position = h.Right), o = this.createPrimaryConfigNode(n), s = this.createSecondaryConfigNode(
438
+ let s, o;
439
+ return !i.size && !i.position && n ? (n.position || (n.position = r.Right), s = this.createPrimaryConfigNode(n), o = this.createSecondaryConfigNode(
436
440
  i,
437
- o
438
- )) : (o = this.createPrimaryConfigNode(i), s = this.createSecondaryConfigNode(
441
+ s
442
+ )) : (s = this.createPrimaryConfigNode(i), o = this.createSecondaryConfigNode(
439
443
  n,
440
- o
441
- )), o && s && (t.children.push(o.buildSashTree()), t.children.push(s.buildSashTree())), t;
444
+ s
445
+ )), s && o && (t.children.push(s.buildSashTree()), t.children.push(o.buildSashTree())), t;
442
446
  }
443
447
  }
444
- const A = {
448
+ const x = {
445
449
  width: 333,
446
450
  height: 333
447
- }, D = {
451
+ }, $ = {
448
452
  fitContainer: !1
449
453
  };
450
- class nt extends M {
454
+ class ot extends P {
451
455
  constructor({
452
456
  id: t,
453
457
  children: i,
454
- width: n = A.width,
455
- height: o = A.height,
456
- fitContainer: s = D.fitContainer,
457
- ...r
458
+ width: n = x.width,
459
+ height: s = x.height,
460
+ fitContainer: o = $.fitContainer,
461
+ ...h
458
462
  } = {
459
- ...A,
460
- ...D
463
+ ...x,
464
+ ...$
461
465
  }) {
462
466
  super({
463
467
  id: t,
464
468
  children: i,
465
469
  size: NaN,
466
- position: h.Root,
467
- parentRect: { width: n, height: o },
468
- ...r
469
- }), this.fitContainer = s;
470
+ position: r.Root,
471
+ parentRect: { width: n, height: s },
472
+ ...h
473
+ }), this.fitContainer = o;
470
474
  }
471
475
  }
472
- class st extends m {
473
- constructor(t = y) {
474
- super({ ...t, position: h.Root }), Object.assign(this, D);
476
+ class ht extends m {
477
+ constructor(t = E) {
478
+ super({ ...t, position: r.Root }), Object.assign(this, $);
475
479
  }
476
480
  }
477
- const ot = {
481
+ function S(e) {
482
+ const t = document.createElement("bw-pane");
483
+ return t.style.top = `${e.top}px`, t.style.left = `${e.left}px`, t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.setAttribute("sash-id", e.id), t.setAttribute("position", e.position), t;
484
+ }
485
+ function rt(e) {
486
+ const t = e.domNode;
487
+ return t.style.top = `${e.top}px`, t.style.left = `${e.left}px`, t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.setAttribute("position", e.position), t;
488
+ }
489
+ function at(e, { size: t }) {
490
+ const i = z(t);
491
+ let n = e.width / 2;
492
+ i && (i < 1 ? n = e.width * i : n = i);
493
+ const s = new m({
494
+ top: e.top,
495
+ left: e.left,
496
+ width: n,
497
+ height: e.height,
498
+ position: r.Left
499
+ }), o = new m({
500
+ top: e.top,
501
+ left: e.left + s.width,
502
+ width: e.width - n,
503
+ height: e.height,
504
+ position: r.Right
505
+ }), h = S(o);
506
+ return o.domNode = h, N(h, e.domNode), e.addChild(s), e.addChild(o), s;
507
+ }
508
+ function lt(e, { size: t }) {
509
+ const i = z(t);
510
+ let n = e.width / 2;
511
+ i && (i < 1 ? n = e.width * i : n = i);
512
+ const s = new m({
513
+ left: e.left,
514
+ top: e.top,
515
+ width: e.width - n,
516
+ height: e.height,
517
+ position: r.Left
518
+ }), o = new m({
519
+ left: e.left + s.width,
520
+ top: e.top,
521
+ width: n,
522
+ height: e.height,
523
+ position: r.Right
524
+ }), h = S(s);
525
+ return s.domNode = h, N(h, e.domNode), e.addChild(s), e.addChild(o), o;
526
+ }
527
+ function dt(e, { size: t }) {
528
+ const i = z(t);
529
+ let n = e.height / 2;
530
+ i && (i < 1 ? n = e.height * i : n = i);
531
+ const s = new m({
532
+ left: e.left,
533
+ top: e.top,
534
+ width: e.width,
535
+ height: n,
536
+ position: r.Top
537
+ }), o = new m({
538
+ left: e.left,
539
+ top: e.top + s.height,
540
+ width: e.width,
541
+ height: e.height - n,
542
+ position: r.Bottom
543
+ }), h = S(o);
544
+ return o.domNode = h, N(h, e.domNode), e.addChild(s), e.addChild(o), s;
545
+ }
546
+ function ct(e, { size: t }) {
547
+ const i = z(t);
548
+ let n = e.height / 2;
549
+ i && (i < 1 ? n = e.height * i : n = i);
550
+ const s = new m({
551
+ top: e.top,
552
+ left: e.left,
553
+ width: e.width,
554
+ height: e.height - n,
555
+ position: r.Top
556
+ }), o = new m({
557
+ top: e.top + s.height,
558
+ left: e.left,
559
+ width: e.width,
560
+ height: n,
561
+ position: r.Bottom
562
+ }), h = S(s);
563
+ return s.domNode = h, N(h, e.domNode), e.addChild(s), e.addChild(o), o;
564
+ }
565
+ function pt(e, { position: t, size: i, minWidth: n, minHeight: s }) {
566
+ if (t === r.Left)
567
+ return at(e, { size: i });
568
+ if (t === r.Right)
569
+ return lt(e, { size: i });
570
+ if (t === r.Top)
571
+ return dt(e, { size: i });
572
+ if (t === r.Bottom)
573
+ return ct(e, { size: i });
574
+ }
575
+ const ut = {
478
576
  createPane(e) {
479
577
  const t = S(e);
480
578
  return e.store.droppable === !1 && t.setAttribute("can-drop", "false"), t;
481
579
  },
482
580
  // Intended to be overridden
483
581
  onPaneCreate(e, t) {
484
- t.store.content && e.append(C(t.store.content)), this != null && this.debug && (e.style.backgroundColor = X(), e.innerHTML = "", e.append(T(e)));
582
+ t.store.content && e.append(v(t.store.content)), this != null && this.debug && (e.style.backgroundColor = X(), e.innerHTML = "", e.append(T(e)));
485
583
  },
486
584
  updatePane(e) {
487
- return ht(e);
585
+ return rt(e);
488
586
  },
489
587
  // Intended to be overridden
490
588
  onPaneUpdate(e, t) {
@@ -497,12 +595,12 @@ const ot = {
497
595
  * @param {'top'|'right'|'bottom'|'left'} position - The position of the new pane relative to the target pane
498
596
  * @returns {Sash} - The newly created sash
499
597
  */
500
- addPane(e, t) {
598
+ addPane(e, { position: t, size: i }) {
501
599
  if (!t) throw new Error("[bwin] Position is required when adding pane");
502
- const i = this.rootSash.getById(e);
503
- if (!i) throw new Error("[bwin] Parent sash not found when adding pane");
504
- const n = ct(i, t);
505
- return i.id = P(), this.update(), n;
600
+ const n = this.rootSash.getById(e);
601
+ if (!n) throw new Error("[bwin] Parent sash not found when adding pane");
602
+ const s = pt(n, { position: t, size: i });
603
+ return n.id = D(), this.update(), s;
506
604
  },
507
605
  /**
508
606
  * Remove a pane
@@ -513,117 +611,31 @@ const ot = {
513
611
  const t = this.rootSash.getDescendantParentById(e);
514
612
  if (!t) throw new Error("[bwin] Parent sash not found when removing pane");
515
613
  const i = t.getChildSiblingById(e);
516
- t.id = P(), i.children.length === 0 ? (t.domNode = i.domNode, t.domNode.setAttribute("sash-id", t.id), t.children = []) : (t.children = i.children, i.position === h.Left ? i.width = t.width : i.position === h.Right ? (i.width = t.width, i.left = t.left) : i.position === h.Top ? i.height = t.height : i.position === h.Bottom && (i.height = t.height, i.top = t.top)), this.update();
614
+ t.id = D(), i.children.length === 0 ? (t.domNode = i.domNode, t.domNode.setAttribute("sash-id", t.id), t.children = []) : (t.children = i.children, i.position === r.Left ? i.width = t.width : i.position === r.Right ? (i.width = t.width, i.left = t.left) : i.position === r.Top ? i.height = t.height : i.position === r.Bottom && (i.height = t.height, i.top = t.top)), this.update();
517
615
  }
518
616
  };
519
- function S(e) {
520
- const t = document.createElement("bw-pane");
521
- return t.style.top = `${e.top}px`, t.style.left = `${e.left}px`, t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.setAttribute("sash-id", e.id), t.setAttribute("position", e.position), t;
522
- }
523
- function ht(e) {
524
- const t = e.domNode;
525
- return t.style.top = `${e.top}px`, t.style.left = `${e.left}px`, t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.setAttribute("position", e.position), t;
526
- }
527
- function rt(e) {
528
- const t = new m({
529
- top: e.top,
530
- left: e.left,
531
- width: e.width / 2,
532
- height: e.height,
533
- position: h.Left
534
- }), i = new m({
535
- top: e.top,
536
- left: e.left + t.width,
537
- width: e.width / 2,
538
- height: e.height,
539
- position: h.Right
540
- }), n = S(i);
541
- return i.domNode = n, v(n, e.domNode), e.addChild(t), e.addChild(i), t;
542
- }
543
- function at(e) {
544
- const t = new m({
545
- top: e.top,
546
- left: e.left,
547
- width: e.width / 2,
548
- height: e.height,
549
- position: h.Left
550
- }), i = S(t);
551
- t.domNode = i, v(i, e.domNode);
552
- const n = new m({
553
- top: e.top,
554
- left: e.left + t.width,
555
- width: e.width / 2,
556
- height: e.height,
557
- position: h.Right
558
- });
559
- return e.addChild(t), e.addChild(n), n;
560
- }
561
- function lt(e) {
562
- const t = new m({
563
- top: e.top,
564
- left: e.left,
565
- width: e.width,
566
- height: e.height / 2,
567
- position: h.Top
568
- }), i = new m({
569
- top: e.top + t.height,
570
- left: e.left,
571
- width: e.width,
572
- height: e.height / 2,
573
- position: h.Bottom
574
- }), n = S(i);
575
- return i.domNode = n, v(n, e.domNode), e.addChild(t), e.addChild(i), t;
576
- }
577
- function dt(e) {
578
- const t = new m({
579
- top: e.top,
580
- left: e.left,
581
- width: e.width,
582
- height: e.height / 2,
583
- position: h.Top
584
- }), i = S(t);
585
- t.domNode = i, v(i, e.domNode);
586
- const n = new m({
587
- top: e.top + t.height,
588
- left: e.left,
589
- width: e.width,
590
- height: e.height / 2,
591
- position: h.Bottom
592
- });
593
- return e.addChild(t), e.addChild(n), n;
594
- }
595
- function ct(e, t) {
596
- if (t === h.Left)
597
- return rt(e);
598
- if (t === h.Right)
599
- return at(e);
600
- if (t === h.Top)
601
- return lt(e);
602
- if (t === h.Bottom)
603
- return dt(e);
604
- }
605
617
  function T(e) {
606
618
  const t = document.createElement("pre");
607
619
  t.style.fontSize = "10px";
608
620
  const i = `
609
- id: ${e.getAttribute("sash-id")}
621
+ ${e.getAttribute("sash-id")}
622
+ ${e.getAttribute("position")}
610
623
  top: ${e.style.top}
611
624
  left: ${e.style.left}
612
625
  width: ${e.style.width}
613
626
  height: ${e.style.height}
614
- position: ${e.getAttribute("position")}
615
627
  `;
616
628
  return t.innerHTML = i.trim(), t;
617
629
  }
618
- const pt = {
630
+ const gt = {
619
631
  createWindow() {
620
632
  const e = document.createElement("bw-window");
621
633
  return e.style.width = `${this.rootSash.width}px`, e.style.height = `${this.rootSash.height}px`, e.setAttribute("sash-id", this.rootSash.id), e;
622
634
  },
623
- glaze(e) {
624
- this.rootSash.walk((t) => {
625
- let i = null;
626
- t.children.length > 0 ? (i = this.createMuntin(t), this.onMuntinCreate(i, t), e.append(i)) : (i = this.createPane(t), this.onPaneCreate(i, t), e.prepend(i)), t.domNode = i;
635
+ glaze() {
636
+ this.rootSash.walk((e) => {
637
+ let t = null;
638
+ e.children.length > 0 ? (t = this.createMuntin(e), this.onMuntinCreate(t, e), this.windowElement.append(t)) : (t = this.createPane(e), this.onPaneCreate(t, e), this.windowElement.prepend(t)), e.domNode = t;
627
639
  });
628
640
  },
629
641
  update() {
@@ -636,7 +648,7 @@ const pt = {
636
648
  i.children.length > 0 ? t.includes(i.id) ? (this.updateMuntin(i), this.onMuntinUpdate(i.domNode, i)) : (i.domNode = this.createMuntin(i), this.windowElement.append(i.domNode)) : t.includes(i.id) ? (this.updatePane(i), this.onPaneUpdate(i.domNode, i)) : (i.domNode || (i.domNode = this.createPane(i)), this.windowElement.prepend(i.domNode));
637
649
  });
638
650
  }
639
- }, ut = {
651
+ }, ft = {
640
652
  muntinSize: 4,
641
653
  createMuntin(e) {
642
654
  const t = document.createElement("bw-muntin"), i = e.leftChild, n = e.topChild;
@@ -650,7 +662,7 @@ const pt = {
650
662
  },
651
663
  onMuntinUpdate(e, t) {
652
664
  }
653
- }, gt = {
665
+ }, wt = {
654
666
  fitContainer: !1,
655
667
  enableFitContainer() {
656
668
  new ResizeObserver((e) => {
@@ -658,7 +670,7 @@ const pt = {
658
670
  t.target === this.containerElement && this.fitContainer && (this.rootSash.width = t.contentRect.width, this.rootSash.height = t.contentRect.height, this.update());
659
671
  }).observe(this.containerElement);
660
672
  }
661
- }, ft = {
673
+ }, mt = {
662
674
  activeMuntinSash: null,
663
675
  isResizeStarted: !1,
664
676
  isDropStarted: !1,
@@ -677,23 +689,23 @@ const pt = {
677
689
  this.activeMuntinSash = this.rootSash.getById(t), this.activeMuntinSash && (this.isResizeStarted = !0, this.lastX = e.pageX, this.lastY = e.pageY, this.applyResizeStyles());
678
690
  }), document.addEventListener("mousemove", (e) => {
679
691
  if (!this.isResizeStarted || !this.activeMuntinSash) return;
680
- const [t, i, n, o] = this.activeMuntinSash.getChildren(), s = this.activeMuntinSash.isLeftRightSplit(), r = this.activeMuntinSash.isTopBottomSplit();
681
- if (s && o && i) {
682
- const a = e.pageX - this.lastX, l = o.width + a, c = i.width - a;
683
- if (l <= o.calcMinWidth() || c <= i.calcMinWidth())
692
+ const [t, i, n, s] = this.activeMuntinSash.getChildren(), o = this.activeMuntinSash.isLeftRightSplit(), h = this.activeMuntinSash.isTopBottomSplit();
693
+ if (o && s && i) {
694
+ const a = e.pageX - this.lastX, d = s.width + a, l = i.width - a;
695
+ if (d <= s.calcMinWidth() || l <= i.calcMinWidth())
684
696
  return;
685
- o.width = l, i.width = c, i.left = i.left + a, this.update(), this.lastX = e.pageX;
686
- } else if (r && t && n) {
687
- const a = e.pageY - this.lastY, l = t.height + a, c = n.height - a;
688
- if (l <= t.calcMinHeight() || c <= n.calcMinHeight())
697
+ s.width = d, i.width = l, i.left = i.left + a, this.update(), this.lastX = e.pageX;
698
+ } else if (h && t && n) {
699
+ const a = e.pageY - this.lastY, d = t.height + a, l = n.height - a;
700
+ if (d <= t.calcMinHeight() || l <= n.calcMinHeight())
689
701
  return;
690
- t.height = l, n.height = c, n.top = n.top + a, this.update(), this.lastY = e.pageY;
702
+ t.height = d, n.height = l, n.top = n.top + a, this.update(), this.lastY = e.pageY;
691
703
  }
692
704
  }), document.addEventListener("mouseup", () => {
693
705
  this.isResizeStarted = !1, this.activeMuntinSash = null, this.revertResizeStyles();
694
706
  });
695
707
  }
696
- }, wt = {
708
+ }, bt = {
697
709
  activeDropPaneEl: null,
698
710
  // Intended to be overridden in `BinaryWindow` class
699
711
  onPaneDrop(e, t) {
@@ -713,20 +725,22 @@ const pt = {
713
725
  this.onPaneDrop(e, i), typeof i.store.onDrop == "function" && i.store.onDrop(e, i), this.activeDropPaneEl.removeAttribute("drop-area"), this.activeDropPaneEl = null;
714
726
  });
715
727
  }
716
- };
717
- class B {
728
+ }, yt = !1;
729
+ class H {
718
730
  constructor(t) {
719
- E(this, "windowElement", null), E(this, "containerElement", null), E(this, "debug", !1);
731
+ b(this, "windowElement", null), b(this, "containerElement", null), b(this, "debug", yt);
720
732
  let i = null;
721
- t instanceof st ? (i = t, this.rootSash = t) : (i = new nt(t), this.rootSash = i.buildSashTree()), this.fitContainer = i.fitContainer;
733
+ t instanceof ht ? (i = t, this.rootSash = t) : (i = new ot(t), this.rootSash = i.buildSashTree()), this.fitContainer = i.fitContainer;
734
+ }
735
+ frame(t) {
736
+ this.containerElement = t, this.windowElement = this.createWindow(), this.glaze(), this.containerElement.append(this.windowElement);
722
737
  }
723
738
  // Features can work independently to each other
724
739
  enableFeatures() {
725
740
  this.enableResize(), this.enableDrop(), this.fitContainer && this.enableFitContainer();
726
741
  }
727
742
  mount(t) {
728
- const i = this.createWindow();
729
- this.glaze(i), this.containerElement = t, this.containerElement.append(i), this.windowElement = i, this.enableFeatures();
743
+ this.frame(t), this.enableFeatures();
730
744
  }
731
745
  static assemble(...t) {
732
746
  t.forEach((i) => {
@@ -734,15 +748,15 @@ class B {
734
748
  });
735
749
  }
736
750
  }
737
- B.assemble(
738
- pt,
739
- ut,
740
- ot,
751
+ H.assemble(
741
752
  gt,
753
+ ft,
754
+ ut,
742
755
  wt,
743
- ft
756
+ bt,
757
+ mt
744
758
  );
745
- function H(e) {
759
+ function G(e) {
746
760
  if (e.tagName === "BW-PANE")
747
761
  return e.getAttribute("sash-id");
748
762
  const t = e.closest("bw-pane");
@@ -750,16 +764,101 @@ function H(e) {
750
764
  throw new Error("[bwin] Pane element not found");
751
765
  return t.getAttribute("sash-id");
752
766
  }
753
- const I = "bw-glass-action--close", G = [
754
- {
755
- label: "",
756
- className: I,
757
- onClick: (e, t) => {
758
- const i = H(e.target);
759
- t.removePane(i);
767
+ const Et = {
768
+ label: "",
769
+ className: "bw-glass-action--close",
770
+ onClick: (e, t) => {
771
+ const i = G(e.target);
772
+ t.removePane(i);
773
+ }
774
+ }, vt = {
775
+ label: "",
776
+ className: "bw-glass-action--minimize",
777
+ onClick: (e, t) => {
778
+ const i = t.sillElement;
779
+ if (!i) throw new Error("[bwin] Sill element not found when minimizing");
780
+ const n = v('<button class="bw-minimized-glass" />');
781
+ i.append(n);
782
+ const s = e.target.closest("bw-pane"), o = e.target.closest("bw-glass"), h = s.getAttribute("sash-id"), a = s.getAttribute("position");
783
+ n.bwGlassElement = o, n.bwOriginalPosition = a, n.bwOriginalBoundingRect = R(s), t.removePane(h);
784
+ }
785
+ }, Nt = {
786
+ label: "",
787
+ className: "bw-glass-action--maximize",
788
+ onClick: (e) => {
789
+ const t = e.target.closest("bw-pane");
790
+ t.hasAttribute("maximized") ? (t.removeAttribute("maximized"), t.style.left = `${t.bwOriginalBoundingRect.left}px`, t.style.top = `${t.bwOriginalBoundingRect.top}px`, t.style.width = `${t.bwOriginalBoundingRect.width}px`, t.style.height = `${t.bwOriginalBoundingRect.height}px`) : (t.setAttribute("maximized", ""), t.bwOriginalBoundingRect = R(t), t.style.left = "0", t.style.top = "0", t.style.width = "100%", t.style.height = "100%");
791
+ }
792
+ };
793
+ function zt(e, t) {
794
+ const i = e.left + e.width, n = e.top + e.height, s = t.left + t.width, o = t.top + t.height;
795
+ if (e.left >= s || t.left >= i || e.top >= o || t.top >= n)
796
+ return null;
797
+ const h = Math.max(e.left, t.left), a = Math.max(e.top, t.top), d = Math.min(i, s), l = Math.min(n, o);
798
+ return {
799
+ left: h,
800
+ top: a,
801
+ width: d - h,
802
+ height: l - a
803
+ };
804
+ }
805
+ const I = [vt, Nt, Et], Ct = {
806
+ enableActions() {
807
+ this.handleMinimizedGlassClick(), this.observeActionButtons();
808
+ },
809
+ restoreGlass(e) {
810
+ const t = e.bwOriginalBoundingRect;
811
+ let i = 0, n = null;
812
+ if (this.windowElement.querySelectorAll("bw-pane").forEach((s) => {
813
+ const o = R(s), h = zt(t, o);
814
+ if (h) {
815
+ const a = h.width * h.height;
816
+ a > i && (i = a, n = s);
817
+ }
818
+ }), n) {
819
+ const s = e.bwOriginalPosition, o = R(n);
820
+ let h = 0;
821
+ if (s === r.Left || s === r.Right)
822
+ h = t.width >= o.width ? o.width / 2 : t.width;
823
+ else if (s === r.Top || s === r.Bottom)
824
+ h = t.height >= o.height ? o.height / 2 : t.height;
825
+ else
826
+ throw new Error("[bwin] Invalid position when restoring glass");
827
+ this.addPane(n.getAttribute("sash-id"), {
828
+ position: s,
829
+ size: h
830
+ }).domNode.append(e.bwGlassElement);
760
831
  }
832
+ },
833
+ handleMinimizedGlassClick() {
834
+ this.sillElement.addEventListener("click", (e) => {
835
+ if (!e.target.matches(".bw-minimized-glass")) return;
836
+ const t = e.target;
837
+ this.restoreGlass(t), t.remove();
838
+ });
839
+ },
840
+ updateDisabledStateOfActionButtons() {
841
+ this.updateDisabledState(".bw-glass-action--close"), this.updateDisabledState(".bw-glass-action--minimize"), this.updateDisabledState(".bw-glass-action--maximize");
842
+ },
843
+ updateDisabledState(e) {
844
+ if (this.windowElement.querySelectorAll("bw-pane").length === 1) {
845
+ const t = this.windowElement.querySelector(e);
846
+ t && t.setAttribute("disabled", "");
847
+ } else
848
+ this.windowElement.querySelectorAll(e).forEach((t) => {
849
+ t.removeAttribute("disabled");
850
+ });
851
+ },
852
+ observeActionButtons() {
853
+ this.updateDisabledStateOfActionButtons(), new MutationObserver((e) => {
854
+ e.forEach((t) => {
855
+ t.type === "childList" && this.updateDisabledStateOfActionButtons();
856
+ });
857
+ }).observe(this.windowElement, {
858
+ childList: !0
859
+ });
761
860
  }
762
- ], N = {
861
+ }, C = {
763
862
  title: null,
764
863
  content: null,
765
864
  tabs: [],
@@ -768,43 +867,43 @@ const I = "bw-glass-action--close", G = [
768
867
  };
769
868
  class W {
770
869
  constructor({
771
- title: t = N.title,
772
- content: i = N.content,
773
- tabs: n = N.tabs,
774
- actions: o = N.actions,
775
- draggable: s = N.draggable,
776
- sash: r,
870
+ title: t = C.title,
871
+ content: i = C.content,
872
+ tabs: n = C.tabs,
873
+ actions: s = C.actions,
874
+ draggable: o = C.draggable,
875
+ sash: h,
777
876
  binaryWindow: a
778
877
  }) {
779
- E(this, "domNode"), this.title = t, this.content = i, this.tabs = n, this.actions = o, this.sash = r, this.draggable = s, this.binaryWindow = a, this.build();
878
+ b(this, "domNode"), this.title = t, this.content = i, this.tabs = n, this.actions = s, this.sash = h, this.draggable = o, this.binaryWindow = a, this.build();
780
879
  }
781
880
  build() {
782
881
  const t = document.createElement("bw-glass-header");
783
882
  if (Array.isArray(this.tabs) && this.tabs.length > 0)
784
883
  t.append(this.createTabs());
785
884
  else if (this.title) {
786
- const o = document.createElement("bw-glass-title");
787
- o.append(C(this.title)), t.append(o);
885
+ const s = document.createElement("bw-glass-title");
886
+ s.append(v(this.title)), t.append(s);
788
887
  }
789
888
  t.setAttribute("can-drag", this.draggable), t.append(this.createActions());
790
- const i = document.createElement("bw-glass-content"), n = C(this.content);
889
+ const i = document.createElement("bw-glass-content"), n = v(this.content);
791
890
  n && i.append(n), this.domNode = document.createElement("bw-glass"), this.domNode.append(t, i);
792
891
  }
793
892
  createTabs() {
794
893
  const t = document.createElement("bw-glass-tab-container");
795
894
  for (const i of this.tabs) {
796
- const n = (i == null ? void 0 : i.label) ?? i, o = C(`<button class="bw-glass-tab">${n}</button>`);
797
- t.append(o);
895
+ const n = (i == null ? void 0 : i.label) ?? i, s = v(`<button class="bw-glass-tab">${n}</button>`);
896
+ t.append(s);
798
897
  }
799
898
  return t;
800
899
  }
801
900
  createActions() {
802
- const t = document.createElement("bw-glass-action-container"), i = this.actions === void 0 ? G : Array.isArray(this.actions) ? this.actions : [];
901
+ const t = document.createElement("bw-glass-action-container"), i = this.actions === void 0 ? I : Array.isArray(this.actions) ? this.actions : [];
803
902
  for (const n of i) {
804
- const o = (n == null ? void 0 : n.label) ?? n, s = n.className ? `bw-glass-action ${n.className}` : "bw-glass-action", r = C(`<button class="${s}">${o}</button>`);
805
- typeof n.onClick == "function" && r.addEventListener("click", (a) => {
903
+ const s = (n == null ? void 0 : n.label) ?? n, o = n.className ? `bw-glass-action ${n.className}` : "bw-glass-action", h = v(`<button class="${o}">${s}</button>`);
904
+ typeof n.onClick == "function" && h.addEventListener("click", (a) => {
806
905
  n.onClick(a, this.binaryWindow);
807
- }), t.append(r);
906
+ }), t.append(h);
808
907
  }
809
908
  return t;
810
909
  }
@@ -815,40 +914,19 @@ class W {
815
914
  return this.domNode.querySelector("bw-glass-header");
816
915
  }
817
916
  }
818
- const mt = {
819
- enableObservers() {
820
- this.observeCloseButtons();
821
- },
822
- observeCloseButtons() {
823
- const e = `.${I}`;
824
- new MutationObserver((t) => {
825
- t.forEach((i) => {
826
- if (i.type === "childList")
827
- if (this.windowElement.querySelectorAll("bw-pane").length === 1) {
828
- const n = this.windowElement.querySelector(e);
829
- n && n.setAttribute("disabled", "");
830
- } else
831
- this.windowElement.querySelectorAll(e).forEach((n) => {
832
- n.removeAttribute("disabled");
833
- });
834
- });
835
- }).observe(this.windowElement, {
836
- childList: !0
837
- });
838
- }
839
- }, bt = {
917
+ const St = {
840
918
  activeDragGlassEl: null,
841
919
  activeDragGlassPaneCanDrop: !1,
842
920
  onPaneDrop(e, t) {
843
921
  if (!this.activeDragGlassEl) return;
844
922
  const i = this.activeDropPaneEl.getAttribute("drop-area");
845
923
  if (i === "center") {
846
- const n = this.activeDragGlassEl.closest("bw-pane"), o = this.activeDropPaneEl.getAttribute("can-drop") !== "false";
847
- Y(n, this.activeDropPaneEl), n.setAttribute("can-drop", o);
924
+ const n = this.activeDragGlassEl.closest("bw-pane"), s = this.activeDropPaneEl.getAttribute("can-drop") !== "false";
925
+ Y(n, this.activeDropPaneEl), n.setAttribute("can-drop", s);
848
926
  return;
849
927
  } else {
850
- const n = H(this.activeDragGlassEl);
851
- this.addPane(t.id, i).domNode.append(this.activeDragGlassEl), this.removePane(n);
928
+ const n = G(this.activeDragGlassEl);
929
+ this.addPane(t.id, { position: i }).domNode.append(this.activeDragGlassEl), this.removePane(n);
852
930
  }
853
931
  },
854
932
  enableDrag() {
@@ -872,7 +950,7 @@ const mt = {
872
950
  this.activeDragGlassEl && (this.activeDragGlassEl.removeAttribute("draggable"), this.activeDragGlassEl.closest("bw-pane").setAttribute("can-drop", this.activeDragGlassPaneCanDrop), this.activeDragGlassEl = null);
873
951
  });
874
952
  }
875
- }, yt = {
953
+ }, At = {
876
954
  trimMuntin(e) {
877
955
  e.hasAttribute("vertical") ? (e.style.top = `${parseFloat(e.style.top) + this.muntinSize / 2}px`, e.style.height = `${parseFloat(e.style.height) - this.muntinSize}px`) : e.hasAttribute("horizontal") && (e.style.left = `${parseFloat(e.style.left) + this.muntinSize / 2}px`, e.style.width = `${parseFloat(e.style.width) - this.muntinSize}px`);
878
956
  },
@@ -883,9 +961,17 @@ const mt = {
883
961
  this.trimMuntin(e);
884
962
  }
885
963
  };
886
- class k extends B {
964
+ class O extends H {
965
+ constructor() {
966
+ super(...arguments), b(this, "sillElement", null);
967
+ }
968
+ frame() {
969
+ super.frame(...arguments);
970
+ const t = v("<bw-sill />");
971
+ this.windowElement.append(t), this.sillElement = t;
972
+ }
887
973
  enableFeatures() {
888
- super.enableFeatures(), this.enableObservers(), this.enableDrag();
974
+ super.enableFeatures(), this.enableDrag(), this.enableActions();
889
975
  }
890
976
  onPaneCreate(t, i) {
891
977
  const n = new W({ ...i.store, sash: i, binaryWindow: this });
@@ -902,8 +988,8 @@ class k extends B {
902
988
  *
903
989
  */
904
990
  addGlass(t, i, n) {
905
- const o = this.addPane(t, i), s = new W({ ...n, sash: o, binaryWindow: this });
906
- o.domNode.append(s.domNode);
991
+ const s = this.addPane(t, { position: i }), o = new W({ ...n, sash: s, binaryWindow: this });
992
+ s.domNode.append(o.domNode);
907
993
  }
908
994
  /**
909
995
  * Remove glass from or together with the pane
@@ -917,52 +1003,52 @@ class k extends B {
917
1003
  else {
918
1004
  const n = this.rootSash.getById(t);
919
1005
  if (!n) throw new Error("[bwin] Pane not found when removing glass");
920
- const o = n.domNode.querySelector("bw-glass");
921
- o && o.remove();
1006
+ const s = n.domNode.querySelector("bw-glass");
1007
+ s && s.remove();
922
1008
  }
923
1009
  }
924
1010
  }
925
- k.assemble(mt, bt, yt);
926
- const b = 4;
927
- function Et({ sash: e }) {
928
- var d;
929
- const t = x(), i = e.leftChild, n = e.topChild;
930
- let o, s, r, a, l, c;
931
- return i ? (o = b, s = e.height - b, r = e.top + b / 2, a = e.left + i.width - b / 2, l = !0) : n && (o = e.width - b, s = b, r = e.top + n.height - b / 2, a = e.left + b / 2, c = !0), $(() => {
1011
+ O.assemble(St, At, Ct);
1012
+ const y = 4;
1013
+ function Mt({ sash: e }) {
1014
+ var c;
1015
+ const t = M(), i = e.leftChild, n = e.topChild;
1016
+ let s, o, h, a, d, l;
1017
+ return i ? (s = y, o = e.height - y, h = e.top + y / 2, a = e.left + i.width - y / 2, d = !0) : n && (s = e.width - y, o = y, h = e.top + n.height - y / 2, a = e.left + y / 2, l = !0), L(() => {
932
1018
  e.domNode = t.current;
933
1019
  }, []), /* @__PURE__ */ g.createElement(
934
1020
  "bw-muntin",
935
1021
  {
936
1022
  "sash-id": e.id,
937
1023
  style: {
938
- width: o,
939
- height: s,
940
- top: r,
1024
+ width: s,
1025
+ height: o,
1026
+ top: h,
941
1027
  left: a
942
1028
  },
943
- vertical: l,
944
- horizontal: c,
945
- resizable: ((d = e.store) == null ? void 0 : d.resizable) === !1 ? "false" : "true",
1029
+ vertical: d,
1030
+ horizontal: l,
1031
+ resizable: ((c = e.store) == null ? void 0 : c.resizable) === !1 ? "false" : "true",
946
1032
  ref: t
947
1033
  }
948
1034
  );
949
1035
  }
950
- function vt({
1036
+ function Rt({
951
1037
  sash: e,
952
1038
  bwin: t
953
1039
  }) {
954
- var d, p, u, f, w;
955
- const i = x(), { left: n, top: o, width: s, height: r, id: a, position: l } = e;
956
- $(() => {
1040
+ var c, p, u, f, w;
1041
+ const i = M(), { left: n, top: s, width: o, height: h, id: a, position: d } = e;
1042
+ L(() => {
957
1043
  e.domNode = i.current;
958
1044
  }, []);
959
- const c = ((d = e.store) == null ? void 0 : d.actions) === void 0 ? G : Array.isArray(e.store.actions) ? e.store.actions : [];
1045
+ const l = ((c = e.store) == null ? void 0 : c.actions) === void 0 ? I : Array.isArray(e.store.actions) ? e.store.actions : [];
960
1046
  return /* @__PURE__ */ g.createElement(
961
1047
  "bw-pane",
962
1048
  {
963
1049
  "sash-id": a,
964
- position: l,
965
- style: { left: n, top: o, width: s, height: r },
1050
+ position: d,
1051
+ style: { left: n, top: s, width: o, height: h },
966
1052
  "can-drop": ((p = e.store) == null ? void 0 : p.droppable) === !1 ? "false" : "true",
967
1053
  ref: i
968
1054
  },
@@ -972,40 +1058,41 @@ function vt({
972
1058
  "can-drag": ((u = e.store) == null ? void 0 : u.draggable) === !1 ? "false" : "true"
973
1059
  },
974
1060
  ((f = e.store) == null ? void 0 : f.title) && /* @__PURE__ */ g.createElement("bw-glass-title", null, e.store.title),
975
- c.length > 0 && /* @__PURE__ */ g.createElement("bw-glass-action-container", null, c.map((z, _) => {
976
- const O = z.className ? `bw-glass-action ${z.className}` : "bw-glass-action";
1061
+ l.length > 0 && /* @__PURE__ */ g.createElement("bw-glass-action-container", null, l.map((A, k) => {
1062
+ const F = A.className ? `bw-glass-action ${A.className}` : "bw-glass-action";
977
1063
  return /* @__PURE__ */ g.createElement(
978
1064
  "button",
979
1065
  {
980
- className: O,
981
- key: _,
982
- onClick: (q) => z.onClick(q, t)
1066
+ className: F,
1067
+ key: k,
1068
+ onClick: (_) => A.onClick(_, t)
983
1069
  },
984
- z.label
1070
+ A.label
985
1071
  );
986
1072
  }))
987
1073
  ), /* @__PURE__ */ g.createElement("bw-glass-content", null, (w = e.store) == null ? void 0 : w.content))
988
1074
  );
989
1075
  }
990
- function Ct(e) {
991
- const t = x(), i = new k(e), n = [], o = [];
992
- return i.rootSash.walk((s) => {
993
- s.children.length > 0 ? n.push(s) : o.push(s);
994
- }), $(() => {
995
- const s = t.current;
996
- s != null && s.parentElement && (i.windowElement = s, i.containerElement = s.parentElement, i.enableFeatures());
1076
+ function xt(e) {
1077
+ const t = M(), i = M(), { panes: n, ...s } = e, o = { children: n, ...s }, h = new O(o), a = [], d = [];
1078
+ return h.rootSash.walk((l) => {
1079
+ l.children.length > 0 ? a.push(l) : d.push(l);
1080
+ }), L(() => {
1081
+ const l = t.current;
1082
+ l != null && l.parentElement && (h.windowElement = l, h.containerElement = l.parentElement, h.sillElement = i.current, h.enableFeatures());
997
1083
  }, []), /* @__PURE__ */ g.createElement(
998
1084
  "bw-window",
999
1085
  {
1000
- "sash-id": i.rootSash.id,
1001
- style: { width: i.rootSash.width, height: i.rootSash.height },
1086
+ "sash-id": h.rootSash.id,
1087
+ style: { width: h.rootSash.width, height: h.rootSash.height },
1002
1088
  ref: t
1003
1089
  },
1004
- o.map((s) => /* @__PURE__ */ g.createElement(vt, { key: s.id, sash: s, bwin: i })),
1005
- n.map((s) => /* @__PURE__ */ g.createElement(Et, { key: s.id, sash: s }))
1090
+ d.map((l) => /* @__PURE__ */ g.createElement(Rt, { key: l.id, sash: l, bwin: h })),
1091
+ a.map((l) => /* @__PURE__ */ g.createElement(Mt, { key: l.id, sash: l })),
1092
+ /* @__PURE__ */ g.createElement("bw-sill", { ref: i })
1006
1093
  );
1007
1094
  }
1008
1095
  export {
1009
- G as BUILTIN_ACTIONS,
1010
- Ct as Window
1096
+ I as BUILTIN_ACTIONS,
1097
+ xt as Window
1011
1098
  };