bwin 0.2.4 → 0.2.6

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