perfect-gui 5.1.3 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,375 +1,242 @@
1
- class S {
2
- constructor(t, e = {}) {
3
- if (this.parent = t, this.callback = null, typeof e != "object")
4
- throw Error(
5
- `[GUI] button() first parameter must be an object. Received: ${typeof e}.`
6
- );
7
- let r = e.label || " ";
8
- const d = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? r : null, i = document.createElement("div");
9
- i.className = "p-gui__button", i.textContent = r, d && i.setAttribute("title", d), i.addEventListener("click", () => {
10
- this.callback && this.callback(), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
11
- }), typeof e.color == "string" && (i.style.setProperty("--color-accent", e.color), i.style.setProperty(
12
- "--color-accent-hover",
13
- e.hoverColor || e.color
14
- )), this.parent.wrapper.append(i), this.element = i;
15
- }
16
- onClick(t) {
17
- return this.callback = t, this;
18
- }
19
- }
20
- class Y {
21
- constructor(t, e, r, d) {
22
- this.parent = t, this.propReferences = [];
23
- let i = {}, l = null;
24
- if (e && typeof e == "object" && typeof r == "string")
25
- this.obj = e, this.prop = r, this.isObject = !0, i = d || {}, this.callback = null;
26
- else if (e && typeof e == "object")
27
- this.isObject = !1, i = e, l = typeof i.value == "number" ? i.value : null;
28
- else
29
- throw Error("[GUI] slider() invalid parameters.");
30
- let c = typeof i.label == "string" && i.label || " ";
31
- this.isObject && c == " " && (c = this.prop), this.min = i.min ?? 0, this.max = i.max ?? 1, this.step = i.step || (this.max - this.min) / 100, this.decimals = this.parent._countDecimals(this.step);
32
- let n = null;
33
- this.isObject ? n = this.propReferences.push(this.obj[this.prop]) - 1 : l === null && (l = (this.max - this.min) / 2);
34
- const o = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? c : null, a = document.createElement("div");
35
- a.className = "p-gui__slider", o && a.setAttribute("title", o), this.parent.wrapper.append(a), this.element = a;
36
- const h = document.createElement("div");
37
- h.className = "p-gui__slider-name", h.textContent = c, a.append(h), this.ctrlDiv = document.createElement("div"), this.ctrlDiv.className = "p-gui__slider-ctrl", this.ctrlDiv.setAttribute("type", "range"), this.ctrlDiv.setAttribute("min", this.min), this.ctrlDiv.setAttribute("max", this.max), a.append(this.ctrlDiv);
38
- const p = document.createElement("div");
39
- p.className = "p-gui__slider-bar", this.ctrlDiv.append(p), this.handle = document.createElement("div"), this.handle.className = "p-gui__slider-handle", this.ctrlDiv.append(this.handle), this.filling = document.createElement("div"), this.filling.className = "p-gui__slider-filling", p.append(this.filling), this.valueInput = document.createElement("input"), this.valueInput.className = "p-gui__slider-value", this.valueInput.value = this.isObject ? this.obj[this.prop] : l, a.append(this.valueInput), setTimeout(() => {
40
- const s = this.ctrlDiv.offsetWidth, f = this.handle.offsetWidth;
41
- this.handle.position = this._mapLinear(
42
- this.valueInput.value,
43
- this.min,
44
- this.max,
45
- f / 2,
46
- s - f / 2
47
- ), this.handle.position = Math.min(
48
- this.handle.position,
49
- s - f / 2
50
- ), this.handle.position = Math.max(
51
- this.handle.position,
52
- f / 2
53
- ), this.handle.style.transform = `translate(-50%, -50%) translateX(${this.handle.position}px)`, this.filling.style.width = `${this.handle.position}px`;
54
- }, 0), this.valueInput.addEventListener("change", () => {
55
- this._updateHandlePositionFromValue(), this._triggerCallbacks();
56
- }), this.ctrlDiv.addEventListener("pointerdown", (s) => {
57
- this.ctrlDiv.pointerDown = !0, this.ctrlDiv.prevPosition = s.clientX, this._updateHandlePositionFromPointer(s, !0);
58
- }), window.addEventListener("pointerup", (s) => {
59
- this.ctrlDiv.pointerDown = !1;
60
- }), window.addEventListener("pointercancel", (s) => {
61
- this.ctrlDiv.pointerDown = !1;
62
- }), window.addEventListener("pointermove", (s) => {
63
- this.ctrlDiv.pointerDown && (this.ctrlDiv.pointerDelta = s.clientX - this.ctrlDiv.prevPosition, this._updateHandlePositionFromPointer(s));
64
- }), this.isObject && Object.defineProperty(this.obj, this.prop, {
65
- set: (s) => {
66
- this.propReferences[n] = s, this.valueInput.value = s, this._updateHandlePositionFromValue(), this.callback && this.callback(parseFloat(this.valueInput.value));
67
- },
68
- get: () => this.propReferences[n]
69
- });
70
- }
71
- _updateHandlePositionFromPointer(t, e = !1) {
72
- const r = this.ctrlDiv.getBoundingClientRect(), d = r.width, i = this.handle.offsetWidth, l = t.clientX - this.ctrlDiv.prevPosition, c = parseFloat(this.valueInput.value);
73
- let n;
74
- e ? n = t.clientX - r.left : n = this.handle.position + l, n = Math.max(
75
- i / 2,
76
- Math.min(n, d - i / 2)
77
- );
78
- let o = this.min + (this.max - this.min) * (n - i / 2) / (d - i);
79
- o > c ? o = this._quantizeFloor(o, this.step) : o = this._quantizeCeil(o, this.step), o = parseFloat(o.toFixed(9));
80
- const a = parseFloat((c + this.step).toFixed(9)), h = parseFloat((c - this.step).toFixed(9));
81
- (o >= a || o <= h) && (o = o.toFixed(this.decimals), this.valueInput.value = o, this.ctrlDiv.prevPosition = t.clientX, this.handle.style.transform = `translate(-50%, -50%) translateX(${n}px)`, this.handle.position = n, this.filling.style.width = this.handle.position + "px", this._triggerCallbacks());
82
- }
83
- _updateHandlePositionFromValue() {
84
- const t = this.ctrlDiv.offsetWidth, e = this.handle.offsetWidth;
85
- let r = this._mapLinear(
86
- this.valueInput.value,
87
- this.min,
88
- this.max,
89
- e / 2,
90
- t - e / 2
91
- );
92
- r = Math.max(
93
- e / 2,
94
- Math.min(r, t - e / 2)
95
- ), this.handle.style.transform = `translate(-50%, -50%) translateX(${r}px)`, this.handle.position = r, this.filling.style.width = this.handle.position + "px";
96
- }
97
- _triggerCallbacks() {
98
- this.isObject ? this.obj[this.prop] = parseFloat(this.valueInput.value) : this.callback && this.callback(parseFloat(this.valueInput.value)), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
99
- }
100
- _mapLinear(t, e, r, d, i) {
101
- return d + (t - e) * (i - d) / (r - e);
102
- }
103
- _quantize(t, e) {
104
- return e * Math.round(t / e);
105
- }
106
- _quantizeCeil(t, e) {
107
- return e * Math.ceil(t / e);
108
- }
109
- _quantizeFloor(t, e) {
110
- return e * Math.floor(t / e);
111
- }
112
- onChange(t) {
113
- return this.callback = t, this;
114
- }
115
- }
116
- class z {
117
- constructor(t, e = {}) {
118
- if (this.parent = t, this.callback = null, typeof e != "object")
119
- throw Error(
120
- `[GUI] image() first parameter must be an object. Received: ${typeof e}.`
121
- );
122
- let r;
123
- if (typeof e.path == "string")
124
- r = e.path;
125
- else
126
- throw typeof e.path == null ? Error("[GUI] image() path must be provided.") : Error("[GUI] image() path must be a string.");
127
- let d = r.replace(/^.*[\\\/]/, ""), i;
128
- e.label == null ? i = d : i = typeof e.label == "string" && e.label || " ";
129
- const l = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? i : null, c = e.selected === !0, n = e.selectionBorder !== !1;
130
- let o = "";
131
- e.width && (typeof e.width == "number" && (e.width += "px"), o += `flex: 0 0 calc(${e.width} - 5px); `), e.height && (typeof e.height == "number" && (e.height += "px"), o += `height: ${e.height}; `);
132
- const a = document.createElement("div");
133
- a.className = "p-gui__image", a.style = "background-image: url(" + r + "); " + o, l && a.setAttribute("title", l), this.parent.imageContainer.append(a), this.element = a, c && n && a.classList.add("p-gui__image--selected");
134
- const h = document.createElement("div");
135
- h.className = "p-gui__image-text", h.textContent = i, a.append(h), a.addEventListener("click", () => {
136
- let p = a.parentElement.querySelectorAll(
137
- ".p-gui__image--selected"
138
- );
139
- for (let s = 0; s < p.length; s++)
140
- p[s].classList.remove("p-gui__image--selected");
141
- n && a.classList.add("p-gui__image--selected"), typeof this.callback == "function" && this.callback({ path: r, text: i }), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
142
- });
143
- }
144
- onClick(t) {
145
- return this.callback = t, this;
146
- }
147
- }
148
- class B {
149
- constructor(t, e, r, d) {
150
- this.parent = t, this.callback = null;
151
- let i = {}, l = null, c = !1, n, o;
152
- if (e && typeof e == "object" && typeof r == "string")
153
- n = e, o = r, c = !0, i = d || {};
154
- else if (e && typeof e == "object")
155
- c = !1, i = e, l = typeof i.value == "boolean" ? i.value : null;
156
- else
157
- throw Error("[GUI] toggle() invalid parameters.");
158
- let a = typeof i.label == "string" && i.label || " ", h = null;
159
- c && a == " " && (a = o), c && (h = this.parent.propReferences.push(n[o]) - 1);
160
- const p = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? a : null, s = document.createElement("div");
161
- s.textContent = a, s.className = "p-gui__toggle", p && s.setAttribute("title", p), this.parent.wrapper.append(s), this.element = s, s.addEventListener("click", (g) => {
162
- const u = g.target.childNodes[1];
163
- let m = !0;
164
- u.classList.contains("p-gui__toggle-checkbox--active") && (m = !1), u.classList.toggle("p-gui__toggle-checkbox--active"), c ? n[o] = m : typeof this.callback == "function" && this.callback(m), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
165
- });
166
- let f = c ? n[o] ? " p-gui__toggle-checkbox--active" : "" : l ? " p-gui__toggle-checkbox--active" : "";
167
- const b = document.createElement("div");
168
- b.className = "p-gui__toggle-checkbox" + f, s.append(b), c && Object.defineProperty(n, o, {
169
- set: (g) => {
170
- this.parent.propReferences[h] = g, g ? b.classList.add(
171
- "p-gui__toggle-checkbox--active"
172
- ) : b.classList.remove(
173
- "p-gui__toggle-checkbox--active"
174
- ), typeof this.callback == "function" && this.callback(g);
175
- },
176
- get: () => this.parent.propReferences[h]
177
- });
178
- }
179
- onChange(t) {
180
- return this.callback = t, this;
181
- }
182
- }
183
- class T {
184
- constructor(t, e, r, d) {
185
- this.parent = t, this.callback = null;
186
- let i = {}, l = null, c = !1, n, o;
187
- if (e && typeof e == "object" && typeof r == "string")
188
- n = e, o = r, c = !0, i = d || {};
189
- else if (e && typeof e == "object")
190
- c = !1, i = e;
191
- else
192
- throw Error("[GUI] list() invalid parameters.");
193
- let a = typeof i.label == "string" ? i.label : " ", h = null, p = Array.isArray(i.values) ? i.values : null, s = p && p.length > 0 && typeof p[0] == "object";
194
- const f = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? a : null;
195
- c ? (l = (() => {
196
- if (!p)
197
- return null;
198
- if (typeof n[o] == "string")
199
- return s ? p.find((u) => u.value === n[o]).value : p.indexOf(n[o]);
200
- if (typeof n[o] == "number")
201
- return s ? p.find((u) => u.value === n[o]).value : n[o];
202
- })(), h = this.parent.propReferences.push(n[o]) - 1) : l = (() => {
203
- if (!p)
204
- return null;
205
- if (typeof i.value == "string")
206
- return p.indexOf(i.value);
207
- if (typeof i.value == "number")
208
- return i.value;
209
- })();
210
- let b = document.createElement("div");
211
- b.className = "p-gui__list", b.textContent = a, f && b.setAttribute("title", f), this.parent.wrapper.append(b), this.element = b;
212
- let g = document.createElement("select");
213
- b.append(g), g.className = "p-gui__list-dropdown", g.addEventListener("change", (u) => {
214
- c ? n[o] = u.target.value : this.callback && this.callback(u.target.value), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
215
- }), p && p.forEach((u, m) => {
216
- const x = s ? u.label : u, w = s ? u.value : u;
217
- let y = document.createElement("option");
218
- y.setAttribute("value", w), y.textContent = x, g.append(y), (!s && l == m || s && l == w) && y.setAttribute("selected", "");
219
- }), c && Object.defineProperty(n, o, {
220
- set: (u) => {
221
- let m, x, w;
222
- s ? (w = p.find((U) => U.value == u), x = w?.value || p[0].value, m = p.indexOf(w)) : (typeof u == "string" && (m = p.indexOf(u), x = u), typeof u == "number" && (m = u, x = p[u])), this.parent.propReferences[h] = s ? x : u;
223
- const y = g.querySelector("[selected]");
224
- y && y.removeAttribute("selected"), g.querySelectorAll("option")[m].setAttribute("selected", ""), typeof this.callback == "function" && (s ? this.callback(w, m) : this.callback(x, m));
225
- },
226
- get: () => this.parent.propReferences[h]
227
- });
228
- }
229
- onChange(t) {
230
- return this.callback = t, this;
231
- }
232
- }
233
- class V {
234
- constructor(t, e, r, d) {
235
- this.parent = t, this.callback = null;
236
- let i = {}, l = null, c = !1, n, o;
237
- if (e && typeof e == "object" && typeof r == "string")
238
- n = e, o = r, c = !0, i = d || {};
239
- else if (e && typeof e == "object")
240
- c = !1, i = e;
241
- else
242
- throw Error("[GUI] color() invalid parameters.");
243
- let a = typeof i.label == "string" && i.label || " ", h = null;
244
- const p = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? a : null;
245
- c ? (a == " " && (a = o), h = this.parent.propReferences.push(n[o]) - 1, l = n[o] || "#000000") : (typeof i.value == "string" && (i.value.length != 7 || i.value[0] != "#" ? console.error(
246
- `[GUI] color() 'value' parameter must be an hexadecimal string in the format "#ffffff". Received: "${i.value}".`
247
- ) : l = i.value), l || (l = "#000000"));
248
- const s = document.createElement("div");
249
- s.className = "p-gui__color", s.textContent = a, p && s.setAttribute("title", p), this.parent.wrapper.append(s), this.element = s;
250
- const f = document.createElement("input");
251
- f.className = "p-gui__color-picker", f.setAttribute("type", "color"), f.value = l, s.append(f), f.addEventListener("input", () => {
252
- c ? n[o] = f.value : typeof this.callback == "function" && this.callback(f.value), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
253
- }), c && Object.defineProperty(n, o, {
254
- set: (b) => {
255
- this.parent.propReferences[h] = b, f.value = b, typeof this.callback == "function" && this.callback(b);
256
- },
257
- get: () => this.parent.propReferences[h]
258
- });
259
- }
260
- onChange(t) {
261
- return this.callback = t, this;
262
- }
263
- }
264
- class G {
265
- constructor(t, e, r, d, i) {
266
- this.parent = t, this.callback = null;
267
- let l = {}, c, n, o, a;
268
- if (e && typeof e == "object" && typeof r == "string" && typeof d == "string")
269
- c = e, n = e, o = r, a = d, l = i || {};
270
- else if (e && typeof e == "object" && e.x && e.x.obj)
271
- l = e, c = l.x.obj, o = l.x.prop, n = l.y.obj, a = l.y.prop;
272
- else
273
- throw Error(
274
- "[GUI] vector2() invalid parameters. Use: gui.vector2(obj, 'propX', 'propY', params)"
275
- );
276
- let h = typeof l.label == "string" && l.label || " ";
277
- h === " " && (h = o + " / " + a);
278
- const p = l.x || {}, s = l.y || {}, f = p.min ?? l.min ?? 0, b = p.max ?? l.max ?? 1, g = s.min ?? l.min ?? 0, u = s.max ?? l.max ?? 1, m = p.step || l.step || (b - f) / 100, x = s.step || l.step || (u - g) / 100, w = this.parent._countDecimals(m), y = this.parent._countDecimals(x), U = this.parent.propReferences.push(c[o]) - 1, L = this.parent.propReferences.push(n[a]) - 1, D = typeof l.tooltip == "string" ? l.tooltip : l.tooltip === !0 ? h : null, A = document.createElement("div");
279
- A.className = "p-gui__vector2", A.textContent = h, D && A.setAttribute("title", D), this.parent.wrapper.append(A);
280
- const E = document.createElement("div");
281
- E.className = "p-gui__vector-value", E.textContent = c[o] + ", " + n[a], A.append(E);
282
- const _ = document.createElement("div");
283
- _.className = "p-gui__vector2-area", A.append(_), _.addEventListener("click", (v) => {
284
- const j = parseFloat(
285
- this.parent._mapLinear(
286
- v.offsetX,
287
- 0,
288
- _.clientWidth,
289
- f,
290
- b
291
- )
292
- ), R = parseFloat(
293
- this.parent._mapLinear(
294
- v.offsetY,
295
- 0,
296
- _.clientHeight,
297
- u,
298
- g
299
- )
300
- );
301
- c[o] = j.toFixed(w), n[a] = R.toFixed(y), this.callback && this.callback(c[o], c[a]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
302
- });
303
- const O = (v) => {
304
- const j = _.getBoundingClientRect(), R = v.clientX - j.left, H = v.clientY - j.top, M = this.parent._mapLinear(
305
- R,
306
- 0,
307
- _.clientWidth,
308
- f,
309
- b
310
- ), X = this.parent._mapLinear(
311
- H,
312
- 0,
313
- _.clientHeight,
314
- u,
315
- g
316
- ), $ = Math.max(f, Math.min(b, M)), W = Math.max(g, Math.min(u, X));
317
- c[o] = parseFloat($.toFixed(w)), n[a] = parseFloat(W.toFixed(y)), this.callback && this.callback(c[o], n[a]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
318
- };
319
- _.addEventListener("pointerdown", (v) => {
320
- O(v), document.addEventListener("pointermove", O), document.addEventListener(
321
- "pointerup",
322
- () => {
323
- document.removeEventListener(
324
- "pointermove",
325
- O
326
- );
327
- },
328
- { once: !0 }
329
- );
330
- });
331
- const N = document.createElement("div");
332
- N.className = "p-gui__vector2-line p-gui__vector2-line-x", _.append(N);
333
- const F = document.createElement("div");
334
- F.className = "p-gui__vector2-line p-gui__vector2-line-y", _.append(F);
335
- const I = document.createElement("div");
336
- I.className = "p-gui__vector2-dot", _.append(I);
337
- const P = () => {
338
- I.style.left = this.parent._mapLinear(
339
- c[o],
340
- f,
341
- b,
342
- 0,
343
- _.clientWidth
344
- ) + "px", I.style.top = this.parent._mapLinear(
345
- n[a],
346
- g,
347
- u,
348
- _.clientHeight,
349
- 0
350
- ) + "px";
351
- };
352
- P(), new ResizeObserver(() => {
353
- P();
354
- }).observe(_), Object.defineProperty(c, o, {
355
- set: (v) => {
356
- this.parent.propReferences[U] = v, P(), E.textContent = String(v) + ", " + n[a];
357
- },
358
- get: () => this.parent.propReferences[U]
359
- }), Object.defineProperty(n, a, {
360
- set: (v) => {
361
- this.parent.propReferences[L] = v, P(), E.textContent = c[o] + ", " + String(v);
362
- },
363
- get: () => this.parent.propReferences[L]
364
- });
365
- }
366
- onChange(t) {
367
- return this.callback = t, this;
368
- }
369
- }
370
- const Q = ".p-gui__button{background:var(--color-accent);text-align:center;color:var(--color-bg);border:1px solid transparent;box-sizing:border-box;transition:var(--transition) background,var(--transition) border-color}.p-gui__button:hover{background:var(--color-accent-hover);border-color:#fff3}.p-gui__folder .p-gui__button{margin-inline:0}", q = ".p-gui__slider{position:relative;min-height:14px;display:flex;align-items:center;justify-content:space-between;gap:10px;color:var(--color-text-dark);transition:color var(--transition);padding:3px;touch-action:none}.p-gui__slider:hover{color:var(--color-text-light)}.p-gui__slider-name{width:50%;text-overflow:ellipsis;overflow:hidden}.p-gui__slider-ctrl{-webkit-appearance:none;padding:0;font:inherit;outline:none;box-sizing:border-box;cursor:pointer;position:relative;right:0;height:14px;margin:0 0 0 auto;width:37%;touch-action:none}.p-gui__slider-bar{position:absolute;top:50%;left:0;height:2px;background:#fff3;width:100%;transform:translateY(-50%)}.p-gui__slider-filling{position:absolute;top:-25%;left:0;height:100%;background:var(--color-accent);width:0;pointer-events:none}.p-gui__slider:hover .p-gui__slider-filling{background:var(--color-accent-hover)}.p-gui__slider-handle{width:9px;height:9px;position:absolute;top:50%;left:0;border-radius:2px;transform:translate(-50%,-50%);pointer-events:none;background:var(--color-text-dark);box-shadow:0 0 2px #00000080}.p-gui__slider:hover .p-gui__slider-handle{background:var(--color-text-light)}.p-gui__slider-value{display:inline-block;right:7px;width:13%;border:none;color:#fff;border-radius:2px;background:#ffffff1a;padding:2px 4px;color:inherit}.p-gui__slider-value:focus{outline:none}", J = ".p-gui__list{cursor:default;color:var(--color-text-dark);transition:var(--transition) color}.p-gui__list:hover{color:var(--color-text-light)}.p-gui__list-dropdown{background:#ffffff0d;color:#fff;padding:0 12px 0 5px;top:0}.p-gui__list-dropdown{position:absolute;right:5px;top:0;bottom:0;margin:auto;height:calc(100% - 4px);cursor:pointer;border-radius:3px;border:1px solid var(--color-border-2);outline:none}.p-gui__list-dropdown option{background:#fff;color:#000}.p-gui__list-dropdown:hover{background:#ffffff1a}", Z = ".p-gui__toggle{color:var(--color-text-dark);transition:var(--transition) background,var(--transition) color}.p-gui__toggle:hover{background:#ffffff1a;color:var(--color-text-light)}.p-gui__folder .p-gui__toggle{margin-inline:0}.p-gui__toggle-checkbox{width:10px;height:10px;background-color:#ffffff1a;position:absolute;top:0;right:10px;bottom:0;margin:auto;border-radius:2px;pointer-events:none;transition:.5s all ease}.p-gui__toggle-checkbox--active{background-color:#ddd;box-shadow:0 0 5px #ddd}", K = ".p-gui__color{cursor:default;color:var(--color-text-dark);transition:var(--transition) color}.p-gui__color:hover{color:var(--color-text-light)}.p-gui__color-picker{position:absolute;right:5px;top:0;bottom:0;margin:auto;height:calc(100% - 4px);cursor:pointer;border-radius:3px;border:1px solid var(--color-border-2);outline:none;-webkit-appearance:none;padding:0;background-color:transparent;border:1px solid #222222;overflow:hidden}.p-gui__color-picker::-webkit-color-swatch-wrapper{padding:0}.p-gui__color-picker::-webkit-color-swatch{border:none}", ee = ".p-gui__vector2{background:transparent;aspect-ratio:1;padding-bottom:0;color:var(--color-text-dark)}.p-gui__vector2:hover{color:var(--color-text-light)}.p-gui__vector2-area{position:relative;background:#0000004d;margin-top:8px;width:100%;height:calc(100% - 28px);touch-action:none}.p-gui__vector2-line{position:absolute;background:#fff;opacity:.3;pointer-events:none}.p-gui__vector2-line-x{width:100%;height:1px;left:0;top:50%;transform:translateY(-50%)}.p-gui__vector2-line-y{width:1px;height:100%;top:0;left:50%;transform:translate(-50%)}.p-gui__vector2-dot{position:absolute;top:0;left:0;width:8px;height:8px;border-radius:50%;background:#d5d5d5;border:2px solid #ff9999;transform:translate(-50%,-50%);pointer-events:none}.p-gui__vector-value{display:inline-block;right:7px;position:absolute}", te = '.p-gui__image-container{width:100%;padding:3px;display:flex;justify-content:flex-start;flex-wrap:wrap;box-sizing:border-box}.p-gui__image{background-size:cover;cursor:pointer;position:relative;margin:1px 2.5px 19px;border-radius:var(--main-border-radius);flex:0 0 calc(33.333% - 5px);height:90px;background-position:center;color:var(--color-text-dark);transition:var(--transition) color}.p-gui__image:hover{color:var(--color-text-light)}.p-gui__image:after{position:absolute;top:0;left:0;width:100%;height:100%;content:"";border:1px solid transparent;box-sizing:border-box;border-radius:var(--main-border-radius);transition:var(--transition) border-color}.p-gui__image--selected:after{border-color:#06ff89}.p-gui__image-text{position:absolute;bottom:-15px;text-shadow:0 -1px 0 #111;white-space:nowrap;width:100%;overflow:hidden;text-overflow:ellipsis}', ie = ".p-gui__folder{width:100%;position:relative;background:var(--color-bg);margin-bottom:2px;display:flex;flex-wrap:wrap;border:1px solid var(--color-border-2);border-radius:var(--main-border-radius);box-sizing:border-box;border-left:1px solid #bbbbbb}.p-gui__folder--first{margin-top:0}.p-gui__folder-content{display:grid;grid-template-rows:1fr;transition:.25s grid-template-rows ease;width:100%}.p-gui__folder-inner{overflow:hidden;padding-left:3px;padding-right:2px}.p-gui__folder--closed .p-gui__folder-content{grid-template-rows:0fr}.p-gui__folder-header{padding:5px 3px;background-color:#00000080;color:#fff;cursor:pointer;width:100%;box-sizing:border-box;border-top-right-radius:var(--main-border-radius);border-bottom-right-radius:var(--main-border-radius)}.p-gui__folder-header:hover{background-color:#000000bf}.p-gui__folder-arrow{width:8px;height:8px;display:inline-block;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAHlBMVEUAAAD///////////////////////////////////8kfJuVAAAACXRSTlMA9Z1fCdMo1yxEJnA0AAAAK0lEQVQI12PABlRgjKkJUMZMYRhjpgqMAZSEMICSaIzpDWiKhdENhEhgAgATSg5jyWnYewAAAABJRU5ErkJggg==);background-size:contain;margin-right:5px;transform:rotate(90deg)}.p-gui__folder--closed .p-gui__folder-arrow{transform:rotate(0)}", re = ".p-gui__tabs{width:100%;position:relative;background:var(--color-bg);margin-bottom:2px;border:1px solid var(--color-border-2);border-radius:var(--main-border-radius);box-sizing:border-box;border-left:1px solid #bbbbbb;padding-block:0}.p-gui__tabs--first{margin-top:0}.p-gui__tabs-header{display:flex;background-color:#00000080;border-top-left-radius:var(--main-border-radius);border-top-right-radius:var(--main-border-radius)}.p-gui__tab-button{padding:7px 10px;background:transparent;color:#bbb;cursor:pointer;border:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;font-family:inherit}.p-gui__tab-button:last-child{border-right:none}.p-gui__tab-button:hover{color:#fff}.p-gui__tab-button--active{background-color:var(--color-bg);color:#fff;border-bottom:1px solid transparent}.p-gui__tabs-content{position:relative;width:100%}.p-gui__tab-pane{display:none;width:100%;padding-top:4px;box-sizing:border-box}.p-gui__tab-pane--active{display:block}";
371
- function oe(k) {
372
- return `
1
+ //#region src/components/Button.ts
2
+ var e = class {
3
+ constructor(e, t = {}) {
4
+ if (this.callback = null, this.parent = e, typeof t != "object") throw Error(`[GUI] button() first parameter must be an object. Received: ${typeof t}.`);
5
+ let n = t.label || "\xA0", r = typeof t.tooltip == "string" ? t.tooltip : t.tooltip === !0 ? n : null, i = document.createElement("div");
6
+ i.className = "p-gui__button", i.textContent = n, r && i.setAttribute("title", r), i.addEventListener("click", () => {
7
+ this.callback && this.callback(), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
8
+ }), typeof t.color == "string" && (i.style.setProperty("--color-accent", t.color), i.style.setProperty("--color-accent-hover", t.hoverColor || t.color)), this.parent.wrapper.append(i), this.element = i;
9
+ }
10
+ onClick(e) {
11
+ return this.callback = e, this;
12
+ }
13
+ }, t = class {
14
+ constructor(e, t, n, r = {}) {
15
+ if (this.callback = null, this.parent = e, this.propReferences = [], t && typeof t == "object" && typeof n == "string") this.obj = t, this.prop = n;
16
+ else throw Error("[GUI] slider() invalid parameters.");
17
+ let i = typeof r.label == "string" && r.label || "\xA0";
18
+ i == "\xA0" && (i = this.prop), this.min = r.min ?? 0, this.max = r.max ?? 1, this.step = r.step || (this.max - this.min) / 100, this.decimals = this.parent._countDecimals(this.step);
19
+ let a = this.propReferences.push(this.obj[this.prop]) - 1, o = typeof r.tooltip == "string" ? r.tooltip : r.tooltip === !0 ? i : null, s = document.createElement("div");
20
+ s.className = "p-gui__slider", o && s.setAttribute("title", o), this.parent.wrapper.append(s), this.element = s;
21
+ let c = document.createElement("div");
22
+ c.className = "p-gui__slider-name", c.textContent = i, s.append(c), this.ctrlDiv = document.createElement("div"), this.ctrlDiv.prevPosition = 0, this.ctrlDiv.className = "p-gui__slider-ctrl", this.ctrlDiv.setAttribute("type", "range"), this.ctrlDiv.setAttribute("min", String(this.min)), this.ctrlDiv.setAttribute("max", String(this.max)), s.append(this.ctrlDiv);
23
+ let l = document.createElement("div");
24
+ l.className = "p-gui__slider-bar", this.ctrlDiv.append(l), this.handle = document.createElement("div"), this.handle.className = "p-gui__slider-handle", this.ctrlDiv.append(this.handle), this.filling = document.createElement("div"), this.filling.className = "p-gui__slider-filling", l.append(this.filling), this.valueInput = document.createElement("input"), this.valueInput.className = "p-gui__slider-value", this.valueInput.value = this.obj[this.prop], s.append(this.valueInput), setTimeout(() => {
25
+ let e = this.ctrlDiv.offsetWidth, t = this.handle.offsetWidth;
26
+ this.handle.position = this.parent._mapLinear(parseFloat(this.valueInput.value), this.min, this.max, t / 2, e - t / 2), this.handle.position = Math.min(this.handle.position, e - t / 2), this.handle.position = Math.max(this.handle.position, t / 2), this.handle.style.transform = `translate(-50%, -50%) translateX(${this.handle.position}px)`, this.filling.style.width = `${this.handle.position}px`;
27
+ }, 0), this.valueInput.addEventListener("change", () => {
28
+ this._updateHandlePositionFromValue(), this._triggerCallbacks();
29
+ }), this.ctrlDiv.addEventListener("pointerdown", (e) => {
30
+ this.ctrlDiv.pointerDown = !0, this.ctrlDiv.prevPosition = e.clientX, this._updateHandlePositionFromPointer(e, !0);
31
+ }), window.addEventListener("pointerup", (e) => {
32
+ this.ctrlDiv.pointerDown = !1;
33
+ }), window.addEventListener("pointercancel", (e) => {
34
+ this.ctrlDiv.pointerDown = !1;
35
+ }), window.addEventListener("pointermove", (e) => {
36
+ this.ctrlDiv.pointerDown && (this.ctrlDiv.pointerDelta = e.clientX - (this.ctrlDiv.prevPosition ?? 0), this._updateHandlePositionFromPointer(e));
37
+ }), Object.defineProperty(this.obj, this.prop, {
38
+ set: (e) => {
39
+ this.propReferences[a] = e, this.valueInput.value = e, this._updateHandlePositionFromValue(), this.callback && this.callback(parseFloat(this.valueInput.value));
40
+ },
41
+ get: () => this.propReferences[a]
42
+ });
43
+ }
44
+ _updateHandlePositionFromPointer(e, t = !1) {
45
+ let n = this.ctrlDiv.getBoundingClientRect(), r = n.width, i = this.handle.offsetWidth, a = e.clientX - (this.ctrlDiv.prevPosition ?? 0), o = parseFloat(this.valueInput.value), s;
46
+ s = t ? e.clientX - n.left : (this.handle.position ?? 0) + a, s = Math.max(i / 2, Math.min(s, r - i / 2));
47
+ let c = this.min + (this.max - this.min) * (s - i / 2) / (r - i);
48
+ c = c > o ? this._quantizeFloor(c, this.step) : this._quantizeCeil(c, this.step), c = parseFloat(c.toFixed(9));
49
+ let l = parseFloat((o + this.step).toFixed(9)), u = parseFloat((o - this.step).toFixed(9));
50
+ (c >= l || c <= u) && (c = parseFloat(c.toFixed(this.decimals)), this.valueInput.value = String(c), this.ctrlDiv.prevPosition = e.clientX, this.handle.style.transform = `translate(-50%, -50%) translateX(${s}px)`, this.handle.position = s, this.filling.style.width = this.handle.position + "px", this._triggerCallbacks());
51
+ }
52
+ _updateHandlePositionFromValue() {
53
+ let e = this.ctrlDiv.offsetWidth, t = this.handle.offsetWidth, n = this.parent._mapLinear(parseFloat(this.valueInput.value), this.min, this.max, t / 2, e - t / 2);
54
+ n = Math.max(t / 2, Math.min(n, e - t / 2)), this.handle.style.transform = `translate(-50%, -50%) translateX(${n}px)`, this.handle.position = n, this.filling.style.width = this.handle.position + "px";
55
+ }
56
+ _triggerCallbacks() {
57
+ this.obj[this.prop] = parseFloat(this.valueInput.value), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
58
+ }
59
+ _quantize(e, t) {
60
+ return t * Math.round(e / t);
61
+ }
62
+ _quantizeCeil(e, t) {
63
+ return t * Math.ceil(e / t);
64
+ }
65
+ _quantizeFloor(e, t) {
66
+ return t * Math.floor(e / t);
67
+ }
68
+ onChange(e) {
69
+ return this.callback = e, this;
70
+ }
71
+ }, n = class {
72
+ constructor(e, t, n = {}) {
73
+ if (this.callback = null, this.parent = e, t === void 0) throw Error("[GUI] image() path must be provided.");
74
+ if (typeof t != "string") throw Error("[GUI] image() path must be a string.");
75
+ if (typeof n != "object") throw Error(`[GUI] image() second parameter must be an object. Received: ${typeof n}.`);
76
+ let r = t.replace(/^.*[\\\/]/, ""), i;
77
+ i = n.label == null ? r : typeof n.label == "string" && n.label || "\xA0";
78
+ let a = typeof n.tooltip == "string" ? n.tooltip : n.tooltip === !0 ? i : null, o = n.selected === !0, s = n.selectionBorder !== !1, c = "";
79
+ if (n.width) {
80
+ let e = n.width;
81
+ typeof e == "number" && (e = `${e}px`), c += `flex: 0 0 calc(${e} - 5px); `;
82
+ }
83
+ if (n.height) {
84
+ let e = n.height;
85
+ typeof e == "number" && (e = `${e}px`), c += `height: ${e}; `;
86
+ }
87
+ let l = document.createElement("div");
88
+ l.className = "p-gui__image", l.style = "background-image: url(" + t + "); " + c, a && l.setAttribute("title", a), this.parent.imageContainer.append(l), this.element = l, o && s && l.classList.add("p-gui__image--selected");
89
+ let u = document.createElement("div");
90
+ u.className = "p-gui__image-text", u.textContent = i, l.append(u), l.addEventListener("click", () => {
91
+ let e = l.parentElement?.querySelectorAll(".p-gui__image--selected") || [];
92
+ for (let t = 0; t < e.length; t++) e[t].classList.remove("p-gui__image--selected");
93
+ s && l.classList.add("p-gui__image--selected"), typeof this.callback == "function" && this.callback({
94
+ path: t,
95
+ text: i
96
+ }), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
97
+ });
98
+ }
99
+ onClick(e) {
100
+ return this.callback = e, this;
101
+ }
102
+ }, r = class {
103
+ constructor(e, t, n, r = {}) {
104
+ if (this.parent = e, this.callback = null, !t || typeof t != "object" || typeof n != "string") throw Error("[GUI] toggle() invalid parameters.");
105
+ let i = typeof r.label == "string" && r.label !== "" ? r.label : n, a = this.parent.propReferences.push(t[n]) - 1, o = typeof r.tooltip == "string" ? r.tooltip : r.tooltip === !0 ? i : null, s = document.createElement("div");
106
+ s.textContent = i, s.className = "p-gui__toggle", o && s.setAttribute("title", o), this.parent.wrapper.append(s), this.element = s;
107
+ let c = t[n] ? " p-gui__toggle-checkbox--active" : "", l = document.createElement("div");
108
+ l.className = "p-gui__toggle-checkbox" + c, s.append(l), s.addEventListener("click", (e) => {
109
+ if (!e.target || !(e.target instanceof HTMLElement)) return;
110
+ let r = !0;
111
+ l.classList.contains("p-gui__toggle-checkbox--active") && (r = !1), l.classList.toggle("p-gui__toggle-checkbox--active"), t[n] = r, this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
112
+ }), Object.defineProperty(t, n, {
113
+ set: (e) => {
114
+ this.parent.propReferences[a] = e, e ? l.classList.add("p-gui__toggle-checkbox--active") : l.classList.remove("p-gui__toggle-checkbox--active"), typeof this.callback == "function" && this.callback(e);
115
+ },
116
+ get: () => this.parent.propReferences[a]
117
+ });
118
+ }
119
+ onChange(e) {
120
+ return this.callback = e, this;
121
+ }
122
+ }, i = class {
123
+ constructor(e, t, n, r, i = {}) {
124
+ if (this.parent = e, this.callback = null, !t || typeof t != "object" || typeof n != "string") throw Error("[GUI] list() invalid parameters.");
125
+ let a = typeof i.label == "string" ? i.label : n, o = Array.isArray(r) ? r : null;
126
+ if (!o) throw Error("[GUI] list() Third argument must be an array.");
127
+ let s = o && o.length > 0 && typeof o[0] == "object", c = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? a : null, l = (() => {
128
+ if (!o) return null;
129
+ if (typeof t[n] == "string") return s ? o.find((e) => e.value === t[n])?.value : o.indexOf(t[n]);
130
+ if (typeof t[n] == "number") return s ? o.find((e) => e.value === t[n])?.value : t[n];
131
+ })(), u = this.parent.propReferences.push(t[n]) - 1, d = document.createElement("div");
132
+ d.className = "p-gui__list", d.textContent = a, c && d.setAttribute("title", c), this.parent.wrapper.append(d), this.element = d;
133
+ let f = document.createElement("select");
134
+ d.append(f), f.className = "p-gui__list-dropdown", f.addEventListener("change", (e) => {
135
+ t[n] = e.target.value, this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
136
+ }), o && o.forEach((e, t) => {
137
+ let n = s ? e.label : e, r = s ? e.value : e, i = document.createElement("option");
138
+ i.setAttribute("value", String(r)), i.textContent = String(n), f.append(i), (!s && l == t || s && l == r) && i.setAttribute("selected", "");
139
+ }), Object.defineProperty(t, n, {
140
+ set: (e) => {
141
+ let t, n, r;
142
+ if (s) {
143
+ if (r = o?.find((t) => t.value == e), !r) {
144
+ console.error(`[GUI] list() value ${e} not found in values`);
145
+ return;
146
+ }
147
+ n = r?.value || o[0].value, t = o.indexOf(r);
148
+ } else typeof e == "string" && (t = o.indexOf(e), n = e), typeof e == "number" && (t = e, n = o[e]);
149
+ if (t === void 0 || n === void 0) {
150
+ console.error("[GUI] list() newIndex or newValue is undefined");
151
+ return;
152
+ }
153
+ this.parent.propReferences[u] = s ? n : e;
154
+ let i = f.querySelector("[selected]");
155
+ i && i.removeAttribute("selected"), f.querySelectorAll("option")[t].setAttribute("selected", ""), typeof this.callback == "function" && (s && r ? this.callback(r, t) : this.callback(n, t));
156
+ },
157
+ get: () => this.parent.propReferences[u]
158
+ });
159
+ }
160
+ onChange(e) {
161
+ return this.callback = e, this;
162
+ }
163
+ }, a = class {
164
+ constructor(e, t, n, r = {}) {
165
+ if (this.callback = null, this.parent = e, typeof t != "object" || typeof n != "string") throw Error("[GUI] color() invalid parameters. Expected (object, string, options).");
166
+ let i = typeof r.label == "string" && r.label || "\xA0";
167
+ i === "\xA0" && (i = n);
168
+ let a = typeof r.tooltip == "string" ? r.tooltip : r.tooltip === !0 ? i : null, o = this.parent.propReferences.push(t[n]) - 1, s = t[n] || "#000000", c = document.createElement("div");
169
+ c.className = "p-gui__color", c.textContent = i, a && c.setAttribute("title", a), this.parent.wrapper.append(c), this.element = c;
170
+ let l = document.createElement("input");
171
+ l.className = "p-gui__color-picker", l.setAttribute("type", "color"), l.value = s, c.append(l), l.addEventListener("input", () => {
172
+ t[n] = l.value, this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
173
+ }), Object.defineProperty(t, n, {
174
+ set: (e) => {
175
+ this.parent.propReferences[o] = e, l.value = e, typeof this.callback == "function" && this.callback(e);
176
+ },
177
+ get: () => this.parent.propReferences[o]
178
+ });
179
+ }
180
+ onChange(e) {
181
+ return this.callback = e, this;
182
+ }
183
+ }, o = class {
184
+ constructor(e, t, n, r, i = {}) {
185
+ this.parent = e, this.callback = null;
186
+ let a, o;
187
+ if (t && typeof t == "object" && typeof n == "string" && typeof r == "string") a = t, o = t, n = n, r = r;
188
+ else throw Error("[GUI] vector2() invalid parameters. Use: gui.vector2(obj, 'propX', 'propY', options)");
189
+ let s = typeof i.label == "string" && i.label || "\xA0";
190
+ s === "\xA0" && (s = n + " / " + r);
191
+ let c = i.x || {}, l = i.y || {}, u = c.min ?? i.min ?? 0, d = c.max ?? i.max ?? 1, f = l.min ?? i.min ?? 0, p = l.max ?? i.max ?? 1, m = c.step || i.step || (d - u) / 100, h = l.step || i.step || (p - f) / 100, g = this.parent._countDecimals(m), _ = this.parent._countDecimals(h), v = this.parent.propReferences.push(a[n]) - 1, y = this.parent.propReferences.push(o[r]) - 1, b = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? s : null, x = document.createElement("div");
192
+ x.className = "p-gui__vector2", x.textContent = s, b && x.setAttribute("title", b), this.parent.wrapper.append(x);
193
+ let S = document.createElement("div");
194
+ S.className = "p-gui__vector-value", S.textContent = a[n] + ", " + o[r], x.append(S);
195
+ let C = document.createElement("div");
196
+ C.className = "p-gui__vector2-area", x.append(C), C.addEventListener("click", (e) => {
197
+ let t = parseFloat(this.parent._mapLinear(e.offsetX, 0, C.clientWidth, u, d)), i = parseFloat(this.parent._mapLinear(e.offsetY, 0, C.clientHeight, p, f));
198
+ a[n] = t.toFixed(g), o[r] = i.toFixed(_), this.callback && this.callback(a[n], a[r]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
199
+ });
200
+ let w = (e) => {
201
+ let t = C.getBoundingClientRect(), i = e.clientX - t.left, s = e.clientY - t.top, c = this.parent._mapLinear(i, 0, C.clientWidth, u, d), l = this.parent._mapLinear(s, 0, C.clientHeight, p, f), m = Math.max(u, Math.min(d, c)), h = Math.max(f, Math.min(p, l));
202
+ a[n] = parseFloat(m.toFixed(g)), o[r] = parseFloat(h.toFixed(_)), this.callback && this.callback(a[n], o[r]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
203
+ };
204
+ C.addEventListener("pointerdown", (e) => {
205
+ w(e), document.addEventListener("pointermove", w), document.addEventListener("pointerup", () => {
206
+ document.removeEventListener("pointermove", w);
207
+ }, { once: !0 });
208
+ });
209
+ let T = document.createElement("div");
210
+ T.className = "p-gui__vector2-line p-gui__vector2-line-x", C.append(T);
211
+ let E = document.createElement("div");
212
+ E.className = "p-gui__vector2-line p-gui__vector2-line-y", C.append(E);
213
+ let D = document.createElement("div");
214
+ D.className = "p-gui__vector2-dot", C.append(D);
215
+ let O = () => {
216
+ D.style.left = this.parent._mapLinear(a[n], u, d, 0, C.clientWidth) + "px", D.style.top = this.parent._mapLinear(o[r], f, p, C.clientHeight, 0) + "px";
217
+ };
218
+ O(), new ResizeObserver(() => {
219
+ O();
220
+ }).observe(C), Object.defineProperty(a, n, {
221
+ set: (e) => {
222
+ this.parent.propReferences[v] = e, O(), S.textContent = String(e) + ", " + o[r];
223
+ },
224
+ get: () => this.parent.propReferences[v]
225
+ }), Object.defineProperty(o, r, {
226
+ set: (e) => {
227
+ this.parent.propReferences[y] = e, O(), S.textContent = a[n] + ", " + String(e);
228
+ },
229
+ get: () => this.parent.propReferences[y]
230
+ });
231
+ }
232
+ onChange(e) {
233
+ return this.callback = e, this;
234
+ }
235
+ }, s = ".p-gui__button{background:var(--color-accent);text-align:center;color:var(--color-bg);box-sizing:border-box;transition:var(--transition) background, var(--transition) border-color;border:1px solid #0000}.p-gui__button:hover{background:var(--color-accent-hover);border-color:#fff3}.p-gui__folder .p-gui__button{margin-inline:0}", c = ".p-gui__slider{min-height:14px;color:var(--color-text-dark);transition:color var(--transition);touch-action:none;justify-content:space-between;align-items:center;gap:10px;padding:3px;display:flex;position:relative}.p-gui__slider:hover{color:var(--color-text-light)}.p-gui__slider-name{text-overflow:ellipsis;width:50%;overflow:hidden}.p-gui__slider-ctrl{-webkit-appearance:none;font:inherit;box-sizing:border-box;cursor:pointer;touch-action:none;outline:none;width:37%;height:14px;margin:0 0 0 auto;padding:0;position:relative;right:0}.p-gui__slider-bar{background:#fff3;width:100%;height:2px;position:absolute;top:50%;left:0;transform:translateY(-50%)}.p-gui__slider-filling{background:var(--color-accent);pointer-events:none;width:0;height:100%;position:absolute;top:-25%;left:0}.p-gui__slider:hover .p-gui__slider-filling{background:var(--color-accent-hover)}.p-gui__slider-handle{pointer-events:none;background:var(--color-text-dark);border-radius:2px;width:9px;height:9px;position:absolute;top:50%;left:0;transform:translate(-50%,-50%);box-shadow:0 0 2px #00000080}.p-gui__slider:hover .p-gui__slider-handle{background:var(--color-text-light)}.p-gui__slider-value{color:inherit;width:13%;background:#ffffff1a;border:none;border-radius:2px;padding:2px 4px;display:inline-block;right:7px}.p-gui__slider-value:focus{outline:none}", l = ".p-gui__list{cursor:default;color:var(--color-text-dark);transition:var(--transition) color}.p-gui__list:hover{color:var(--color-text-light)}.p-gui__list-dropdown{color:#fff;background:#ffffff0d;padding:0 12px 0 5px;top:0}.p-gui__list-dropdown{cursor:pointer;border:1px solid var(--color-border-2);border-radius:3px;outline:none;height:calc(100% - 4px);margin:auto;position:absolute;top:0;bottom:0;right:5px}.p-gui__list-dropdown option{color:#000;background:#fff}.p-gui__list-dropdown:hover{background:#ffffff1a}", u = ".p-gui__toggle{color:var(--color-text-dark);transition:var(--transition) background, var(--transition) color}.p-gui__toggle:hover{color:var(--color-text-light);background:#ffffff1a}.p-gui__folder .p-gui__toggle{margin-inline:0}.p-gui__toggle-checkbox{pointer-events:none;background-color:#ffffff1a;border-radius:2px;width:10px;height:10px;margin:auto;transition:all .5s;position:absolute;top:0;bottom:0;right:10px}.p-gui__toggle-checkbox--active{background-color:#ddd;box-shadow:0 0 5px #ddd}", d = ".p-gui__color{cursor:default;color:var(--color-text-dark);transition:var(--transition) color}.p-gui__color:hover{color:var(--color-text-light)}.p-gui__color-picker{cursor:pointer;border:1px solid var(--color-border-2);-webkit-appearance:none;background-color:#0000;border:1px solid #222;border-radius:3px;outline:none;height:calc(100% - 4px);margin:auto;padding:0;position:absolute;top:0;bottom:0;right:5px;overflow:hidden}.p-gui__color-picker::-webkit-color-swatch-wrapper{padding:0}.p-gui__color-picker::-webkit-color-swatch{border:none}", f = ".p-gui__vector2{aspect-ratio:1;color:var(--color-text-dark);background:0 0;padding-bottom:0}.p-gui__vector2:hover{color:var(--color-text-light)}.p-gui__vector2-area{touch-action:none;background:#0000004d;width:100%;height:calc(100% - 28px);margin-top:8px;position:relative}.p-gui__vector2-line{opacity:.3;pointer-events:none;background:#fff;position:absolute}.p-gui__vector2-line-x{width:100%;height:1px;top:50%;left:0;transform:translateY(-50%)}.p-gui__vector2-line-y{width:1px;height:100%;top:0;left:50%;transform:translate(-50%)}.p-gui__vector2-dot{pointer-events:none;background:#d5d5d5;border:2px solid #f99;border-radius:50%;width:8px;height:8px;position:absolute;top:0;left:0;transform:translate(-50%,-50%)}.p-gui__vector-value{display:inline-block;position:absolute;right:7px}", p = ".p-gui__image-container{box-sizing:border-box;flex-wrap:wrap;justify-content:flex-start;width:100%;padding:3px;display:flex}.p-gui__image{cursor:pointer;border-radius:var(--main-border-radius);height:90px;color:var(--color-text-dark);transition:var(--transition) color;background-position:50%;background-size:cover;flex:0 0 calc(33.333% - 5px);margin:1px 2.5px 19px;position:relative}.p-gui__image:hover{color:var(--color-text-light)}.p-gui__image:after{content:\"\";box-sizing:border-box;border-radius:var(--main-border-radius);width:100%;height:100%;transition:var(--transition) border-color;border:1px solid #0000;position:absolute;top:0;left:0}.p-gui__image--selected:after{border-color:#06ff89}.p-gui__image-text{text-shadow:0 -1px #111;white-space:nowrap;text-overflow:ellipsis;width:100%;position:absolute;bottom:-15px;overflow:hidden}", m = ".p-gui__folder{background:var(--color-bg);border:1px solid var(--color-border-2);border-radius:var(--main-border-radius);box-sizing:border-box;border-left:1px solid #bbb;flex-wrap:wrap;width:100%;margin-bottom:2px;display:flex;position:relative}.p-gui__folder--first{margin-top:0}.p-gui__folder-content{grid-template-rows:1fr;width:100%;transition:grid-template-rows .25s;display:grid}.p-gui__folder-inner{padding-left:3px;padding-right:2px;overflow:hidden}.p-gui__folder--closed .p-gui__folder-content{grid-template-rows:0fr}.p-gui__folder-header{color:#fff;cursor:pointer;box-sizing:border-box;border-top-right-radius:var(--main-border-radius);border-bottom-right-radius:var(--main-border-radius);background-color:#00000080;width:100%;padding:5px 3px}.p-gui__folder-header:hover{background-color:#000000bf}.p-gui__folder-arrow{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAHlBMVEUAAAD///////////////////////////////////8kfJuVAAAACXRSTlMA9Z1fCdMo1yxEJnA0AAAAK0lEQVQI12PABlRgjKkJUMZMYRhjpgqMAZSEMICSaIzpDWiKhdENhEhgAgATSg5jyWnYewAAAABJRU5ErkJggg==);background-size:contain;width:8px;height:8px;margin-right:5px;display:inline-block;transform:rotate(90deg)}.p-gui__folder--closed .p-gui__folder-arrow{transform:rotate(0)}", h = ".p-gui__tabs{background:var(--color-bg);border:1px solid var(--color-border-2);border-radius:var(--main-border-radius);box-sizing:border-box;border-left:1px solid #bbb;width:100%;margin-bottom:2px;padding-block:0;position:relative}.p-gui__tabs--first{margin-top:0}.p-gui__tabs-header{border-top-left-radius:var(--main-border-radius);border-top-right-radius:var(--main-border-radius);background-color:#00000080;display:flex}.p-gui__tab-button{color:#bbb;cursor:pointer;white-space:nowrap;text-overflow:ellipsis;background:0 0;border:none;flex:1;padding:7px 10px;font-family:inherit;overflow:hidden}.p-gui__tab-button:last-child{border-right:none}.p-gui__tab-button:hover{color:#fff}.p-gui__tab-button--active{background-color:var(--color-bg);color:#fff;border-bottom:1px solid #0000}.p-gui__tabs-content{width:100%;position:relative}.p-gui__tab-pane{box-sizing:border-box;width:100%;padding-top:4px;display:none}.p-gui__tab-pane--active{display:block}";
236
+ //#endregion
237
+ //#region src/styles/styles.js
238
+ function g(e) {
239
+ return `
373
240
  .p-gui {
374
241
  --main-border-radius: 6px;
375
242
  --color-bg: #161616;
@@ -381,7 +248,7 @@ function oe(k) {
381
248
  --color-accent-hover: #dddddd;
382
249
  --transition: .1s linear;
383
250
 
384
- position: ${k};
251
+ position: ${e};
385
252
  top: 0;
386
253
  left: 0;
387
254
  transform: translate3d(0,0,0);
@@ -517,49 +384,70 @@ function oe(k) {
517
384
  border-color: rgba(255,255,255,.2);
518
385
  }
519
386
 
520
- ${Q}
387
+ ${s}
521
388
 
522
- ${te}
389
+ ${p}
523
390
 
524
- ${J}
391
+ ${l}
525
392
 
526
- ${Z}
393
+ ${u}
527
394
 
528
- ${q}
395
+ ${c}
529
396
 
530
- ${K}
397
+ ${d}
531
398
 
532
- ${ee}
399
+ ${f}
533
400
 
534
- ${ie}
401
+ ${m}
535
402
 
536
- ${re}
403
+ ${h}
537
404
  `;
538
405
  }
539
- class C {
540
- constructor(t = {}) {
541
- if (this.firstParent = this, t.container ? (this.container = typeof t.container == "string" ? document.querySelector(t.container) : t.container, this.position_type = "absolute") : (this.container = document.body, this.position_type = "fixed"), this.propReferences = [], this.folders = [], this.tabsArray = [], t.isFolder) {
542
- this._folderConstructor(t.folderOptions);
543
- return;
544
- }
545
- typeof t.onUpdate == "function" && (this.onUpdate = t.onUpdate), this.label = t != null && typeof t.label == "string" ? t.label : "", this.backgroundColor = t.color || null, this.opacity = t.opacity || 1, this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(
546
- this.container.clientHeight,
547
- window.innerHeight
548
- ), t.maxHeight && (this.initMaxHeight = t.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.screenCorner = this._parseScreenCorner(t.position), window.perfectGUI || (window.perfectGUI = {}), window.perfectGUI.instanceCounter == null ? window.perfectGUI.instanceCounter = 0 : window.perfectGUI.instanceCounter++, this.instanceId = window.perfectGUI.instanceCounter, this.wrapperWidth = t.width || 290, this.stylesheet = document.createElement("style"), this.stylesheet.setAttribute("type", "text/css"), this.stylesheet.setAttribute("id", "lm-gui-stylesheet"), document.head.append(this.stylesheet), this.instanceId == 0 && this._addStyles(`${oe(this.position_type)}`), this._styleInstance(), this.closed = !!t.closed, this._addWrapper(), this.domElement.setAttribute("data-corner-x", this.screenCorner.x), this.domElement.setAttribute("data-corner-y", this.screenCorner.y), t.autoRepositioning != !1 && window.addEventListener("resize", this._handleResize.bind(this)), this._handleResize(), this.hasBeenDragged = !1, t.draggable == !0 && this._makeDraggable();
549
- }
550
- _styleInstance() {
551
- let t = this._getScrollbarWidth(this.container);
552
- if (this.screenCorner.x == "left" ? this.xOffset = 0 : this.xOffset = this.container.clientWidth - this.wrapperWidth - t, this.instanceId > 0) {
553
- let e = this.container.querySelectorAll(".p-gui");
554
- for (let r = 0; r < e.length; r++)
555
- this.screenCorner.y == e[r].dataset.cornerY && (this.screenCorner.x == "left" && e[r].dataset.cornerX == "left" ? this.xOffset += e[r].offsetWidth : this.screenCorner.x == "right" && e[r].dataset.cornerX == "right" && (this.xOffset -= e[r].offsetWidth));
556
- }
557
- this.yOffset = 0, this.position = {
558
- prevX: this.xOffset,
559
- prevY: this.yOffset,
560
- x: this.xOffset,
561
- y: this.yOffset
562
- }, this._addStyles(`#p-gui-${this.instanceId} {
406
+ //#endregion
407
+ //#region src/index.ts
408
+ var _ = class s {
409
+ constructor(e = {}, t = !1) {
410
+ if (this.container = document.body, this.label = "", this.backgroundColor = null, this.opacity = 1, this.maxHeight = window.innerHeight, this.initMaxHeight = null, this.instanceId = 0, this.wrapperWidth = 290, this.stylesheet = null, this.closed = !1, this.domElement = null, this.hasBeenDragged = !1, this.xOffset = 0, this.yOffset = 0, this.position = {
411
+ initX: 0,
412
+ initY: 0,
413
+ prevX: 0,
414
+ prevY: 0,
415
+ x: 0,
416
+ y: 0
417
+ }, this.isFolder = !1, this.parent = null, this.imageContainer = null, this.previousInnerScroll = 0, this.onUpdate = null, this._onPointerDown = (e) => {
418
+ e.preventDefault(), this.position.initX = this.position.x, this.position.initY = this.position.y, this.position.prevX = e.clientX, this.position.prevY = e.clientY, this.container.addEventListener("pointermove", this._onPointerMove), document.addEventListener("pointerup", this._onPointerUp);
419
+ }, this._onPointerMove = (e) => {
420
+ e.preventDefault(), this.hasBeenDragged || (this.hasBeenDragged = !0, this.domElement?.setAttribute("data-dragged", "true")), this.position.x = this.position.initX + e.clientX - this.position.prevX, this.position.y = this.position.initY + e.clientY - this.position.prevY, this.domElement && (this.domElement.style.transform = `translate3d(${this.position.x}px, ${this.position.y}px, 0)`);
421
+ }, this._onPointerUp = () => {
422
+ this.container.removeEventListener("pointermove", this._onPointerMove), document.removeEventListener("pointerup", this._onPointerUp);
423
+ }, this.firstParent = this, this.folders = [], this.tabsArray = [], this.propReferences = [], e.isFolder) {
424
+ this._folderConstructor(e.folderOptions);
425
+ return;
426
+ }
427
+ if (t) return;
428
+ let n = "fixed";
429
+ if (e.container) {
430
+ let t = typeof e.container == "string" ? document.querySelector(e.container) : e.container;
431
+ t instanceof HTMLElement && (this.container = t, n = "absolute");
432
+ }
433
+ this.screenCorner = this._parseScreenCorner(e.position), e.width && (this.wrapperWidth = e.width), typeof e.onUpdate == "function" && (this.onUpdate = e.onUpdate), this.label = typeof e.label == "string" ? e.label : "", this.backgroundColor = e.color || null, this.opacity = e.opacity || 1, this.container && this.container !== document.body && (this.maxHeight = Math.min(this.container.clientHeight, window.innerHeight)), e.maxHeight && (this.initMaxHeight = e.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), window.perfectGUI || (window.perfectGUI = {}), window.perfectGUI.instanceCounter == null ? window.perfectGUI.instanceCounter = 0 : window.perfectGUI.instanceCounter++, this.instanceId = window.perfectGUI.instanceCounter, this.stylesheet = document.createElement("style"), this.stylesheet.setAttribute("type", "text/css"), this.stylesheet.setAttribute("id", "lm-gui-stylesheet"), document.head.append(this.stylesheet), this.instanceId == 0 && this._addStyles(`${g(n)}`), this._styleInstance(), this.closed = !!e.closed;
434
+ let [r, i] = this._addWrapper();
435
+ this.domElement = r, this.wrapper = i, this.domElement.setAttribute("data-corner-x", this.screenCorner.x), this.domElement.setAttribute("data-corner-y", this.screenCorner.y), e.autoRepositioning != 0 && window.addEventListener("resize", this._handleResize.bind(this)), this._handleResize(), e.draggable == 1 && this._makeDraggable();
436
+ }
437
+ _styleInstance() {
438
+ let e = this._getScrollbarWidth(this.container);
439
+ if (this.screenCorner.x == "left" ? this.xOffset = 0 : this.xOffset = this.container.clientWidth - this.wrapperWidth - e, this.instanceId > 0) {
440
+ let e = this.container.querySelectorAll(".p-gui");
441
+ for (let t = 0; t < e.length; t++) this.screenCorner.y == e[t].dataset.cornerY && (this.screenCorner.x == "left" && e[t].dataset.cornerX == "left" ? this.xOffset += e[t].offsetWidth : this.screenCorner.x == "right" && e[t].dataset.cornerX == "right" && (this.xOffset -= e[t].offsetWidth));
442
+ }
443
+ this.yOffset = 0, this.position = {
444
+ initX: this.xOffset,
445
+ initY: this.yOffset,
446
+ prevX: this.xOffset,
447
+ prevY: this.yOffset,
448
+ x: this.xOffset,
449
+ y: this.yOffset
450
+ }, this._addStyles(`#p-gui-${this.instanceId} {
563
451
  width: ${this.wrapperWidth}px;
564
452
  max-height: ${this.maxHeight}px;
565
453
  transform: translate3d(${this.xOffset}px,${this.yOffset}px,0);
@@ -567,183 +455,164 @@ class C {
567
455
  ${this.backgroundColor ? "background: " + this.backgroundColor + ";" : ""}
568
456
  opacity: ${this.opacity};
569
457
  }`);
570
- }
571
- _folderConstructor(t) {
572
- this.domElement = t.wrapper, this.isFolder = !0, this.parent = t.parent, this.firstParent = t.firstParent, this.wrapper = t.inner;
573
- }
574
- _parseScreenCorner(t) {
575
- let e = { x: "right", y: "top" };
576
- return t == null || (typeof t != "string" && console.error("[perfect-gui] Position must be a string."), t.includes("left") && (e.x = "left"), t.includes("bottom") && (e.y = "bottom")), e;
577
- }
578
- _getScrollbarWidth(t) {
579
- return t === document.body ? window.innerWidth - document.documentElement.clientWidth : t.offsetWidth - t.clientWidth;
580
- }
581
- _handleResize() {
582
- if (this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(
583
- this.container.clientHeight,
584
- window.innerHeight
585
- ), this.initMaxHeight && (this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.wrapper.style.maxHeight = this.maxHeight + "px", this.hasBeenDragged)
586
- return;
587
- let t = this._getScrollbarWidth(this.container);
588
- if (this.xOffset = this.screenCorner.x == "left" ? 0 : this.container.clientWidth - this.wrapperWidth - t, this.instanceId > 0) {
589
- let e = this.container.querySelectorAll(
590
- `.p-gui:not(#${this.domElement.id}):not([data-dragged])`
591
- );
592
- for (let r = 0; r < e.length && !(parseInt(
593
- e[r].id.replace("p-gui-", "")
594
- ) > this.instanceId); r++)
595
- this.screenCorner.y == e[r].dataset.cornerY && (this.screenCorner.x == "left" && e[r].dataset.cornerX == "left" ? this.xOffset += e[r].offsetWidth : this.screenCorner.x == "right" && e[r].dataset.cornerX == "right" && (this.xOffset -= e[r].offsetWidth));
596
- }
597
- this.position = {
598
- prevX: this.xOffset,
599
- prevY: this.yOffset,
600
- x: this.xOffset,
601
- y: this.yOffset
602
- }, this.domElement.style.transform = `translate3d(${this.position.x}px, ${this.position.y}px, 0)`;
603
- }
604
- _addStyles(t) {
605
- this.stylesheet.innerHTML += t;
606
- }
607
- _addWrapper() {
608
- this.domElement = document.createElement("div"), this.domElement.id = "p-gui-" + this.instanceId, this.domElement.className = "p-gui" + (this.closed ? " p-gui--collapsed" : ""), this.domElement.setAttribute("data-lenis-prevent", ""), this.container.append(this.domElement), this.header = document.createElement("div"), this.header.className = "p-gui__header", this.header.textContent = this.label, this.header.style = `${this.backgroundColor ? "border-color: " + this.backgroundColor + ";" : ""}`, this.domElement.append(this.header);
609
- const t = document.createElement("div");
610
- t.className = "p-gui__header-close", t.addEventListener("click", this.toggleClose.bind(this)), this.header.append(t);
611
- const e = document.createElement("div");
612
- e.className = "p-gui__content", this.domElement.append(e), this.wrapper = document.createElement("div"), this.wrapper.className = "p-gui__inner", e.append(this.wrapper);
613
- }
614
- button(t = {}) {
615
- return this.imageContainer = null, new S(this, t);
616
- }
617
- image(t = {}) {
618
- return this.imageContainer || (this.imageContainer = document.createElement("div"), this.imageContainer.className = "p-gui__image-container", this.wrapper.append(this.imageContainer)), new z(this, t);
619
- }
620
- slider(t, e, r) {
621
- return this.imageContainer = null, new Y(this, t, e, r);
622
- }
623
- toggle(t, e, r) {
624
- return this.imageContainer = null, new B(this, t, e, r);
625
- }
626
- list(t, e, r) {
627
- return this.imageContainer = null, new T(this, t, e, r);
628
- }
629
- color(t, e, r) {
630
- return this.imageContainer = null, new V(this, t, e, r);
631
- }
632
- vector2(t, e, r, d) {
633
- return this.imageContainer = null, new G(this, t, e, r, d);
634
- }
635
- folder(t = {}) {
636
- let e = typeof t.closed == "boolean" ? t.closed : !1, r = t.label || "", d = t.color || null, i = t.maxHeight || null;
637
- this.imageContainer = null;
638
- let l = "p-gui__folder";
639
- this.folders.length == 0 && (l += " p-gui__folder--first"), e && (l += " p-gui__folder--closed");
640
- let c = d ? `background-color: ${d};` : "";
641
- c += i ? `max-height: ${i}px; overflow-y: auto;` : "";
642
- const n = document.createElement("div");
643
- n.className = l, n.style = c, this.wrapper.append(n);
644
- const o = document.createElement("div");
645
- o.innerHTML = `<span class="p-gui__folder-arrow"></span>${r}`, o.className = "p-gui__folder-header", n.append(o);
646
- const a = document.createElement("div");
647
- a.className = "p-gui__folder-content", n.append(a);
648
- const h = document.createElement("div");
649
- h.className = "p-gui__folder-inner", a.append(h), o.addEventListener("click", () => {
650
- n.classList.toggle("p-gui__folder--closed");
651
- });
652
- let p = new C({
653
- isFolder: !0,
654
- folderOptions: {
655
- wrapper: n,
656
- inner: h,
657
- parent: this,
658
- firstParent: this.firstParent
659
- }
660
- });
661
- return this.folders.push(p), p;
662
- }
663
- tabs(t = {}) {
664
- const e = Array.isArray(t.tabs) ? t.tabs : [], r = t.active || 0, d = t.color || null, i = t.maxHeight || null;
665
- this.imageContainer = null;
666
- let l = "p-gui__tabs";
667
- this.tabsArray.length == 0 && (l += " p-gui__tabs--first");
668
- let c = d ? `background-color: ${d};` : "";
669
- c += i ? `max-height: ${i}px; overflow-y: auto;` : "";
670
- const n = document.createElement("div");
671
- n.className = l, n.style = c, this.wrapper.append(n);
672
- const o = document.createElement("div");
673
- o.className = "p-gui__tabs-header", n.append(o);
674
- const a = document.createElement("div");
675
- a.className = "p-gui__tabs-content", n.append(a);
676
- const h = [];
677
- e.forEach((s, f) => {
678
- const b = typeof s == "string" ? s : s.label || `Tab ${f + 1}`, g = document.createElement("button");
679
- g.className = "p-gui__tab-button", f === r && (g.className += " p-gui__tab-button--active"), g.textContent = b, o.append(g);
680
- const u = document.createElement("div");
681
- u.className = "p-gui__tab-pane", f === r && (u.className += " p-gui__tab-pane--active"), a.append(u);
682
- const m = new C({
683
- isFolder: !0,
684
- folderOptions: {
685
- wrapper: n,
686
- inner: u,
687
- parent: this,
688
- firstParent: this.firstParent
689
- }
690
- });
691
- h.push({
692
- gui: m,
693
- button: g,
694
- pane: u
695
- }), g.addEventListener("click", () => {
696
- h.forEach((x) => {
697
- x.button.classList.remove("p-gui__tab-button--active"), x.pane.classList.remove("p-gui__tab-pane--active");
698
- }), g.classList.add("p-gui__tab-button--active"), u.classList.add("p-gui__tab-pane--active");
699
- });
700
- });
701
- const p = new C({
702
- isFolder: !0,
703
- folderOptions: {
704
- wrapper: n,
705
- inner: h[r]?.pane || document.createElement("div"),
706
- parent: this,
707
- firstParent: this.firstParent
708
- }
709
- });
710
- return p.getTab = (s) => h[s]?.gui || null, p.getTabElement = (s) => h[s]?.button || null, p.setActiveTab = (s) => {
711
- s >= 0 && s < h.length && h[s].button.click();
712
- }, p.getActiveTab = () => h.findIndex(
713
- (s) => s.button.classList.contains("p-gui__tab-button--active")
714
- ), p.element = n, this.tabsArray.push(p), p;
715
- }
716
- _makeDraggable() {
717
- var t = this;
718
- this.header.addEventListener("pointerdown", e), this.header.addEventListener("pointerup", d);
719
- function e(i) {
720
- i.preventDefault(), t.position.initX = t.position.x, t.position.initY = t.position.y, t.position.prevX = i.clientX, t.position.prevY = i.clientY, document.addEventListener("pointermove", r);
721
- }
722
- function r(i) {
723
- i.preventDefault(), t.hasBeenDragged || (t.hasBeenDragged = !0, t.domElement.setAttribute("data-dragged", "true")), t.position.x = t.position.initX + i.clientX - t.position.prevX, t.position.y = t.position.initY + i.clientY - t.position.prevY, t.domElement.style.transform = "translate3d(" + t.position.x + "px," + t.position.y + "px,0)";
724
- }
725
- function d(i) {
726
- document.removeEventListener("pointermove", r);
727
- }
728
- }
729
- toggleClose() {
730
- this.closed = !this.closed, this.closed ? (this.previousInnerScroll = this.wrapper.scrollTop, this.wrapper.scrollTo(0, 0)) : this.wrapper.scrollTo(0, this.previousInnerScroll), this.domElement.classList.toggle("p-gui--collapsed");
731
- }
732
- kill() {
733
- this.domElement.remove();
734
- }
735
- _mapLinear(t, e, r, d, i) {
736
- return d + (t - e) * (i - d) / (r - e);
737
- }
738
- _countDecimals(t) {
739
- const e = t.toString(), r = e.indexOf(".");
740
- return r === -1 ? 0 : e.length - r - 1;
741
- }
742
- static registerPlugin(t) {
743
- for (let e in t)
744
- C.prototype[e] = t[e];
745
- }
746
- }
747
- export {
748
- C as default
458
+ }
459
+ _folderConstructor(e) {
460
+ if (!e) throw Error("[perfect-gui] folderOptions is undefined");
461
+ this.domElement = e.container, this.isFolder = !0, this.parent = e.parent, this.firstParent = e.firstParent, this.wrapper = e.wrapper;
462
+ }
463
+ _parseScreenCorner(e) {
464
+ let t = {
465
+ x: "right",
466
+ y: "top"
467
+ };
468
+ return e == null ? t : (typeof e != "string" && console.error("[perfect-gui] Position must be a string."), e.includes("left") && (t.x = "left"), e.includes("bottom") && (t.y = "bottom"), t);
469
+ }
470
+ _getScrollbarWidth(e) {
471
+ return e === document.body ? window.innerWidth - document.documentElement.clientWidth : e.offsetWidth - e.clientWidth;
472
+ }
473
+ _handleResize() {
474
+ if (!this.domElement || (this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(this.container.clientHeight, window.innerHeight), this.initMaxHeight && (this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.wrapper.style.maxHeight = this.maxHeight + "px", this.hasBeenDragged)) return;
475
+ let e = this._getScrollbarWidth(this.container);
476
+ if (this.xOffset = this.screenCorner.x == "left" ? 0 : this.container.clientWidth - this.wrapperWidth - e, this.instanceId > 0) {
477
+ let e = this.container.querySelectorAll(`.p-gui:not(#${this.domElement.id}):not([data-dragged])`);
478
+ for (let t = 0; t < e.length && !(parseInt(e[t].id.replace("p-gui-", "")) > this.instanceId); t++) this.screenCorner.y == e[t].dataset.cornerY && (this.screenCorner.x == "left" && e[t].dataset.cornerX == "left" ? this.xOffset += e[t].offsetWidth : this.screenCorner.x == "right" && e[t].dataset.cornerX == "right" && (this.xOffset -= e[t].offsetWidth));
479
+ }
480
+ this.position = {
481
+ initX: this.xOffset,
482
+ initY: this.yOffset,
483
+ prevX: this.xOffset,
484
+ prevY: this.yOffset,
485
+ x: this.xOffset,
486
+ y: this.yOffset
487
+ }, this.domElement.style.transform = `translate3d(${this.position.x}px, ${this.position.y}px, 0)`;
488
+ }
489
+ _addStyles(e) {
490
+ this.stylesheet && (this.stylesheet.innerHTML += e);
491
+ }
492
+ _addWrapper() {
493
+ let e = document.createElement("div");
494
+ e.id = "p-gui-" + this.instanceId, e.className = "p-gui" + (this.closed ? " p-gui--collapsed" : ""), e.setAttribute("data-lenis-prevent", ""), this.container.append(e), this.header = document.createElement("div"), this.header.className = "p-gui__header", this.header.textContent = this.label, this.header.style = `${this.backgroundColor ? "border-color: " + this.backgroundColor + ";" : ""}`, e.append(this.header);
495
+ let t = document.createElement("div");
496
+ t.className = "p-gui__header-close", t.addEventListener("click", this.toggleClose.bind(this)), this.header.append(t);
497
+ let n = document.createElement("div");
498
+ n.className = "p-gui__content", e.append(n);
499
+ let r = document.createElement("div");
500
+ return r.className = "p-gui__inner", n.append(r), [e, r];
501
+ }
502
+ button(t = {}) {
503
+ return this.imageContainer = null, new e(this, t);
504
+ }
505
+ image(e, t = {}) {
506
+ return this.imageContainer || (this.imageContainer = document.createElement("div"), this.imageContainer.className = "p-gui__image-container", this.wrapper.append(this.imageContainer)), new n(this, e, t);
507
+ }
508
+ slider(e, n, r) {
509
+ return this.imageContainer = null, new t(this, e, n, r);
510
+ }
511
+ toggle(e, t, n) {
512
+ return this.imageContainer = null, new r(this, e, t, n);
513
+ }
514
+ list(e, t, n, r) {
515
+ return this.imageContainer = null, new i(this, e, t, n, r);
516
+ }
517
+ color(e, t, n) {
518
+ return this.imageContainer = null, new a(this, e, t, n);
519
+ }
520
+ vector2(e, t, n, r) {
521
+ return this.imageContainer = null, new o(this, e, t, n, r);
522
+ }
523
+ folder(e) {
524
+ let t = typeof e.closed == "boolean" ? e.closed : !1, n = e.label || "", r = e.color || null, i = e.maxHeight || null;
525
+ this.imageContainer = null;
526
+ let a = "p-gui__folder";
527
+ this.folders.length == 0 && (a += " p-gui__folder--first"), t && (a += " p-gui__folder--closed");
528
+ let o = r ? `background-color: ${r};` : "";
529
+ o += i ? `max-height: ${i}px; overflow-y: auto;` : "";
530
+ let s = document.createElement("div");
531
+ s.className = a, s.style = o, this.wrapper.append(s);
532
+ let c = document.createElement("div");
533
+ c.innerHTML = `<span class="p-gui__folder-arrow"></span>${n}`, c.className = "p-gui__folder-header", s.append(c);
534
+ let l = document.createElement("div");
535
+ l.className = "p-gui__folder-content", s.append(l);
536
+ let u = document.createElement("div");
537
+ u.className = "p-gui__folder-inner", l.append(u), c.addEventListener("click", () => {
538
+ s.classList.toggle("p-gui__folder--closed");
539
+ });
540
+ let d = new v({
541
+ container: s,
542
+ wrapper: u,
543
+ parent: this,
544
+ firstParent: this.firstParent
545
+ });
546
+ return this.folders.push(d), d;
547
+ }
548
+ tabs(e = {}) {
549
+ let t = Array.isArray(e.tabs) ? e.tabs : [], n = e.active || 0, r = e.color || null, i = e.maxHeight || null;
550
+ this.imageContainer = null;
551
+ let a = "p-gui__tabs";
552
+ this.tabsArray.length == 0 && (a += " p-gui__tabs--first");
553
+ let o = r ? `background-color: ${r};` : "";
554
+ o += i ? `max-height: ${i}px; overflow-y: auto;` : "";
555
+ let s = document.createElement("div");
556
+ s.className = a, s.style = o, this.wrapper.append(s);
557
+ let c = document.createElement("div");
558
+ c.className = "p-gui__tabs-header", s.append(c);
559
+ let l = document.createElement("div");
560
+ l.className = "p-gui__tabs-content", s.append(l);
561
+ let u = [];
562
+ t.forEach((e, t) => {
563
+ let r = typeof e == "string" ? e : e.label || `Tab ${t + 1}`, i = document.createElement("button");
564
+ i.className = "p-gui__tab-button", t === n && (i.className += " p-gui__tab-button--active"), i.textContent = r, c.append(i);
565
+ let a = document.createElement("div");
566
+ a.className = "p-gui__tab-pane", t === n && (a.className += " p-gui__tab-pane--active"), l.append(a);
567
+ let o = new v({
568
+ container: s,
569
+ wrapper: a,
570
+ parent: this,
571
+ firstParent: this.firstParent
572
+ });
573
+ u.push({
574
+ gui: o,
575
+ button: i,
576
+ pane: a
577
+ }), i.addEventListener("click", () => {
578
+ u.forEach((e) => {
579
+ e.button.classList.remove("p-gui__tab-button--active"), e.pane.classList.remove("p-gui__tab-pane--active");
580
+ }), i.classList.add("p-gui__tab-button--active"), a.classList.add("p-gui__tab-pane--active");
581
+ });
582
+ });
583
+ let d = new v({
584
+ container: s,
585
+ wrapper: u[n]?.pane || document.createElement("div"),
586
+ parent: this,
587
+ firstParent: this.firstParent
588
+ });
589
+ return d.getTab = (e) => u[e]?.gui || null, d.getTabElement = (e) => u[e]?.button || null, d.setActiveTab = (e) => {
590
+ e >= 0 && e < u.length && u[e].button.click();
591
+ }, d.getActiveTab = () => u.findIndex((e) => e.button.classList.contains("p-gui__tab-button--active")), d.element = s, this.tabsArray.push(d), d;
592
+ }
593
+ _makeDraggable() {
594
+ !this.domElement || !this.header || this.header.addEventListener("pointerdown", this._onPointerDown);
595
+ }
596
+ toggleClose() {
597
+ this.domElement && (this.closed = !this.closed, this.closed ? (this.previousInnerScroll = this.wrapper.scrollTop, this.wrapper.scrollTo(0, 0)) : this.wrapper.scrollTo(0, this.previousInnerScroll), this.domElement.classList.toggle("p-gui--collapsed"));
598
+ }
599
+ kill() {
600
+ this.domElement && this.domElement.remove();
601
+ }
602
+ _mapLinear(e, t, n, r, i) {
603
+ return r + (e - t) * (i - r) / (n - t);
604
+ }
605
+ _countDecimals(e) {
606
+ let t = e.toString(), n = t.indexOf(".");
607
+ return n === -1 ? 0 : t.length - n - 1;
608
+ }
609
+ static registerPlugin(e) {
610
+ for (let t in e) s.prototype[t] = e[t];
611
+ }
612
+ }, v = class extends _ {
613
+ constructor(e) {
614
+ super({}, !0), this.isFolder = !0, this.domElement = e.container, this.wrapper = e.wrapper, this.parent = e.parent, this.firstParent = e.firstParent;
615
+ }
749
616
  };
617
+ //#endregion
618
+ export { v as Folder, _ as default };