@digitalmeadow/control-panel 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,3 +1,291 @@
1
+ const R = `
2
+ .cp-root {
3
+ position: fixed;
4
+ top: 10px;
5
+ right: 10px;
6
+ width: 280px;
7
+ max-height: 90vh;
8
+ overflow: auto;
9
+ background: transparent;
10
+ color: #fff;
11
+ mix-blend-mode: exclusion;
12
+ font-family:
13
+ -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
14
+ sans-serif;
15
+ font-size: 10px;
16
+ line-height: 1.2;
17
+ padding: 8px;
18
+ z-index: 100;
19
+ }
20
+
21
+ .cp-root::-webkit-scrollbar {
22
+ width: 1px;
23
+ }
24
+ .cp-root::-webkit-scrollbar-track {
25
+ background: transparent;
26
+ }
27
+ .cp-root::-webkit-scrollbar-thumb {
28
+ background: rgba(255, 255, 255, 0.5);
29
+ }
30
+
31
+ .cp-summary {
32
+ cursor: pointer;
33
+ user-select: none;
34
+ font-weight: bold;
35
+ outline: none;
36
+ }
37
+
38
+ .cp-summary-root {
39
+ position: sticky;
40
+ top: 0;
41
+ }
42
+
43
+ .cp-stats {
44
+ float: right;
45
+ font-weight: normal;
46
+ opacity: 0.6;
47
+ font-size: 0.9em;
48
+ font-variant-numeric: tabular-nums;
49
+ }
50
+
51
+ .cp-content {
52
+ margin-top: 4px;
53
+ display: flex;
54
+ flex-direction: column;
55
+ gap: 6px;
56
+ }
57
+
58
+ .cp-folder {
59
+ width: 100%;
60
+ }
61
+
62
+ .cp-folder-content {
63
+ margin: 0 0 6px 0;
64
+ padding: 4px 0 0 9px;
65
+ }
66
+
67
+ .cp-controller {
68
+ display: flex;
69
+ }
70
+
71
+ .cp-label {
72
+ margin: auto 0;
73
+ width: 50%;
74
+ flex-shrink: 0;
75
+ overflow: hidden;
76
+ text-overflow: ellipsis;
77
+ white-space: nowrap;
78
+ user-select: none;
79
+ padding-right: 8px;
80
+ opacity: 0.8;
81
+ }
82
+
83
+ .cp-input-number {
84
+ width: 50%;
85
+ background: transparent;
86
+ border: 1px solid #fff;
87
+ color: inherit;
88
+ padding: 2px 4px;
89
+ border-radius: 2px;
90
+ font-family: inherit;
91
+ font-size: inherit;
92
+ }
93
+
94
+ .cp-input-number:focus {
95
+ outline: none;
96
+ border-color: #fff;
97
+ background: transparent;
98
+ }
99
+
100
+ .cp-select {
101
+ width: 50%;
102
+ background: rgba(255, 255, 255, 0.3);
103
+ border: none;
104
+ padding: 2px 4px;
105
+ border-radius: 2px;
106
+ font-family: inherit;
107
+ font-size: inherit;
108
+ }
109
+
110
+ .cp-checkbox {
111
+ margin: auto 0;
112
+ }
113
+
114
+ .cp-button {
115
+ width: 100%;
116
+ background: rgba(255, 255, 255, 0.3);
117
+ border: none;
118
+ padding: 4px 2px;
119
+ border-radius: 2px;
120
+ cursor: pointer;
121
+ text-align: center;
122
+ font-family: inherit;
123
+ font-size: inherit;
124
+ transition: background 0.1s;
125
+ }
126
+
127
+ .cp-button:hover {
128
+ background: rgba(255, 255, 255, 0.4);
129
+ }
130
+
131
+ .cp-button:active {
132
+ background: rgba(255, 255, 255, 0.2);
133
+ transform: translateY(1px);
134
+ }
135
+
136
+ .cp-controller[data-disabled="true"] {
137
+ opacity: 0.5;
138
+ pointer-events: none;
139
+ cursor: not-allowed;
140
+ }
141
+
142
+ .cp-controller-details {
143
+ width: 50%;
144
+ }
145
+
146
+ .cp-controller-summary {
147
+ cursor: pointer;
148
+ outline: none;
149
+ }
150
+
151
+ .cp-controller-summary-content {
152
+ display: inline-flex;
153
+ align-items: center;
154
+ gap: 6px;
155
+ width: calc(100% - 16px);
156
+ vertical-align: middle;
157
+ }
158
+
159
+ .cp-input-range {
160
+ -webkit-appearance: none;
161
+ flex: 1;
162
+ min-width: 0;
163
+ height: 2px;
164
+ background: rgba(255, 255, 255, 0.3);
165
+ margin: 0;
166
+ vertical-align: middle;
167
+ cursor: grab;
168
+ }
169
+ .cp-input-range::-webkit-slider-thumb {
170
+ -webkit-appearance: none;
171
+ width: 4px;
172
+ height: 8px;
173
+ border-radius: 1px;
174
+ background: #fff;
175
+ cursor: grab;
176
+ }
177
+ .cp-input-range::-moz-range-thumb {
178
+ width: 4px;
179
+ height: 16px;
180
+ background: #fff;
181
+ cursor: grab;
182
+ }
183
+
184
+ .cp-input-range:active {
185
+ cursor: grabbing;
186
+ }
187
+
188
+ .cp-value-display {
189
+ min-width: 24px;
190
+ text-align: right;
191
+ font-variant-numeric: tabular-nums;
192
+ font-size: 0.9em;
193
+ opacity: 0.8;
194
+ user-select: none;
195
+ }
196
+
197
+ .cp-number-settings {
198
+ margin-top: 4px;
199
+ background: transparent;
200
+ border: 1px solid rgba(255, 255, 255, 0.2);
201
+ padding: 4px;
202
+ border-radius: 4px;
203
+ display: flex;
204
+ flex-direction: column;
205
+ gap: 4px;
206
+ }
207
+
208
+ .cp-separator {
209
+ border: none;
210
+ border-top: 1px solid rgba(255, 255, 255, 0.3);
211
+ margin: 4px 0;
212
+ width: 100%;
213
+ }
214
+
215
+ .cp-setting-row {
216
+ display: flex;
217
+ align-items: center;
218
+ gap: 4px;
219
+ }
220
+
221
+ .cp-setting-label {
222
+ width: 50%;
223
+ font-size: 0.9em;
224
+ opacity: 0.7;
225
+ }
226
+
227
+ .cp-input-small {
228
+ width: 50%;
229
+ }
230
+
231
+ .cp-radios {
232
+ width: 50%;
233
+ display: flex;
234
+ gap: 2px;
235
+ }
236
+
237
+ .cp-radio {
238
+ flex: 1;
239
+ font-size: 0.9em;
240
+ padding: 4px 2px;
241
+ height: 100%;
242
+ }
243
+
244
+ .cp-radio[data-active="true"] {
245
+ background: rgba(255, 255, 255, 0.2);
246
+ border-color: #fff;
247
+ font-weight: bold;
248
+ }
249
+
250
+ .cp-button-delete {
251
+ width: 24px;
252
+ padding: 0;
253
+ display: flex;
254
+ align-items: center;
255
+ justify-content: center;
256
+ line-height: 1;
257
+ }
258
+
259
+ .cp-input-color {
260
+ padding: 0;
261
+ margin: 0;
262
+ border: none;
263
+ background: none;
264
+ outline: none;
265
+
266
+ isolation: isolate;
267
+ mix-blend-mode: normal;
268
+ cursor: pointer;
269
+ }
270
+
271
+ .cp-color-swatch {
272
+ width: 10px;
273
+ height: 10px;
274
+ margin-right: 8px;
275
+ }
276
+
277
+ .cp-stops-container {
278
+ display: flex;
279
+ flex-direction: column;
280
+ gap: 4px;
281
+ }
282
+ `;
283
+ let V = !1;
284
+ function j() {
285
+ if (V) return;
286
+ const n = document.createElement("style");
287
+ n.id = "control-panel-styles", n.textContent = R, document.head.appendChild(n), V = !0;
288
+ }
1
289
  function r(n, t = {}, e = []) {
2
290
  const i = document.createElement(n);
3
291
  for (const [s, a] of Object.entries(t))
@@ -16,13 +304,13 @@ function B(n) {
16
304
  );
17
305
  return t.addEventListener("click", n), t;
18
306
  }
19
- function R(n) {
307
+ function $(n) {
20
308
  return n.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()).trim();
21
309
  }
22
310
  function D(n, t, e) {
23
311
  return Math.min(Math.max(n, t), e);
24
312
  }
25
- function j(n, t, e) {
313
+ function q(n, t, e) {
26
314
  if (t.length !== e.length)
27
315
  throw new Error("Input and output ranges must have the same length");
28
316
  if (t.length < 2)
@@ -34,10 +322,10 @@ function j(n, t, e) {
34
322
  return e[e.length - 1];
35
323
  if (i === 0 && n < t[0])
36
324
  return e[0];
37
- const s = t[i], a = t[i + 1], o = e[i], h = e[i + 1];
38
- return (n - s) / (a - s) * (h - o) + o;
325
+ const s = t[i], a = t[i + 1], o = e[i], c = e[i + 1];
326
+ return (n - s) / (a - s) * (c - o) + o;
39
327
  }
40
- class z {
328
+ class H {
41
329
  constructor() {
42
330
  this.source = null, this.stream = null, this.fftSize = 2048, this.smoothingTimeConstant = 0.92, this.spectrumBoost = 2, this.levels = {
43
331
  bass: 0,
@@ -75,18 +363,18 @@ class z {
75
363
  }
76
364
  update() {
77
365
  if (this.analyser.getByteFrequencyData(this.dataArray), this.analyser.getByteTimeDomainData(this.waveformArray), this.spectrumBoost !== 1) {
78
- const p = this.dataArray.length;
79
- for (let c = 0; c < p; c++) {
80
- const u = 1 + c / p * (this.spectrumBoost - 1);
81
- this.dataArray[c] = Math.min(255, this.dataArray[c] * u);
366
+ const h = this.dataArray.length;
367
+ for (let p = 0; p < h; p++) {
368
+ const u = 1 + p / h * (this.spectrumBoost - 1);
369
+ this.dataArray[p] = Math.min(255, this.dataArray[p] * u);
82
370
  }
83
371
  }
84
- const t = [2, 10], e = [10, 150], i = [150, 600], s = this.getAverage(t[0], t[1]), a = this.getAverage(e[0], e[1]), o = this.getAverage(i[0], i[1]), h = this.getAverage(0, i[1]);
85
- this.processLevel("bass", s), this.processLevel("mids", a), this.processLevel("highs", o), this.processLevel("volume", h);
372
+ const t = [2, 10], e = [10, 150], i = [150, 600], s = this.getAverage(t[0], t[1]), a = this.getAverage(e[0], e[1]), o = this.getAverage(i[0], i[1]), c = this.getAverage(0, i[1]);
373
+ this.processLevel("bass", s), this.processLevel("mids", a), this.processLevel("highs", o), this.processLevel("volume", c);
86
374
  }
87
375
  processLevel(t, e) {
88
376
  this.peaks[t] -= 5e-4, this.peaks[t] = D(this.peaks[t], 0.1, 1), e > this.peaks[t] && (this.peaks[t] = e), this.levels[t] = D(
89
- j(e, [0, this.peaks[t]], [0, 1]),
377
+ q(e, [0, this.peaks[t]], [0, 1]),
90
378
  0,
91
379
  1
92
380
  );
@@ -103,8 +391,8 @@ class z {
103
391
  return () => this.levels[t];
104
392
  }
105
393
  }
106
- const x = new z();
107
- class $ {
394
+ const C = new H();
395
+ class U {
108
396
  constructor() {
109
397
  this.midiAccess = null, this.values = /* @__PURE__ */ new Map(), this.isListening = !1, this.resolveListen = null, this.listeningCallback = null, this.init();
110
398
  }
@@ -131,8 +419,8 @@ class $ {
131
419
  this.values.set(a, o), this.isListening && this.resolveListen && o > 0 && (this.resolveListen(a), this.isListening = !1, this.resolveListen = null, this.listeningCallback && this.listeningCallback());
132
420
  }
133
421
  getIdFromMessage(t) {
134
- const e = t.data, [i, s] = e, a = i & 240, o = t.currentTarget.name || "unknown", h = a === 144 || a === 128 ? "note" : "ctrl", p = o.replace(/[^a-zA-Z0-9]/g, "");
135
- return `${s}_${h}_${p}`;
422
+ const e = t.data, [i, s] = e, a = i & 240, o = t.currentTarget.name || "unknown", c = a === 144 || a === 128 ? "note" : "ctrl", h = o.replace(/[^a-zA-Z0-9]/g, "");
423
+ return `${s}_${c}_${h}`;
136
424
  }
137
425
  normalizeValue(t) {
138
426
  const [e, i, s] = t, a = e & 240;
@@ -150,10 +438,10 @@ class $ {
150
438
  return () => this.values.get(t) ?? 0;
151
439
  }
152
440
  }
153
- const q = new $(), M = class M {
441
+ const _ = new U(), k = class k {
154
442
  constructor(t, e, i = {}) {
155
443
  this.changeFns = /* @__PURE__ */ new Set(), this.object = t, this.property = e, this.key = i.id ?? e, this.initialValue = this.object[this.property], this.domElement = r("div", { className: "cp-controller" });
156
- const s = i.label ?? R(e), a = r("label", { className: "cp-label" }, [
444
+ const s = i.label ?? $(e), a = r("label", { className: "cp-label" }, [
157
445
  String(s)
158
446
  ]);
159
447
  a.setAttribute("title", String(s)), this.domElement.appendChild(a), i.disabled && this.domElement.setAttribute("data-disabled", "true");
@@ -184,8 +472,8 @@ const q = new $(), M = class M {
184
472
  this.domElement.appendChild(t);
185
473
  }
186
474
  };
187
- M.audio = x, M.midi = q;
188
- let m = M;
475
+ k.audio = C, k.midi = _;
476
+ let m = k;
189
477
  const O = {
190
478
  linear: (n) => n,
191
479
  quadIn: (n) => n * n,
@@ -259,9 +547,9 @@ class P {
259
547
  ]), o = r("select", {
260
548
  className: "cp-select cp-input-small"
261
549
  });
262
- return e.forEach((h) => {
263
- const p = r("option", { value: h }, [h]);
264
- o.appendChild(p);
550
+ return e.forEach((c) => {
551
+ const h = r("option", { value: c }, [c]);
552
+ o.appendChild(h);
265
553
  }), o.addEventListener("change", () => i(o.value)), s.appendChild(a), s.appendChild(o), { row: s, select: o };
266
554
  }
267
555
  setSignalType(t) {
@@ -303,7 +591,7 @@ class P {
303
591
  this.setSignalType("none"), this.setEase("linear"), this.setBehaviour("forward"), this.setMidiId(null);
304
592
  }
305
593
  }
306
- class H extends m {
594
+ class W extends m {
307
595
  constructor(t, e, i = {}) {
308
596
  super(t, e, i), this.pingPongDirection = 1, this.min = 0, this.max = 100, this.initialOptions = i, this.min = i.min ?? 0, this.max = i.max ?? 100;
309
597
  const s = r("details", {
@@ -331,29 +619,29 @@ class H extends m {
331
619
  className: "cp-controller-summary-content"
332
620
  });
333
621
  o.appendChild(this.input), o.appendChild(this.display), a.appendChild(o), s.appendChild(a);
334
- const h = r("div", { className: "cp-number-settings" }), p = this.createSetting(
622
+ const c = r("div", { className: "cp-number-settings" }), h = this.createSetting(
335
623
  "min",
336
624
  i.min,
337
625
  (l) => this.setMin(l)
338
626
  );
339
- this.minInput = p.input, h.appendChild(p.row);
340
- const c = this.createSetting(
627
+ this.minInput = h.input, c.appendChild(h.row);
628
+ const p = this.createSetting(
341
629
  "max",
342
630
  i.max,
343
631
  (l) => this.setMax(l)
344
632
  );
345
- this.maxInput = c.input, h.appendChild(c.row);
633
+ this.maxInput = p.input, c.appendChild(p.row);
346
634
  const y = this.createSetting(
347
635
  "step",
348
636
  i.step,
349
637
  (l) => this.setStep(l)
350
638
  );
351
- this.stepInput = y.input, h.appendChild(y.row);
639
+ this.stepInput = y.input, c.appendChild(y.row);
352
640
  const u = r("hr", { className: "cp-separator" });
353
- h.appendChild(u), this.signalHandler = new P({
354
- container: h,
641
+ c.appendChild(u), this.signalHandler = new P({
642
+ container: c,
355
643
  onChange: (l, d) => this.applySignal(l, d)
356
- }), s.appendChild(h), this.appendWidget(s);
644
+ }), s.appendChild(c), this.appendWidget(s);
357
645
  }
358
646
  // Setters
359
647
  setMin(t) {
@@ -434,7 +722,7 @@ class H extends m {
434
722
  ), this.setStep(this.initialOptions.step), this.signalHandler?.reset();
435
723
  }
436
724
  }
437
- class U extends m {
725
+ class J extends m {
438
726
  constructor(t, e, i) {
439
727
  super(t, e, i), this.optionValues = [], this.select = r("select", { className: "cp-select" }), this.optionValues = i.options || [], this.optionValues.forEach((s, a) => {
440
728
  const o = r("option", { value: String(a) }, [
@@ -459,7 +747,7 @@ class U extends m {
459
747
  t !== -1 && (this.select.value = String(t));
460
748
  }
461
749
  }
462
- class _ extends m {
750
+ class G extends m {
463
751
  constructor(t, e, i = {}) {
464
752
  const s = { action: e };
465
753
  super(s, "action", i);
@@ -474,7 +762,7 @@ class _ extends m {
474
762
  updateDisplay() {
475
763
  }
476
764
  }
477
- class W extends m {
765
+ class Z extends m {
478
766
  constructor(t, e, i = {}) {
479
767
  super(t, e, i), this.input = r("input", {
480
768
  type: "checkbox",
@@ -487,7 +775,7 @@ class W extends m {
487
775
  this.input.checked = this.value;
488
776
  }
489
777
  }
490
- class J extends m {
778
+ class K extends m {
491
779
  constructor(t, e, i) {
492
780
  super(t, e, i), this.buttons = [], this.optionValues = [], this.container = r("div", { className: "cp-radios" }), this.optionValues = i.options || [], this.optionValues.forEach((s) => {
493
781
  const a = r("button", { className: "cp-button cp-radio" }, [
@@ -505,7 +793,7 @@ class J extends m {
505
793
  });
506
794
  }
507
795
  }
508
- class G extends m {
796
+ class Y extends m {
509
797
  constructor(t, e, i = {}) {
510
798
  super(t, e, i), this.input = r("input", {
511
799
  type: "color",
@@ -530,21 +818,21 @@ function F(n) {
530
818
  parseInt(e[3], 16)
531
819
  ] : [0, 0, 0];
532
820
  }
533
- function Z(n, t, e) {
821
+ function Q(n, t, e) {
534
822
  return "#" + ((1 << 24) + (Math.round(n) << 16) + (Math.round(t) << 8) + Math.round(e)).toString(16).slice(1);
535
823
  }
536
824
  function w(n) {
537
825
  const t = n / 255;
538
826
  return t <= 0.04045 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4);
539
827
  }
540
- function A(n) {
828
+ function L(n) {
541
829
  return n <= 31308e-7 ? n * 12.92 * 255 : (1.055 * Math.pow(n, 1 / 2.4) - 0.055) * 255;
542
830
  }
543
- function K(n, t, e) {
544
- const [i, s, a] = F(n), [o, h, p] = F(t), c = w(i), y = w(s), u = w(a), l = w(o), d = w(h), f = w(p), v = c + e * (l - c), I = y + e * (d - y), S = u + e * (f - u), C = A(v), g = A(I), b = A(S);
545
- return Z(C, g, b);
831
+ function X(n, t, e) {
832
+ const [i, s, a] = F(n), [o, c, h] = F(t), p = w(i), y = w(s), u = w(a), l = w(o), d = w(c), f = w(h), b = p + e * (l - p), I = y + e * (d - y), v = u + e * (f - u), x = L(b), g = L(I), S = L(v);
833
+ return Q(x, g, S);
546
834
  }
547
- class Q extends m {
835
+ class tt extends m {
548
836
  constructor(t, e, i = {}) {
549
837
  super(t, e, i), this.stops = [], this.pingPongDirection = 1, this.animationT = 0, this.manualPosition = 0, this.initialOptions = i, this.stops = i.stops || [
550
838
  { color: "#000000", position: 0 },
@@ -565,25 +853,25 @@ class Q extends m {
565
853
  { className: "cp-value-display" },
566
854
  [String(this.value)]
567
855
  ), o.appendChild(this.displayColor), o.appendChild(this.displayText), a.appendChild(o), s.appendChild(a);
568
- const h = r("div", { className: "cp-number-settings" });
856
+ const c = r("div", { className: "cp-number-settings" });
569
857
  this.stopsContainer = r("div", {
570
858
  className: "cp-stops-container"
571
- }), this.renderStops(), h.appendChild(this.stopsContainer);
572
- const p = r(
859
+ }), this.renderStops(), c.appendChild(this.stopsContainer);
860
+ const h = r(
573
861
  "button",
574
862
  {
575
863
  className: "cp-button"
576
864
  },
577
865
  ["+ Add Stop"]
578
866
  );
579
- p.addEventListener("click", () => {
867
+ h.addEventListener("click", () => {
580
868
  this.stops.push({ color: "#ffffff", position: 0.5 }), this.sortStops(), this.renderStops(), this.updateOutput();
581
- }), h.appendChild(p);
582
- const c = r("hr", { className: "cp-separator" });
583
- h.appendChild(c), this.signalHandler = new P({
584
- container: h,
869
+ }), c.appendChild(h);
870
+ const p = r("hr", { className: "cp-separator" });
871
+ c.appendChild(p), this.signalHandler = new P({
872
+ container: c,
585
873
  onChange: (y, u) => this.applySignal(y, u)
586
- }), s.appendChild(h), this.appendWidget(s), this.updateOutput(0);
874
+ }), s.appendChild(c), this.appendWidget(s), this.updateOutput(0);
587
875
  }
588
876
  sortStops() {
589
877
  this.stops.sort((t, e) => t.position - e.position);
@@ -595,8 +883,8 @@ class Q extends m {
595
883
  className: "cp-input-color",
596
884
  value: t.color
597
885
  });
598
- s.addEventListener("input", (h) => {
599
- t.color = h.target.value, this.updateOutput();
886
+ s.addEventListener("input", (c) => {
887
+ t.color = c.target.value, this.updateOutput();
600
888
  });
601
889
  const a = r("input", {
602
890
  type: "number",
@@ -606,9 +894,9 @@ class Q extends m {
606
894
  step: "0.01",
607
895
  value: String(t.position)
608
896
  });
609
- a.addEventListener("change", (h) => {
610
- let p = parseFloat(h.target.value);
611
- isNaN(p) && (p = 0), t.position = Math.max(0, Math.min(1, p)), this.sortStops(), this.renderStops(), this.updateOutput();
897
+ a.addEventListener("change", (c) => {
898
+ let h = parseFloat(c.target.value);
899
+ isNaN(h) && (h = 0), t.position = Math.max(0, Math.min(1, h)), this.sortStops(), this.renderStops(), this.updateOutput();
612
900
  });
613
901
  const o = B(() => {
614
902
  this.stops.splice(e, 1), this.renderStops(), this.updateOutput();
@@ -632,8 +920,8 @@ class Q extends m {
632
920
  for (let i = 0; i < this.stops.length - 1; i++) {
633
921
  const s = this.stops[i], a = this.stops[i + 1];
634
922
  if (t >= s.position && t <= a.position) {
635
- const o = a.position - s.position, h = o === 0 ? 0 : (t - s.position) / o;
636
- e = K(s.color, a.color, h);
923
+ const o = a.position - s.position, c = o === 0 ? 0 : (t - s.position) / o;
924
+ e = X(s.color, a.color, c);
637
925
  break;
638
926
  }
639
927
  }
@@ -672,7 +960,7 @@ class Q extends m {
672
960
  ], this.sortStops(), this.renderStops(), this.signalHandler?.reset(), this.updateOutput(0);
673
961
  }
674
962
  }
675
- class X extends m {
963
+ class et extends m {
676
964
  constructor(t, e, i = {}) {
677
965
  super(t, e, i), this.items = [], this.initialOptions = i, this.itemType = i.itemType || "string", this.items = this.parseValue(this.value);
678
966
  const s = r("details", {
@@ -681,15 +969,15 @@ class X extends m {
681
969
  className: "cp-controller-summary"
682
970
  }), o = r("div", {
683
971
  className: "cp-controller-summary-content"
684
- }), h = r("span", { className: "cp-value-display" }, [
972
+ }), c = r("span", { className: "cp-value-display" }, [
685
973
  `${this.items.length} items`
686
974
  ]);
687
- o.appendChild(h), a.appendChild(o), s.appendChild(a);
688
- const p = r("div", { className: "cp-number-settings" });
975
+ o.appendChild(c), a.appendChild(o), s.appendChild(a);
976
+ const h = r("div", { className: "cp-number-settings" });
689
977
  this.itemsContainer = r("div", {
690
978
  className: "cp-stops-container"
691
- }), this.renderItems(), p.appendChild(this.itemsContainer);
692
- const c = r(
979
+ }), this.renderItems(), h.appendChild(this.itemsContainer);
980
+ const p = r(
693
981
  "button",
694
982
  {
695
983
  className: "cp-button cp-input-small",
@@ -697,9 +985,9 @@ class X extends m {
697
985
  },
698
986
  ["+ Add Item"]
699
987
  );
700
- c.addEventListener("click", () => {
988
+ p.addEventListener("click", () => {
701
989
  this.addItem();
702
- }), p.appendChild(c), s.appendChild(p), this.appendWidget(s);
990
+ }), h.appendChild(p), s.appendChild(h), this.appendWidget(s);
703
991
  }
704
992
  parseValue(t) {
705
993
  return !t || t.trim() === "" ? [] : t.split(",").map((e) => e.trim());
@@ -768,7 +1056,7 @@ class X extends m {
768
1056
  this.items = this.parseValue(t), this.renderItems(), this.updateValue();
769
1057
  }
770
1058
  }
771
- class Y {
1059
+ class st {
772
1060
  constructor() {
773
1061
  this.frames = 0, this.pollingInterval = 1e3, this.prevTime = performance.now(), this.render = () => {
774
1062
  this.frames++;
@@ -786,44 +1074,44 @@ class Y {
786
1074
  cancelAnimationFrame(this.rafId);
787
1075
  }
788
1076
  }
789
- class k {
1077
+ class z {
790
1078
  constructor() {
791
1079
  this.controllers = [], this.folders = [];
792
1080
  }
793
1081
  addNumber(t, e, i = {}) {
794
- const s = new H(t, e, i);
1082
+ const s = new W(t, e, i);
795
1083
  return this.contentElement.appendChild(s.domElement), this.controllers.push(s), s;
796
1084
  }
797
1085
  addSelect(t, e, i = {}) {
798
- const s = new U(t, e, i);
1086
+ const s = new J(t, e, i);
799
1087
  return this.contentElement.appendChild(s.domElement), this.controllers.push(s), s;
800
1088
  }
801
1089
  addBoolean(t, e, i = {}) {
802
- const s = new W(t, e, i);
1090
+ const s = new Z(t, e, i);
803
1091
  return this.contentElement.appendChild(s.domElement), this.controllers.push(s), s;
804
1092
  }
805
1093
  addButton(t, e, i = {}) {
806
- const s = new _(t, e, i);
1094
+ const s = new G(t, e, i);
807
1095
  return this.contentElement.appendChild(s.domElement), this.controllers.push(s), s;
808
1096
  }
809
1097
  addRadio(t, e, i = {}) {
810
- const s = new J(t, e, i);
1098
+ const s = new K(t, e, i);
811
1099
  return this.contentElement.appendChild(s.domElement), this.controllers.push(s), s;
812
1100
  }
813
1101
  addColor(t, e, i = {}) {
814
- const s = new G(t, e, i);
1102
+ const s = new Y(t, e, i);
815
1103
  return this.contentElement.appendChild(s.domElement), this.controllers.push(s), s;
816
1104
  }
817
1105
  addGradient(t, e, i = {}) {
818
- const s = new Q(t, e, i);
1106
+ const s = new tt(t, e, i);
819
1107
  return this.contentElement.appendChild(s.domElement), this.controllers.push(s), s;
820
1108
  }
821
1109
  addArray(t, e, i = {}) {
822
- const s = new X(t, e, i);
1110
+ const s = new et(t, e, i);
823
1111
  return this.contentElement.appendChild(s.domElement), this.controllers.push(s), s;
824
1112
  }
825
1113
  addFolder(t) {
826
- const e = new tt(t);
1114
+ const e = new it(t);
827
1115
  return this.contentElement.appendChild(e.domElement), this.folders.push(e), e;
828
1116
  }
829
1117
  save() {
@@ -861,7 +1149,7 @@ class k {
861
1149
  t.reset();
862
1150
  }
863
1151
  }
864
- class tt extends k {
1152
+ class it extends z {
865
1153
  constructor(t) {
866
1154
  super(), this.title = t, this.domElement = r("details", {
867
1155
  className: "cp-folder",
@@ -879,9 +1167,9 @@ class tt extends k {
879
1167
  );
880
1168
  }
881
1169
  }
882
- class et extends k {
1170
+ class nt extends z {
883
1171
  constructor(t, e = {}) {
884
- super(), this.domElement = r("details", {
1172
+ super(), j(), this.domElement = r("details", {
885
1173
  className: "cp-root",
886
1174
  open: !0
887
1175
  }), this.summaryElement = r("summary", {
@@ -890,7 +1178,7 @@ class et extends k {
890
1178
  const i = r("span", {}, [
891
1179
  e.title || "ControlPanel"
892
1180
  ]);
893
- this.summaryElement.appendChild(i), this.stats = new Y(), this.summaryElement.appendChild(this.stats.domElement), this.contentElement = r("div", { className: "cp-content" }), this.domElement.appendChild(this.contentElement);
1181
+ this.summaryElement.appendChild(i), this.stats = new st(), this.summaryElement.appendChild(this.stats.domElement), this.contentElement = r("div", { className: "cp-content" }), this.domElement.appendChild(this.contentElement);
894
1182
  const s = this.addFolder("_Signals"), a = {
895
1183
  audioInput: null,
896
1184
  fftSize: 2048
@@ -899,20 +1187,20 @@ class et extends k {
899
1187
  label: "Audio Signal",
900
1188
  options: ["microphone", "browser"]
901
1189
  }).onChange((l) => {
902
- x.setInput(l);
1190
+ C.setInput(l);
903
1191
  }), s.addSelect(a, "fftSize", {
904
1192
  label: "FFT Size",
905
1193
  options: [256, 512, 1024, 2048]
906
1194
  }).onChange((l) => {
907
- x.setFFTSize(l);
908
- }), s.addNumber(x, "smoothingTimeConstant", {
1195
+ C.setFFTSize(l);
1196
+ }), s.addNumber(C, "smoothingTimeConstant", {
909
1197
  min: 0,
910
1198
  max: 0.99,
911
1199
  step: 0.01,
912
1200
  label: "Smoothing"
913
1201
  }).onChange((l) => {
914
- x.analyser.smoothingTimeConstant = l;
915
- }), s.addNumber(x, "spectrumBoost", {
1202
+ C.analyser.smoothingTimeConstant = l;
1203
+ }), s.addNumber(C, "spectrumBoost", {
916
1204
  min: 1,
917
1205
  max: 5,
918
1206
  step: 0.1,
@@ -920,21 +1208,21 @@ class et extends k {
920
1208
  }), t ? t.appendChild(this.domElement) : document.body.appendChild(this.domElement);
921
1209
  const o = e.title || "ControlPanel";
922
1210
  this.presetStoragePrefix = `cp-presets-${o}-`;
923
- const h = this.addFolder("_User Presets"), p = () => {
1211
+ const c = this.addFolder("_User Presets"), h = () => {
924
1212
  const l = ["Default"];
925
1213
  if (typeof localStorage > "u") return l;
926
1214
  for (let d = 0; d < localStorage.length; d++) {
927
1215
  const f = localStorage.key(d);
928
1216
  if (f && f.startsWith(this.presetStoragePrefix)) {
929
- const v = f.substring(this.presetStoragePrefix.length);
930
- v !== "Default" && !l.includes(v) && l.push(v);
1217
+ const b = f.substring(this.presetStoragePrefix.length);
1218
+ b !== "Default" && !l.includes(b) && l.push(b);
931
1219
  }
932
1220
  }
933
1221
  return l.sort();
934
- }, c = {
1222
+ }, p = {
935
1223
  selected: "Default",
936
1224
  save: () => {
937
- const l = prompt("Preset Name:", c.selected);
1225
+ const l = prompt("Preset Name:", p.selected);
938
1226
  if (l) {
939
1227
  if (l === "Default") {
940
1228
  alert("Cannot overwrite Default preset");
@@ -942,24 +1230,24 @@ class et extends k {
942
1230
  }
943
1231
  const d = this.presetStoragePrefix + l;
944
1232
  this.saveToLocalStorage(d);
945
- const f = p();
946
- u.setOptions(f), c.selected = l, u.setValue(l);
1233
+ const f = h();
1234
+ u.setOptions(f), p.selected = l, u.setValue(l);
947
1235
  }
948
1236
  },
949
1237
  load: () => {
950
- const l = c.selected, d = this.presetStoragePrefix + l;
951
- this.loadFromLocalStorage(d), c.selected = l, u.setValue(l);
1238
+ const l = p.selected, d = this.presetStoragePrefix + l;
1239
+ this.loadFromLocalStorage(d), p.selected = l, u.setValue(l);
952
1240
  },
953
1241
  delete: () => {
954
- if (c.selected === "Default") {
1242
+ if (p.selected === "Default") {
955
1243
  alert("Cannot delete Default preset");
956
1244
  return;
957
1245
  }
958
- if (confirm(`Delete preset "${c.selected}"?`)) {
959
- const l = this.presetStoragePrefix + c.selected;
1246
+ if (confirm(`Delete preset "${p.selected}"?`)) {
1247
+ const l = this.presetStoragePrefix + p.selected;
960
1248
  localStorage.removeItem(l);
961
- const d = p();
962
- u.setOptions(d), c.selected = "Default", u.setValue("Default"), this.reset();
1249
+ const d = h();
1250
+ u.setOptions(d), p.selected = "Default", u.setValue("Default"), this.reset();
963
1251
  }
964
1252
  },
965
1253
  export: () => {
@@ -968,34 +1256,34 @@ class et extends k {
968
1256
  controllers: {},
969
1257
  folders: {}
970
1258
  };
971
- for (const [E, L] of Object.entries(T.controllers))
972
- E.startsWith("_") || (N.controllers[E] = L);
973
- for (const [E, L] of Object.entries(
1259
+ for (const [E, M] of Object.entries(T.controllers))
1260
+ E.startsWith("_") || (N.controllers[E] = M);
1261
+ for (const [E, M] of Object.entries(
974
1262
  T.folders
975
1263
  ))
976
- E.startsWith("_") || (N.folders[E] = d(L));
1264
+ E.startsWith("_") || (N.folders[E] = d(M));
977
1265
  return N;
978
- }, f = d(l), v = {
979
- _presetName: c.selected || "CustomPreset",
1266
+ }, f = d(l), b = {
1267
+ _presetName: p.selected || "CustomPreset",
980
1268
  _exportDate: (/* @__PURE__ */ new Date()).toISOString(),
981
1269
  _instructions: "To add as factory preset: Copy 'controllers' and 'folders' fields into the presets.json file",
982
1270
  ...f
983
- }, I = JSON.stringify(v, null, 2), S = new Blob([I], { type: "application/json" }), C = URL.createObjectURL(S), g = document.createElement("a");
984
- g.href = C;
985
- const b = (/* @__PURE__ */ new Date()).toISOString().split("T")[0], V = c.selected.replace(/[^a-z0-9]/gi, "-").toLowerCase();
986
- g.download = `${o.toLowerCase()}-preset-${V}-${b}.json`, document.body.appendChild(g), g.click(), document.body.removeChild(g), URL.revokeObjectURL(C);
1271
+ }, I = JSON.stringify(b, null, 2), v = new Blob([I], { type: "application/json" }), x = URL.createObjectURL(v), g = document.createElement("a");
1272
+ g.href = x;
1273
+ const S = (/* @__PURE__ */ new Date()).toISOString().split("T")[0], A = p.selected.replace(/[^a-z0-9]/gi, "-").toLowerCase();
1274
+ g.download = `${o.toLowerCase()}-preset-${A}-${S}.json`, document.body.appendChild(g), g.click(), document.body.removeChild(g), URL.revokeObjectURL(x);
987
1275
  },
988
1276
  import: () => {
989
1277
  const l = document.createElement("input");
990
1278
  l.type = "file", l.accept = ".json", l.onchange = (d) => {
991
1279
  const f = d.target.files?.[0];
992
1280
  if (!f) return;
993
- const v = new FileReader();
994
- v.onload = (I) => {
1281
+ const b = new FileReader();
1282
+ b.onload = (I) => {
995
1283
  try {
996
- const S = I.target?.result, C = JSON.parse(S), g = {
997
- controllers: C.controllers || {},
998
- folders: C.folders || {}
1284
+ const v = I.target?.result, x = JSON.parse(v), g = {
1285
+ controllers: x.controllers || {},
1286
+ folders: x.folders || {}
999
1287
  };
1000
1288
  if (!g.controllers || !g.folders) {
1001
1289
  alert(
@@ -1004,28 +1292,28 @@ class et extends k {
1004
1292
  return;
1005
1293
  }
1006
1294
  this.load(g);
1007
- const b = C._presetName || "ImportedPreset";
1295
+ const S = x._presetName || "ImportedPreset";
1008
1296
  if (confirm(
1009
- `Preset loaded! Save as "${b}" to User Presets?`
1297
+ `Preset loaded! Save as "${S}" to User Presets?`
1010
1298
  )) {
1011
- const T = this.presetStoragePrefix + b;
1299
+ const T = this.presetStoragePrefix + S;
1012
1300
  this.saveToLocalStorage(T);
1013
- const N = p();
1014
- u.setOptions(N), c.selected = b, u.setValue(b);
1301
+ const N = h();
1302
+ u.setOptions(N), p.selected = S, u.setValue(S);
1015
1303
  }
1016
- } catch (S) {
1304
+ } catch (v) {
1017
1305
  alert(
1018
- `Failed to import preset: ${S instanceof Error ? S.message : "Invalid JSON"}`
1019
- ), console.error("Import error:", S);
1306
+ `Failed to import preset: ${v instanceof Error ? v.message : "Invalid JSON"}`
1307
+ ), console.error("Import error:", v);
1020
1308
  }
1021
- }, v.readAsText(f);
1309
+ }, b.readAsText(f);
1022
1310
  }, l.click();
1023
1311
  }
1024
- }, y = p(), u = h.addSelect(c, "selected", {
1312
+ }, y = h(), u = c.addSelect(p, "selected", {
1025
1313
  label: "Preset",
1026
1314
  options: y
1027
1315
  });
1028
- h.addButton("Load", () => c.load()), h.addButton("Save / New", () => c.save()), h.addButton("Delete", () => c.delete()), h.addButton("Export JSON", () => c.export()), h.addButton("Import JSON", () => c.import());
1316
+ c.addButton("Load", () => p.load()), c.addButton("Save / New", () => p.save()), c.addButton("Delete", () => p.delete()), c.addButton("Export JSON", () => p.export()), c.addButton("Import JSON", () => p.import());
1029
1317
  }
1030
1318
  saveToLocalStorage(t) {
1031
1319
  const e = this.save();
@@ -1055,18 +1343,20 @@ class et extends k {
1055
1343
  }
1056
1344
  }
1057
1345
  export {
1058
- X as ArrayController,
1059
- z as AudioSignals,
1060
- W as BooleanController,
1061
- _ as ButtonController,
1062
- G as ColorController,
1063
- et as ControlPanel,
1346
+ et as ArrayController,
1347
+ H as AudioSignals,
1348
+ Z as BooleanController,
1349
+ G as ButtonController,
1350
+ Y as ColorController,
1351
+ nt as ControlPanel,
1352
+ z as ControlPanelContainer,
1064
1353
  m as Controller,
1065
- Q as GradientController,
1066
- $ as MidiSignals,
1067
- H as NumberController,
1068
- J as RadioController,
1069
- U as SelectController,
1070
- x as audioSignals,
1071
- q as midiSignals
1354
+ it as Folder,
1355
+ tt as GradientController,
1356
+ U as MidiSignals,
1357
+ W as NumberController,
1358
+ K as RadioController,
1359
+ J as SelectController,
1360
+ C as audioSignals,
1361
+ _ as midiSignals
1072
1362
  };