audio-mixer-ui 0.8.0 → 0.9.1

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,12 +1,12 @@
1
- import { ref as M, watch as g, unref as r, onScopeDispose as tU, readonly as El, mergeModels as Sl, useCssVars as ll, computed as J, useTemplateRef as A, useModel as $, createElementBlock as y, openBlock as p, normalizeClass as C, createElementVNode as h, createCommentVNode as f, Fragment as nl, renderList as Xl, normalizeStyle as gl, renderSlot as tl, toDisplayString as D, onUnmounted as cl, watchEffect as kl, onMounted as bl, createVNode as x, withCtx as P, createTextVNode as Nl, withDirectives as Kl, withKeys as QU, vModelText as Hl, withModifiers as Tl, createBlock as Rl } from "vue";
1
+ import { ref as x, watch as v, unref as T, onScopeDispose as QU, readonly as El, mergeModels as Sl, useCssVars as Ul, computed as J, useTemplateRef as f, useModel as $, createElementBlock as y, openBlock as N, normalizeClass as L, createElementVNode as h, createCommentVNode as _, Fragment as nl, renderList as Xl, normalizeStyle as gl, renderSlot as Ql, toDisplayString as K, onUnmounted as cl, watchEffect as kl, onMounted as bl, createVNode as C, withCtx as w, createTextVNode as Nl, withDirectives as Kl, withKeys as VU, vModelText as Hl, withModifiers as Tl, createBlock as Rl } from "vue";
2
2
  import { defineStore as sl } from "pinia";
3
3
  var Dl = function() {
4
4
  if (typeof Map < "u")
5
5
  return Map;
6
- function Z(l, U) {
6
+ function t(l, U) {
7
7
  var F = -1;
8
- return l.some(function(d, t) {
9
- return d[0] === U ? (F = t, !0) : !1;
8
+ return l.some(function(d, Z) {
9
+ return d[0] === U ? (F = Z, !0) : !1;
10
10
  }), F;
11
11
  }
12
12
  return (
@@ -25,22 +25,22 @@ var Dl = function() {
25
25
  enumerable: !0,
26
26
  configurable: !0
27
27
  }), l.prototype.get = function(U) {
28
- var F = Z(this.__entries__, U), d = this.__entries__[F];
28
+ var F = t(this.__entries__, U), d = this.__entries__[F];
29
29
  return d && d[1];
30
30
  }, l.prototype.set = function(U, F) {
31
- var d = Z(this.__entries__, U);
31
+ var d = t(this.__entries__, U);
32
32
  ~d ? this.__entries__[d][1] = F : this.__entries__.push([U, F]);
33
33
  }, l.prototype.delete = function(U) {
34
- var F = this.__entries__, d = Z(F, U);
34
+ var F = this.__entries__, d = t(F, U);
35
35
  ~d && F.splice(d, 1);
36
36
  }, l.prototype.has = function(U) {
37
- return !!~Z(this.__entries__, U);
37
+ return !!~t(this.__entries__, U);
38
38
  }, l.prototype.clear = function() {
39
39
  this.__entries__.splice(0);
40
40
  }, l.prototype.forEach = function(U, F) {
41
41
  F === void 0 && (F = null);
42
- for (var d = 0, t = this.__entries__; d < t.length; d++) {
43
- var Q = t[d];
42
+ for (var d = 0, Z = this.__entries__; d < Z.length; d++) {
43
+ var Q = Z[d];
44
44
  U.call(F, Q[1], Q[0]);
45
45
  }
46
46
  }, l;
@@ -48,25 +48,25 @@ var Dl = function() {
48
48
  );
49
49
  }(), Gl = typeof window < "u" && typeof document < "u" && window.document === document, ml = function() {
50
50
  return typeof global < "u" && global.Math === Math ? global : typeof self < "u" && self.Math === Math ? self : typeof window < "u" && window.Math === Math ? window : Function("return this")();
51
- }(), VU = function() {
52
- return typeof requestAnimationFrame == "function" ? requestAnimationFrame.bind(ml) : function(Z) {
51
+ }(), aU = function() {
52
+ return typeof requestAnimationFrame == "function" ? requestAnimationFrame.bind(ml) : function(t) {
53
53
  return setTimeout(function() {
54
- return Z(Date.now());
54
+ return t(Date.now());
55
55
  }, 1e3 / 60);
56
56
  };
57
- }(), aU = 2;
58
- function nU(Z, l) {
57
+ }(), nU = 2;
58
+ function RU(t, l) {
59
59
  var U = !1, F = !1, d = 0;
60
- function t() {
61
- U && (U = !1, Z()), F && V();
60
+ function Z() {
61
+ U && (U = !1, t()), F && V();
62
62
  }
63
63
  function Q() {
64
- VU(t);
64
+ aU(Z);
65
65
  }
66
66
  function V() {
67
67
  var a = Date.now();
68
68
  if (U) {
69
- if (a - d < aU)
69
+ if (a - d < nU)
70
70
  return;
71
71
  F = !0;
72
72
  } else
@@ -75,108 +75,108 @@ function nU(Z, l) {
75
75
  }
76
76
  return V;
77
77
  }
78
- var RU = 20, mU = ["top", "right", "bottom", "left", "width", "height", "size", "weight"], eU = typeof MutationObserver < "u", WU = (
78
+ var mU = 20, eU = ["top", "right", "bottom", "left", "width", "height", "size", "weight"], WU = typeof MutationObserver < "u", cU = (
79
79
  /** @class */
80
80
  function() {
81
- function Z() {
82
- this.connected_ = !1, this.mutationEventsAdded_ = !1, this.mutationsObserver_ = null, this.observers_ = [], this.onTransitionEnd_ = this.onTransitionEnd_.bind(this), this.refresh = nU(this.refresh.bind(this), RU);
81
+ function t() {
82
+ this.connected_ = !1, this.mutationEventsAdded_ = !1, this.mutationsObserver_ = null, this.observers_ = [], this.onTransitionEnd_ = this.onTransitionEnd_.bind(this), this.refresh = RU(this.refresh.bind(this), mU);
83
83
  }
84
- return Z.prototype.addObserver = function(l) {
84
+ return t.prototype.addObserver = function(l) {
85
85
  ~this.observers_.indexOf(l) || this.observers_.push(l), this.connected_ || this.connect_();
86
- }, Z.prototype.removeObserver = function(l) {
86
+ }, t.prototype.removeObserver = function(l) {
87
87
  var U = this.observers_, F = U.indexOf(l);
88
88
  ~F && U.splice(F, 1), !U.length && this.connected_ && this.disconnect_();
89
- }, Z.prototype.refresh = function() {
89
+ }, t.prototype.refresh = function() {
90
90
  var l = this.updateObservers_();
91
91
  l && this.refresh();
92
- }, Z.prototype.updateObservers_ = function() {
92
+ }, t.prototype.updateObservers_ = function() {
93
93
  var l = this.observers_.filter(function(U) {
94
94
  return U.gatherActive(), U.hasActive();
95
95
  });
96
96
  return l.forEach(function(U) {
97
97
  return U.broadcastActive();
98
98
  }), l.length > 0;
99
- }, Z.prototype.connect_ = function() {
100
- !Gl || this.connected_ || (document.addEventListener("transitionend", this.onTransitionEnd_), window.addEventListener("resize", this.refresh), eU ? (this.mutationsObserver_ = new MutationObserver(this.refresh), this.mutationsObserver_.observe(document, {
99
+ }, t.prototype.connect_ = function() {
100
+ !Gl || this.connected_ || (document.addEventListener("transitionend", this.onTransitionEnd_), window.addEventListener("resize", this.refresh), WU ? (this.mutationsObserver_ = new MutationObserver(this.refresh), this.mutationsObserver_.observe(document, {
101
101
  attributes: !0,
102
102
  childList: !0,
103
103
  characterData: !0,
104
104
  subtree: !0
105
105
  })) : (document.addEventListener("DOMSubtreeModified", this.refresh), this.mutationEventsAdded_ = !0), this.connected_ = !0);
106
- }, Z.prototype.disconnect_ = function() {
106
+ }, t.prototype.disconnect_ = function() {
107
107
  !Gl || !this.connected_ || (document.removeEventListener("transitionend", this.onTransitionEnd_), window.removeEventListener("resize", this.refresh), this.mutationsObserver_ && this.mutationsObserver_.disconnect(), this.mutationEventsAdded_ && document.removeEventListener("DOMSubtreeModified", this.refresh), this.mutationsObserver_ = null, this.mutationEventsAdded_ = !1, this.connected_ = !1);
108
- }, Z.prototype.onTransitionEnd_ = function(l) {
109
- var U = l.propertyName, F = U === void 0 ? "" : U, d = mU.some(function(t) {
110
- return !!~F.indexOf(t);
108
+ }, t.prototype.onTransitionEnd_ = function(l) {
109
+ var U = l.propertyName, F = U === void 0 ? "" : U, d = eU.some(function(Z) {
110
+ return !!~F.indexOf(Z);
111
111
  });
112
112
  d && this.refresh();
113
- }, Z.getInstance = function() {
114
- return this.instance_ || (this.instance_ = new Z()), this.instance_;
115
- }, Z.instance_ = null, Z;
113
+ }, t.getInstance = function() {
114
+ return this.instance_ || (this.instance_ = new t()), this.instance_;
115
+ }, t.instance_ = null, t;
116
116
  }()
117
- ), jl = function(Z, l) {
117
+ ), jl = function(t, l) {
118
118
  for (var U = 0, F = Object.keys(l); U < F.length; U++) {
119
119
  var d = F[U];
120
- Object.defineProperty(Z, d, {
120
+ Object.defineProperty(t, d, {
121
121
  value: l[d],
122
122
  enumerable: !1,
123
123
  writable: !1,
124
124
  configurable: !0
125
125
  });
126
126
  }
127
- return Z;
128
- }, Zl = function(Z) {
129
- var l = Z && Z.ownerDocument && Z.ownerDocument.defaultView;
127
+ return t;
128
+ }, Zl = function(t) {
129
+ var l = t && t.ownerDocument && t.ownerDocument.defaultView;
130
130
  return l || ml;
131
131
  }, ql = hl(0, 0, 0, 0);
132
- function el(Z) {
133
- return parseFloat(Z) || 0;
132
+ function el(t) {
133
+ return parseFloat(t) || 0;
134
134
  }
135
- function rl(Z) {
135
+ function rl(t) {
136
136
  for (var l = [], U = 1; U < arguments.length; U++)
137
137
  l[U - 1] = arguments[U];
138
138
  return l.reduce(function(F, d) {
139
- var t = Z["border-" + d + "-width"];
140
- return F + el(t);
139
+ var Z = t["border-" + d + "-width"];
140
+ return F + el(Z);
141
141
  }, 0);
142
142
  }
143
- function cU(Z) {
143
+ function bU(t) {
144
144
  for (var l = ["top", "right", "bottom", "left"], U = {}, F = 0, d = l; F < d.length; F++) {
145
- var t = d[F], Q = Z["padding-" + t];
146
- U[t] = el(Q);
145
+ var Z = d[F], Q = t["padding-" + Z];
146
+ U[Z] = el(Q);
147
147
  }
148
148
  return U;
149
149
  }
150
- function bU(Z) {
151
- var l = Z.getBBox();
150
+ function sU(t) {
151
+ var l = t.getBBox();
152
152
  return hl(0, 0, l.width, l.height);
153
153
  }
154
- function sU(Z) {
155
- var l = Z.clientWidth, U = Z.clientHeight;
154
+ function hU(t) {
155
+ var l = t.clientWidth, U = t.clientHeight;
156
156
  if (!l && !U)
157
157
  return ql;
158
- var F = Zl(Z).getComputedStyle(Z), d = cU(F), t = d.left + d.right, Q = d.top + d.bottom, V = el(F.width), a = el(F.height);
159
- if (F.boxSizing === "border-box" && (Math.round(V + t) !== l && (V -= rl(F, "left", "right") + t), Math.round(a + Q) !== U && (a -= rl(F, "top", "bottom") + Q)), !BU(Z)) {
160
- var n = Math.round(V + t) - l, R = Math.round(a + Q) - U;
158
+ var F = Zl(t).getComputedStyle(t), d = bU(F), Z = d.left + d.right, Q = d.top + d.bottom, V = el(F.width), a = el(F.height);
159
+ if (F.boxSizing === "border-box" && (Math.round(V + Z) !== l && (V -= rl(F, "left", "right") + Z), Math.round(a + Q) !== U && (a -= rl(F, "top", "bottom") + Q)), !iU(t)) {
160
+ var n = Math.round(V + Z) - l, R = Math.round(a + Q) - U;
161
161
  Math.abs(n) !== 1 && (V -= n), Math.abs(R) !== 1 && (a -= R);
162
162
  }
163
163
  return hl(d.left, d.top, V, a);
164
164
  }
165
- var hU = /* @__PURE__ */ function() {
166
- return typeof SVGGraphicsElement < "u" ? function(Z) {
167
- return Z instanceof Zl(Z).SVGGraphicsElement;
168
- } : function(Z) {
169
- return Z instanceof Zl(Z).SVGElement && typeof Z.getBBox == "function";
165
+ var BU = /* @__PURE__ */ function() {
166
+ return typeof SVGGraphicsElement < "u" ? function(t) {
167
+ return t instanceof Zl(t).SVGGraphicsElement;
168
+ } : function(t) {
169
+ return t instanceof Zl(t).SVGElement && typeof t.getBBox == "function";
170
170
  };
171
171
  }();
172
- function BU(Z) {
173
- return Z === Zl(Z).document.documentElement;
172
+ function iU(t) {
173
+ return t === Zl(t).document.documentElement;
174
174
  }
175
- function iU(Z) {
176
- return Gl ? hU(Z) ? bU(Z) : sU(Z) : ql;
175
+ function uU(t) {
176
+ return Gl ? BU(t) ? sU(t) : hU(t) : ql;
177
177
  }
178
- function uU(Z) {
179
- var l = Z.x, U = Z.y, F = Z.width, d = Z.height, t = typeof DOMRectReadOnly < "u" ? DOMRectReadOnly : Object, Q = Object.create(t.prototype);
178
+ function JU(t) {
179
+ var l = t.x, U = t.y, F = t.width, d = t.height, Z = typeof DOMRectReadOnly < "u" ? DOMRectReadOnly : Object, Q = Object.create(Z.prototype);
180
180
  return jl(Q, {
181
181
  x: l,
182
182
  y: U,
@@ -188,50 +188,50 @@ function uU(Z) {
188
188
  left: l
189
189
  }), Q;
190
190
  }
191
- function hl(Z, l, U, F) {
192
- return { x: Z, y: l, width: U, height: F };
191
+ function hl(t, l, U, F) {
192
+ return { x: t, y: l, width: U, height: F };
193
193
  }
194
- var JU = (
194
+ var GU = (
195
195
  /** @class */
196
196
  function() {
197
- function Z(l) {
197
+ function t(l) {
198
198
  this.broadcastWidth = 0, this.broadcastHeight = 0, this.contentRect_ = hl(0, 0, 0, 0), this.target = l;
199
199
  }
200
- return Z.prototype.isActive = function() {
201
- var l = iU(this.target);
200
+ return t.prototype.isActive = function() {
201
+ var l = uU(this.target);
202
202
  return this.contentRect_ = l, l.width !== this.broadcastWidth || l.height !== this.broadcastHeight;
203
- }, Z.prototype.broadcastRect = function() {
203
+ }, t.prototype.broadcastRect = function() {
204
204
  var l = this.contentRect_;
205
205
  return this.broadcastWidth = l.width, this.broadcastHeight = l.height, l;
206
- }, Z;
206
+ }, t;
207
207
  }()
208
- ), GU = (
208
+ ), oU = (
209
209
  /** @class */
210
210
  /* @__PURE__ */ function() {
211
- function Z(l, U) {
212
- var F = uU(U);
211
+ function t(l, U) {
212
+ var F = JU(U);
213
213
  jl(this, { target: l, contentRect: F });
214
214
  }
215
- return Z;
215
+ return t;
216
216
  }()
217
- ), oU = (
217
+ ), SU = (
218
218
  /** @class */
219
219
  function() {
220
- function Z(l, U, F) {
220
+ function t(l, U, F) {
221
221
  if (this.activeObservations_ = [], this.observations_ = new Dl(), typeof l != "function")
222
222
  throw new TypeError("The callback provided as parameter 1 is not a function.");
223
223
  this.callback_ = l, this.controller_ = U, this.callbackCtx_ = F;
224
224
  }
225
- return Z.prototype.observe = function(l) {
225
+ return t.prototype.observe = function(l) {
226
226
  if (!arguments.length)
227
227
  throw new TypeError("1 argument required, but only 0 present.");
228
228
  if (!(typeof Element > "u" || !(Element instanceof Object))) {
229
229
  if (!(l instanceof Zl(l).Element))
230
230
  throw new TypeError('parameter 1 is not of type "Element".');
231
231
  var U = this.observations_;
232
- U.has(l) || (U.set(l, new JU(l)), this.controller_.addObserver(this), this.controller_.refresh());
232
+ U.has(l) || (U.set(l, new GU(l)), this.controller_.addObserver(this), this.controller_.refresh());
233
233
  }
234
- }, Z.prototype.unobserve = function(l) {
234
+ }, t.prototype.unobserve = function(l) {
235
235
  if (!arguments.length)
236
236
  throw new TypeError("1 argument required, but only 0 present.");
237
237
  if (!(typeof Element > "u" || !(Element instanceof Object))) {
@@ -240,83 +240,83 @@ var JU = (
240
240
  var U = this.observations_;
241
241
  U.has(l) && (U.delete(l), U.size || this.controller_.removeObserver(this));
242
242
  }
243
- }, Z.prototype.disconnect = function() {
243
+ }, t.prototype.disconnect = function() {
244
244
  this.clearActive(), this.observations_.clear(), this.controller_.removeObserver(this);
245
- }, Z.prototype.gatherActive = function() {
245
+ }, t.prototype.gatherActive = function() {
246
246
  var l = this;
247
247
  this.clearActive(), this.observations_.forEach(function(U) {
248
248
  U.isActive() && l.activeObservations_.push(U);
249
249
  });
250
- }, Z.prototype.broadcastActive = function() {
250
+ }, t.prototype.broadcastActive = function() {
251
251
  if (this.hasActive()) {
252
252
  var l = this.callbackCtx_, U = this.activeObservations_.map(function(F) {
253
- return new GU(F.target, F.broadcastRect());
253
+ return new oU(F.target, F.broadcastRect());
254
254
  });
255
255
  this.callback_.call(l, U, l), this.clearActive();
256
256
  }
257
- }, Z.prototype.clearActive = function() {
257
+ }, t.prototype.clearActive = function() {
258
258
  this.activeObservations_.splice(0);
259
- }, Z.prototype.hasActive = function() {
259
+ }, t.prototype.hasActive = function() {
260
260
  return this.activeObservations_.length > 0;
261
- }, Z;
261
+ }, t;
262
262
  }()
263
263
  ), Pl = typeof WeakMap < "u" ? /* @__PURE__ */ new WeakMap() : new Dl(), wl = (
264
264
  /** @class */
265
265
  /* @__PURE__ */ function() {
266
- function Z(l) {
267
- if (!(this instanceof Z))
266
+ function t(l) {
267
+ if (!(this instanceof t))
268
268
  throw new TypeError("Cannot call a class as a function.");
269
269
  if (!arguments.length)
270
270
  throw new TypeError("1 argument required, but only 0 present.");
271
- var U = WU.getInstance(), F = new oU(l, U, this);
271
+ var U = cU.getInstance(), F = new SU(l, U, this);
272
272
  Pl.set(this, F);
273
273
  }
274
- return Z;
274
+ return t;
275
275
  }()
276
276
  );
277
277
  [
278
278
  "observe",
279
279
  "unobserve",
280
280
  "disconnect"
281
- ].forEach(function(Z) {
282
- wl.prototype[Z] = function() {
281
+ ].forEach(function(t) {
282
+ wl.prototype[t] = function() {
283
283
  var l;
284
- return (l = Pl.get(this))[Z].apply(l, arguments);
284
+ return (l = Pl.get(this))[t].apply(l, arguments);
285
285
  };
286
286
  });
287
- var SU = function() {
287
+ var XU = function() {
288
288
  return typeof ml.ResizeObserver < "u" ? ml.ResizeObserver : wl;
289
289
  }();
290
- function Ul(Z) {
291
- const l = M(0), U = M(0);
290
+ function Fl(t) {
291
+ const l = x(0), U = x(0);
292
292
  let F = null;
293
293
  const d = () => {
294
294
  F && (F.disconnect(), F = null);
295
295
  };
296
- return g(() => r(Z), () => {
296
+ return v(() => T(t), () => {
297
297
  d();
298
- const Q = r(Z);
298
+ const Q = T(t);
299
299
  if (!Q) return;
300
- F = new SU((a) => {
300
+ F = new XU((a) => {
301
301
  const n = a[0];
302
302
  n && (l.value = n.contentRect.width, U.value = n.contentRect.height);
303
303
  }), F.observe(Q);
304
304
  const V = Q.getBoundingClientRect();
305
305
  l.value = V.width, U.value = V.height;
306
- }, { immediate: !0 }), tU(d), {
306
+ }, { immediate: !0 }), QU(d), {
307
307
  width: El(l),
308
308
  height: El(U)
309
309
  };
310
310
  }
311
- const j = (Z, l) => {
312
- const U = Z.__vccOpts || Z;
311
+ const H = (t, l) => {
312
+ const U = t.__vccOpts || t;
313
313
  for (const [F, d] of l)
314
314
  U[F] = d;
315
315
  return U;
316
- }, XU = {
316
+ }, NU = {
317
317
  key: 0,
318
318
  class: "level"
319
- }, NU = {
319
+ }, pU = {
320
320
  __name: "AudioSlider",
321
321
  props: /* @__PURE__ */ Sl({
322
322
  min: { type: Number, default: 0 },
@@ -332,72 +332,72 @@ const j = (Z, l) => {
332
332
  valueModifiers: {}
333
333
  }),
334
334
  emits: ["update:value"],
335
- setup(Z) {
336
- ll((o) => ({
335
+ setup(t) {
336
+ Ul((G) => ({
337
337
  "083f3e45": c.value,
338
338
  d4833630: e.value,
339
- d6eaa016: B.value,
340
- 12894835: s.value,
341
- "3e9a6a44": u.value
339
+ d6eaa016: u.value,
340
+ 12894835: b.value,
341
+ "3e9a6a44": B.value
342
342
  }));
343
- const l = Z, U = A("root"), { width: F, height: d } = Ul(U), t = J(() => Math.min(F.value, d.value)), Q = J(() => Math.max(F.value, d.value)), V = J(() => F.value > d.value), a = J(() => V.value ? "h-slide" : "v-slide"), n = $(Z, "value"), R = J(() => t.value * 0.8), m = J(() => t.value * l.thumbLength * 0.8), e = J(() => (V.value ? m : R).value + "px"), c = J(() => (V.value ? R : m).value + "px"), s = J(() => t.value * 0.1 + "px"), u = J(() => (Q.value - m.value) * (n.value - l.min) / (l.max - l.min) + "px"), B = J(() => V.value ? "90deg" : "0deg"), X = M(!1), T = M(0), I = (o) => {
343
+ const l = t, U = f("root"), { width: F, height: d } = Fl(U), Z = J(() => Math.min(F.value, d.value)), Q = J(() => Math.max(F.value, d.value)), V = J(() => F.value > d.value), a = J(() => V.value ? "h-slide" : "v-slide"), n = $(t, "value"), R = J(() => Z.value * 0.8), m = J(() => Z.value * l.thumbLength * 0.8), e = J(() => (V.value ? m : R).value + "px"), c = J(() => (V.value ? R : m).value + "px"), b = J(() => Z.value * 0.1 + "px"), B = J(() => (Q.value - m.value) * (n.value - l.min) / (l.max - l.min) + "px"), u = J(() => V.value ? "90deg" : "0deg"), X = x(!1), E = x(0), z = (G) => {
344
344
  if (!U.value) return n.value;
345
- const z = U.value.getBoundingClientRect(), w = o.touches ? o.touches[0].clientX : o.clientX, i = o.touches ? o.touches[0].clientY : o.clientY;
346
- let S;
345
+ const M = U.value.getBoundingClientRect(), O = G.touches ? G.touches[0].clientX : G.clientX, i = G.touches ? G.touches[0].clientY : G.clientY;
346
+ let o;
347
347
  if (V.value) {
348
- const v = w - z.left - R.value / 2, O = z.width - R.value;
349
- S = Math.max(0, Math.min(1, v / O));
348
+ const I = O - M.left - R.value / 2, A = M.width - R.value;
349
+ o = Math.max(0, Math.min(1, I / A));
350
350
  } else {
351
- const v = z.bottom - i - R.value / 2, O = z.height - R.value;
352
- S = Math.max(0, Math.min(1, v / O));
351
+ const I = M.bottom - i - R.value / 2, A = M.height - R.value;
352
+ o = Math.max(0, Math.min(1, I / A));
353
353
  }
354
- const k = l.min + S * (l.max - l.min);
354
+ const k = l.min + o * (l.max - l.min);
355
355
  return l.step > 0 ? Math.round(k / l.step) * l.step : k;
356
- }, K = (o) => {
357
- o.preventDefault(), X.value = !0, T.value = n.value, n.value = I(o), U.value && U.value.setPointerCapture && U.value.setPointerCapture(o.pointerId), document.addEventListener("mousemove", H), document.addEventListener("mouseup", E);
358
- }, H = (o) => {
359
- X.value && (o.preventDefault(), n.value = I(o));
360
- }, E = (o) => {
356
+ }, D = (G) => {
357
+ G.preventDefault(), X.value = !0, E.value = n.value, n.value = z(G), U.value && U.value.setPointerCapture && U.value.setPointerCapture(G.pointerId), document.addEventListener("mousemove", g), document.addEventListener("mouseup", j);
358
+ }, g = (G) => {
359
+ X.value && (G.preventDefault(), n.value = z(G));
360
+ }, j = (G) => {
361
361
  if (X.value) {
362
- if (o.preventDefault(), X.value = !1, U.value && U.value.releasePointerCapture)
362
+ if (G.preventDefault(), X.value = !1, U.value && U.value.releasePointerCapture)
363
363
  try {
364
- U.value.releasePointerCapture(o.pointerId);
364
+ U.value.releasePointerCapture(G.pointerId);
365
365
  } catch {
366
366
  }
367
- document.removeEventListener("mousemove", H), document.removeEventListener("mouseup", E);
367
+ document.removeEventListener("mousemove", g), document.removeEventListener("mouseup", j);
368
368
  }
369
- }, G = (o) => {
370
- o.preventDefault(), o.touches.length === 1 && (X.value = !0, T.value = n.value, n.value = I(o), document.addEventListener("touchmove", L, { passive: !1 }), document.addEventListener("touchend", Y), document.addEventListener("touchcancel", Y));
371
- }, L = (o) => {
372
- X.value && (o.preventDefault(), o.touches.length === 1 && (n.value = I(o)));
373
- }, Y = (o) => {
374
- X.value && (o.preventDefault(), X.value = !1, document.removeEventListener("touchmove", L), document.removeEventListener("touchend", Y), document.removeEventListener("touchcancel", Y));
375
- }, q = (o) => Math.min(1, Math.max(0, l.level * 10 - o + 1));
376
- return (o, z) => (p(), y("div", {
377
- class: C(a.value),
369
+ }, Y = (G) => {
370
+ G.preventDefault(), G.touches.length === 1 && (X.value = !0, E.value = n.value, n.value = z(G), document.addEventListener("touchmove", p, { passive: !1 }), document.addEventListener("touchend", r), document.addEventListener("touchcancel", r));
371
+ }, p = (G) => {
372
+ X.value && (G.preventDefault(), G.touches.length === 1 && (n.value = z(G)));
373
+ }, r = (G) => {
374
+ X.value && (G.preventDefault(), X.value = !1, document.removeEventListener("touchmove", p), document.removeEventListener("touchend", r), document.removeEventListener("touchcancel", r));
375
+ }, q = (G) => Math.min(1, Math.max(0, l.level * 10 - G + 1));
376
+ return (G, M) => (N(), y("div", {
377
+ class: L(a.value),
378
378
  ref_key: "root",
379
379
  ref: U,
380
- onMousedown: K,
381
- onTouchstart: G,
380
+ onMousedown: D,
381
+ onTouchstart: Y,
382
382
  style: { userSelect: "none", touchAction: "none" }
383
383
  }, [
384
- z[0] || (z[0] = h("div", { class: "track" }, null, -1)),
385
- Z.showLevel ? (p(), y("div", XU, [
386
- (p(), y(nl, null, Xl(10, (w) => h("div", {
387
- class: C(["led", "led" + w])
384
+ M[0] || (M[0] = h("div", { class: "track" }, null, -1)),
385
+ t.showLevel ? (N(), y("div", NU, [
386
+ (N(), y(nl, null, Xl(10, (O) => h("div", {
387
+ class: L(["led", "led" + O])
388
388
  }, [
389
389
  h("div", {
390
390
  class: "on",
391
- style: gl({ opacity: q(w) })
391
+ style: gl({ opacity: q(O) })
392
392
  }, null, 4)
393
393
  ], 2)), 64))
394
- ])) : f("", !0),
394
+ ])) : _("", !0),
395
395
  h("div", {
396
- class: C(["thumb", { dragging: X.value, [Z.colour]: !0, [Z.style]: !0 }])
396
+ class: L(["thumb", { dragging: X.value, [t.colour]: !0, [t.style]: !0 }])
397
397
  }, null, 2)
398
398
  ], 34));
399
399
  }
400
- }, Wl = /* @__PURE__ */ j(NU, [["__scopeId", "data-v-ab2e7b69"]]), pU = {
400
+ }, Wl = /* @__PURE__ */ H(pU, [["__scopeId", "data-v-ab2e7b69"]]), yU = {
401
401
  __name: "TitleText",
402
402
  props: {
403
403
  align: {
@@ -405,24 +405,24 @@ const j = (Z, l) => {
405
405
  default: "left"
406
406
  }
407
407
  },
408
- setup(Z) {
409
- ll((V) => ({
408
+ setup(t) {
409
+ Ul((V) => ({
410
410
  "5fddb56d": Q.value
411
411
  }));
412
- const l = A("el"), { width: U, height: F } = Ul(l), d = J(() => Math.min(U.value, F.value)), t = J(() => U.value > F.value ? "h-text" : "v-text"), Q = J(() => d.value * 3 / 4 + "px");
413
- return (V, a) => (p(), y("div", {
412
+ const l = f("el"), { width: U, height: F } = Fl(l), d = J(() => Math.min(U.value, F.value)), Z = J(() => U.value > F.value ? "h-text" : "v-text"), Q = J(() => d.value * 3 / 4 + "px");
413
+ return (V, a) => (N(), y("div", {
414
414
  ref_key: "el",
415
415
  ref: l,
416
416
  class: "outer"
417
417
  }, [
418
418
  h("div", {
419
- class: C({ [t.value]: !0, [Z.align]: !0 })
419
+ class: L({ [Z.value]: !0, [t.align]: !0 })
420
420
  }, [
421
- tl(V.$slots, "default", {}, void 0, !0)
421
+ Ql(V.$slots, "default", {}, void 0, !0)
422
422
  ], 2)
423
423
  ], 512));
424
424
  }
425
- }, Ol = /* @__PURE__ */ j(pU, [["__scopeId", "data-v-3ce29e77"]]), yU = {
425
+ }, Ol = /* @__PURE__ */ H(yU, [["__scopeId", "data-v-3ce29e77"]]), YU = {
426
426
  __name: "TriState",
427
427
  props: {
428
428
  mute: { default: !1 },
@@ -431,38 +431,38 @@ const j = (Z, l) => {
431
431
  soloModifiers: {}
432
432
  },
433
433
  emits: ["update:mute", "update:solo"],
434
- setup(Z) {
435
- const l = $(Z, "mute"), U = $(Z, "solo"), F = A("outer"), { width: d, height: t } = Ul(F), Q = J(() => d.value > t.value * 1.9);
434
+ setup(t) {
435
+ const l = $(t, "mute"), U = $(t, "solo"), F = f("outer"), { width: d, height: Z } = Fl(F), Q = J(() => d.value > Z.value * 1.9);
436
436
  function V() {
437
437
  l.value = !l.value, U.value = !1;
438
438
  }
439
439
  function a() {
440
440
  U.value = !U.value, l.value = !1;
441
441
  }
442
- return (n, R) => (p(), y("div", {
442
+ return (n, R) => (N(), y("div", {
443
443
  class: "outer",
444
444
  ref_key: "outer",
445
445
  ref: F
446
446
  }, [
447
447
  h("div", {
448
- class: C(["solo", { on: U.value }]),
448
+ class: L(["solo", { on: U.value }]),
449
449
  onClick: a
450
450
  }, null, 2),
451
451
  h("div", {
452
452
  class: "s-label",
453
453
  onClick: a
454
- }, D(Q.value ? "SOLO" : "S"), 1),
454
+ }, K(Q.value ? "SOLO" : "S"), 1),
455
455
  h("div", {
456
- class: C(["mute", { on: l.value }]),
456
+ class: L(["mute", { on: l.value }]),
457
457
  onClick: V
458
458
  }, null, 2),
459
459
  h("div", {
460
460
  class: "m-label",
461
461
  onClick: V
462
- }, D(Q.value ? "MUTE" : "M"), 1)
462
+ }, K(Q.value ? "MUTE" : "M"), 1)
463
463
  ], 512));
464
464
  }
465
- }, YU = /* @__PURE__ */ j(yU, [["__scopeId", "data-v-143eade0"]]), ol = {
465
+ }, EU = /* @__PURE__ */ H(YU, [["__scopeId", "data-v-5eda54eb"]]), ol = {
466
466
  // Enable development UI features (animations, random data, etc.)
467
467
  enabled: !1,
468
468
  // Specific feature flags
@@ -474,7 +474,7 @@ const j = (Z, l) => {
474
474
  // Enable other debug/dev features as needed
475
475
  debugMode: !1
476
476
  }
477
- }, KF = () => ol.enabled, Al = (Z) => ol.enabled && ol.features[Z], Fl = sl("audioState", {
477
+ }, KF = () => ol.enabled, Al = (t) => ol.enabled && ol.features[t], dl = sl("audioState", {
478
478
  state: () => ({
479
479
  // Playback state
480
480
  isPlaying: !1,
@@ -502,81 +502,81 @@ const j = (Z, l) => {
502
502
  }),
503
503
  getters: {
504
504
  // Format current time as MM:SS
505
- formattedTime: (Z) => {
506
- const l = Math.floor(Z.currentTime / 60), U = Math.floor(Z.currentTime % 60);
505
+ formattedTime: (t) => {
506
+ const l = Math.floor(t.currentTime / 60), U = Math.floor(t.currentTime % 60);
507
507
  return `${l}:${U.toString().padStart(2, "0")}`;
508
508
  },
509
509
  // Get volume for a specific part
510
- getPartVolume: (Z) => (l) => Z.partVolumes[l] ?? 0.75,
510
+ getPartVolume: (t) => (l) => t.partVolumes[l] ?? 0.75,
511
511
  // Check if part is muted
512
- isPartMuted: (Z) => (l) => Z.partMuted[l] ?? !1,
512
+ isPartMuted: (t) => (l) => t.partMuted[l] ?? !1,
513
513
  // Check if part is solo
514
- isPartSolo: (Z) => (l) => Z.partSolo[l] ?? !1,
514
+ isPartSolo: (t) => (l) => t.partSolo[l] ?? !1,
515
515
  // Check if any part has solo enabled (global solo state)
516
- isAnySolo: (Z) => Object.values(Z.partSolo).some((l) => l === !0),
516
+ isAnySolo: (t) => Object.values(t.partSolo).some((l) => l === !0),
517
517
  // Current musical position as string
518
- currentPosition: (Z) => {
519
- let l = `${Z.currentBar}.${Z.currentBeat}`;
520
- return Z.currentRepeat > 0 && (l += ` (R${Z.currentRepeat})`), l;
518
+ currentPosition: (t) => {
519
+ let l = `${t.currentBar}.${t.currentBeat}`;
520
+ return t.currentRepeat > 0 && (l += ` (R${t.currentRepeat})`), l;
521
521
  }
522
522
  },
523
523
  actions: {
524
524
  // Playback state updates
525
- setPlaybackState(Z) {
526
- this.isPlaying = Z;
525
+ setPlaybackState(t) {
526
+ this.isPlaying = t;
527
527
  },
528
- setCurrentTime(Z) {
529
- this.currentTime = Z;
528
+ setCurrentTime(t) {
529
+ this.currentTime = t;
530
530
  },
531
- setPlaybackSpeed(Z) {
532
- this.playbackSpeed = Z;
531
+ setPlaybackSpeed(t) {
532
+ this.playbackSpeed = t;
533
533
  },
534
534
  // Musical position updates
535
- setCurrentBar(Z, l = 1, U = 0) {
536
- typeof Z == "number" && (this.currentBar = Z), typeof l == "number" && (this.currentBeat = l), typeof U == "number" && (this.currentRepeat = U);
535
+ setCurrentBar(t, l = 1, U = 0) {
536
+ typeof t == "number" && (this.currentBar = t), typeof l == "number" && (this.currentBeat = l), typeof U == "number" && (this.currentRepeat = U);
537
537
  },
538
538
  // Volume controls
539
- setMasterVolume(Z) {
540
- this.masterVolume = Math.max(0, Math.min(1, Z));
539
+ setMasterVolume(t) {
540
+ this.masterVolume = Math.max(0, Math.min(1, t));
541
541
  },
542
- setMetronomeVolume(Z) {
543
- this.metronomeVolume = Math.max(0, Math.min(1, Z));
542
+ setMetronomeVolume(t) {
543
+ this.metronomeVolume = Math.max(0, Math.min(1, t));
544
544
  },
545
- setPartVolume(Z, l) {
546
- this.partVolumes[Z] = Math.max(0, Math.min(1, l));
545
+ setPartVolume(t, l) {
546
+ this.partVolumes[t] = Math.max(0, Math.min(1, l));
547
547
  },
548
- setPartMuted(Z, l) {
549
- this.partMuted[Z] = l;
548
+ setPartMuted(t, l) {
549
+ this.partMuted[t] = l;
550
550
  },
551
- setPartSolo(Z, l) {
552
- this.partSolo[Z] = l;
551
+ setPartSolo(t, l) {
552
+ this.partSolo[t] = l;
553
553
  },
554
554
  // Transport features
555
- setLeadInActive(Z, l = 1) {
556
- this.isLeadInActive = Z, this.leadInBars = l;
555
+ setLeadInActive(t, l = 1) {
556
+ this.isLeadInActive = t, this.leadInBars = l;
557
557
  },
558
- setStartingNotesActive(Z) {
559
- this.isStartingNotesActive = Z;
558
+ setStartingNotesActive(t) {
559
+ this.isStartingNotesActive = t;
560
560
  },
561
561
  // Feature toggles
562
- setMetronomeEnabled(Z) {
563
- this.metronomeEnabled = Z;
562
+ setMetronomeEnabled(t) {
563
+ this.metronomeEnabled = t;
564
564
  },
565
- setLeadInEnabled(Z) {
566
- this.leadInEnabled = Z;
565
+ setLeadInEnabled(t) {
566
+ this.leadInEnabled = t;
567
567
  },
568
568
  // Initialize part states
569
- initializeParts(Z) {
570
- this.partVolumes = {}, this.partMuted = {}, this.partSolo = {}, Z.forEach((l) => {
569
+ initializeParts(t) {
570
+ this.partVolumes = {}, this.partMuted = {}, this.partSolo = {}, t.forEach((l) => {
571
571
  this.partVolumes[l.name] = l.volume || 0.75, this.partMuted[l.name] = !1, this.partSolo[l.name] = !1;
572
572
  });
573
573
  },
574
574
  // Initialization state (for blur overlay)
575
- setLoaded(Z) {
576
- this.isLoaded = Z;
575
+ setLoaded(t) {
576
+ this.isLoaded = t;
577
577
  }
578
578
  }
579
- }), Ql = sl("musicData", {
579
+ }), ll = sl("musicData", {
580
580
  state: () => ({
581
581
  // Musical structure
582
582
  beats: [],
@@ -592,30 +592,30 @@ const j = (Z, l) => {
592
592
  }),
593
593
  getters: {
594
594
  // Get practice mark letters as array
595
- practiceMarkLetters: (Z) => Object.keys(Z.practiceMarks).sort(),
595
+ practiceMarkLetters: (t) => Object.keys(t.practiceMarks).sort(),
596
596
  // Get bar number for practice mark
597
- getBarForMark: (Z) => (l) => Z.practiceMarks[l],
597
+ getBarForMark: (t) => (l) => t.practiceMarks[l],
598
598
  // Get all unique bar numbers
599
- allBars: (Z) => {
599
+ allBars: (t) => {
600
600
  const l = /* @__PURE__ */ new Set();
601
- return Z.beats.forEach((U) => {
601
+ return t.beats.forEach((U) => {
602
602
  U.beat === 1 && l.add(U.bar);
603
603
  }), Array.from(l).sort((U, F) => U - F);
604
604
  },
605
605
  // Check if a bar has repeats
606
- hasRepeats: (Z) => (l) => Z.beats.some((U) => U.bar === l && U.repeat > 0),
606
+ hasRepeats: (t) => (l) => t.beats.some((U) => U.bar === l && U.repeat > 0),
607
607
  // Get the number of repeats for a specific bar
608
- getRepeatCountForBar: (Z) => (l) => {
608
+ getRepeatCountForBar: (t) => (l) => {
609
609
  const U = /* @__PURE__ */ new Set();
610
- return Z.beats.forEach((F) => {
610
+ return t.beats.forEach((F) => {
611
611
  F.bar === l && U.add(F.repeat);
612
612
  }), U.size;
613
613
  }
614
614
  },
615
615
  actions: {
616
616
  // Load musical data
617
- loadMusicData(Z) {
618
- this.title = Z.title || "Untitled", this.beats = Z.beats || [], this.practiceMarks = Z.practiceMarks || Z.marks || {}, this.parts = (Z.parts || []).map((l) => ({
617
+ loadMusicData(t) {
618
+ this.title = t.title || "Untitled", this.beats = t.beats || [], this.practiceMarks = t.practiceMarks || t.marks || {}, this.parts = (t.parts || []).map((l) => ({
619
619
  ...l,
620
620
  solo: l.solo || !1,
621
621
  mute: l.mute || !1
@@ -623,38 +623,38 @@ const j = (Z, l) => {
623
623
  },
624
624
  // Calculate total duration from beats
625
625
  calculateDuration() {
626
- this.beats.length > 0 && (this.totalDuration = Math.max(...this.beats.map((Z) => Z.time)));
626
+ this.beats.length > 0 && (this.totalDuration = Math.max(...this.beats.map((t) => t.time)));
627
627
  },
628
628
  // Find the highest bar number
629
629
  calculateMaxBar() {
630
- this.beats.length > 0 && (this.maxBar = Math.max(...this.beats.map((Z) => Z.bar)));
630
+ this.beats.length > 0 && (this.maxBar = Math.max(...this.beats.map((t) => t.bar)));
631
631
  },
632
632
  // Extract time signature from first beat
633
633
  extractTimeSignature() {
634
634
  this.beats.length > 0 && this.beats[0].timeSig && (this.timeSignature = this.beats[0].timeSig), this.beats.length > 0 && this.beats[0].tempo && (this.baseTempo = this.beats[0].tempo);
635
635
  },
636
636
  // Update practice marks
637
- setPracticeMark(Z, l) {
638
- this.practiceMarks[Z] = l;
637
+ setPracticeMark(t, l) {
638
+ this.practiceMarks[t] = l;
639
639
  },
640
- removePracticeMark(Z) {
641
- delete this.practiceMarks[Z];
640
+ removePracticeMark(t) {
641
+ delete this.practiceMarks[t];
642
642
  },
643
643
  // Update beats data (for when MIDI parser provides new beat information)
644
- updateBeats(Z) {
645
- console.log("Updating beats in music data store"), this.beats = Z, this.calculateDuration(), this.calculateMaxBar(), this.extractTimeSignature();
644
+ updateBeats(t) {
645
+ console.log("Updating beats in music data store"), this.beats = t, this.calculateDuration(), this.calculateMaxBar(), this.extractTimeSignature();
646
646
  },
647
647
  // Update total duration (for when audio engine provides actual duration)
648
- setTotalDuration(Z) {
649
- console.log("Setting total duration in music data store to:", Z), this.totalDuration = Z;
648
+ setTotalDuration(t) {
649
+ console.log("Setting total duration in music data store to:", t), this.totalDuration = t;
650
650
  },
651
651
  // Validate bar number
652
- isValidBar(Z, l = 0) {
653
- return this.beats.some((U) => U.bar === Z && U.repeat === l);
652
+ isValidBar(t, l = 0) {
653
+ return this.beats.some((U) => U.bar === t && U.repeat === l);
654
654
  },
655
655
  // Update parts (for when audio engine discovers parts from MIDI)
656
- setParts(Z) {
657
- this.parts = Z.map((l) => ({
656
+ setParts(t) {
657
+ this.parts = t.map((l) => ({
658
658
  name: l.name,
659
659
  volume: l.volume || 0.75,
660
660
  solo: l.solo || !1,
@@ -662,7 +662,7 @@ const j = (Z, l) => {
662
662
  }));
663
663
  }
664
664
  }
665
- }), EU = sl("playbackState", {
665
+ }), fl = sl("playbackState", {
666
666
  state: () => ({
667
667
  // Transport state
668
668
  transportState: "stopped",
@@ -687,24 +687,36 @@ const j = (Z, l) => {
687
687
  showNavigationControls: !0,
688
688
  // Last positions for convenience
689
689
  lastBarPosition: 1,
690
- lastPracticeMarkUsed: null
690
+ lastPracticeMarkUsed: null,
691
+ // Navigation history
692
+ lastPlayStartBar: null,
693
+ lastPlayStartRepeat: null,
694
+ lastPlayStartTime: null,
695
+ lastNavigationAction: null,
696
+ // 'pause' | 'play' | 'manual' | null
697
+ // Fixed navigation points (computed once on load)
698
+ fixedNavigationPoints: [],
699
+ // Combined navigation points (recomputed when play start changes)
700
+ navigationPoints: []
691
701
  }),
692
702
  getters: {
693
703
  // Check if currently playing
694
- isPlaying: (Z) => Z.transportState === "playing",
704
+ isPlaying: (t) => t.transportState === "playing",
695
705
  // Check if paused
696
- isPaused: (Z) => Z.transportState === "paused",
706
+ isPaused: (t) => t.transportState === "paused",
697
707
  // Check if stopped
698
- isStopped: (Z) => Z.transportState === "stopped",
708
+ isStopped: (t) => t.transportState === "stopped",
699
709
  // Check if loop is configured
700
- isLoopConfigured: (Z) => Z.loopEnabled && Z.loopStart && Z.loopEnd && Z.loopEnd > Z.loopStart,
710
+ isLoopConfigured: (t) => t.loopEnabled && t.loopStart && t.loopEnd && t.loopEnd > t.loopStart,
701
711
  // Get loop range as string
702
- loopRange: (Z) => !Z.loopEnabled || !Z.loopStart || !Z.loopEnd ? null : `${Z.loopStart}-${Z.loopEnd}`
712
+ loopRange: (t) => !t.loopEnabled || !t.loopStart || !t.loopEnd ? null : `${t.loopStart}-${t.loopEnd}`,
713
+ // Get navigation points list
714
+ getNavigationPoints: (t) => t.navigationPoints
703
715
  },
704
716
  actions: {
705
717
  // Transport controls
706
- setTransportState(Z) {
707
- ["stopped", "playing", "paused"].includes(Z) && (this.transportState = Z);
718
+ setTransportState(t) {
719
+ ["stopped", "playing", "paused"].includes(t) && (this.transportState = t);
708
720
  },
709
721
  play() {
710
722
  this.setTransportState("playing");
@@ -716,55 +728,98 @@ const j = (Z, l) => {
716
728
  this.setTransportState("stopped");
717
729
  },
718
730
  // Navigation settings
719
- setAutoPlay(Z) {
720
- this.autoPlay = Z;
731
+ setAutoPlay(t) {
732
+ this.autoPlay = t;
721
733
  },
722
- setLoop(Z, l = null, U = null) {
723
- this.loopEnabled = Z, l !== null && (this.loopStart = l), U !== null && (this.loopEnd = U);
734
+ setLoop(t, l = null, U = null) {
735
+ this.loopEnabled = t, l !== null && (this.loopStart = l), U !== null && (this.loopEnd = U);
724
736
  },
725
- setLoopStart(Z) {
726
- this.loopStart = Z, this.loopEnd && this.loopEnd <= Z && (this.loopEnd = Z + 4);
737
+ setLoopStart(t) {
738
+ this.loopStart = t, this.loopEnd && this.loopEnd <= t && (this.loopEnd = t + 4);
727
739
  },
728
- setLoopEnd(Z) {
729
- this.loopEnd = Z, this.loopStart && this.loopStart >= Z && (this.loopStart = Math.max(1, Z - 4));
740
+ setLoopEnd(t) {
741
+ this.loopEnd = t, this.loopStart && this.loopStart >= t && (this.loopStart = Math.max(1, t - 4));
730
742
  },
731
743
  // Lead-in settings
732
- setLeadInEnabled(Z) {
733
- this.leadInEnabled = Z;
744
+ setLeadInEnabled(t) {
745
+ this.leadInEnabled = t;
734
746
  },
735
- setLeadInBars(Z) {
736
- this.leadInBars = Math.max(1, Math.min(4, Z));
747
+ setLeadInBars(t) {
748
+ this.leadInBars = Math.max(1, Math.min(4, t));
737
749
  },
738
750
  // Starting notes settings
739
- setStartingNotesEnabled(Z) {
740
- this.startingNotesEnabled = Z;
751
+ setStartingNotesEnabled(t) {
752
+ this.startingNotesEnabled = t;
741
753
  },
742
- setStartingNotesSequential(Z) {
743
- this.startingNotesSequential = Z;
754
+ setStartingNotesSequential(t) {
755
+ this.startingNotesSequential = t;
744
756
  },
745
757
  // Metronome settings
746
- setMetronomeEnabled(Z) {
747
- this.metronomeEnabled = Z;
758
+ setMetronomeEnabled(t) {
759
+ this.metronomeEnabled = t;
748
760
  },
749
- setMetronomeVolume(Z) {
750
- this.metronomeVolume = Math.max(0, Math.min(1, Z));
761
+ setMetronomeVolume(t) {
762
+ this.metronomeVolume = Math.max(0, Math.min(1, t));
751
763
  },
752
764
  // UI visibility controls
753
- setTransportControlsVisible(Z) {
754
- this.showTransportControls = Z;
765
+ setTransportControlsVisible(t) {
766
+ this.showTransportControls = t;
755
767
  },
756
- setPartControlsVisible(Z) {
757
- this.showPartControls = Z;
768
+ setPartControlsVisible(t) {
769
+ this.showPartControls = t;
758
770
  },
759
- setNavigationControlsVisible(Z) {
760
- this.showNavigationControls = Z;
771
+ setNavigationControlsVisible(t) {
772
+ this.showNavigationControls = t;
761
773
  },
762
774
  // Position tracking
763
- updateLastBarPosition(Z) {
764
- this.lastBarPosition = Z;
775
+ updateLastBarPosition(t) {
776
+ this.lastBarPosition = t;
777
+ },
778
+ updateLastPracticeMarkUsed(t) {
779
+ this.lastPracticeMarkUsed = t;
780
+ },
781
+ // Navigation points management
782
+ buildFixedNavigationPoints() {
783
+ const t = [], l = ll();
784
+ t.push({ time: 0, bar: 1, repeat: 1, label: "Start" });
785
+ const U = l.beats.filter((F) => F.beat === 1);
786
+ for (const [F, d] of Object.entries(l.practiceMarks))
787
+ U.filter((Z) => Z.bar === d).forEach((Z) => {
788
+ t.push({
789
+ time: Z.time,
790
+ bar: Z.bar,
791
+ repeat: Z.repeat,
792
+ label: `Mark ${F}`
793
+ });
794
+ });
795
+ if (l.beats.length > 0) {
796
+ const F = Math.max(...l.beats.map((d) => d.time));
797
+ t.push({ time: F, label: "End" });
798
+ }
799
+ this.fixedNavigationPoints = t.sort((F, d) => F.time - d.time), this.navigationPoints = [...this.fixedNavigationPoints];
800
+ },
801
+ rebuildNavigationPoints() {
802
+ setTimeout(() => {
803
+ const t = ll(), l = [...this.fixedNavigationPoints];
804
+ this.lastPlayStartBar !== null && t.beats.filter((d) => d.beat === 1 && d.bar === this.lastPlayStartBar).forEach((d) => {
805
+ l.push({
806
+ time: d.time,
807
+ bar: d.bar,
808
+ repeat: d.repeat,
809
+ label: "Last Play Start"
810
+ });
811
+ });
812
+ const U = l.sort((F, d) => F.time - d.time);
813
+ this.navigationPoints = U.filter(
814
+ (F, d, Z) => d === 0 || F.time !== Z[d - 1].time
815
+ );
816
+ }, 50);
817
+ },
818
+ setLastPlayStart(t, l, U) {
819
+ this.lastPlayStartBar = t, this.lastPlayStartRepeat = l, this.lastPlayStartTime = U, this.rebuildNavigationPoints();
765
820
  },
766
- updateLastPracticeMarkUsed(Z) {
767
- this.lastPracticeMarkUsed = Z;
821
+ setNavigationAction(t) {
822
+ this.lastNavigationAction = t;
768
823
  },
769
824
  // Reset to defaults
770
825
  resetToDefaults() {
@@ -772,34 +827,34 @@ const j = (Z, l) => {
772
827
  }
773
828
  }
774
829
  });
775
- function fl(Z) {
776
- return { all: Z = Z || /* @__PURE__ */ new Map(), on: function(l, U) {
777
- var F = Z.get(l);
778
- F ? F.push(U) : Z.set(l, [U]);
830
+ function _l(t) {
831
+ return { all: t = t || /* @__PURE__ */ new Map(), on: function(l, U) {
832
+ var F = t.get(l);
833
+ F ? F.push(U) : t.set(l, [U]);
779
834
  }, off: function(l, U) {
780
- var F = Z.get(l);
781
- F && (U ? F.splice(F.indexOf(U) >>> 0, 1) : Z.set(l, []));
835
+ var F = t.get(l);
836
+ F && (U ? F.splice(F.indexOf(U) >>> 0, 1) : t.set(l, []));
782
837
  }, emit: function(l, U) {
783
- var F = Z.get(l);
838
+ var F = t.get(l);
784
839
  F && F.slice().map(function(d) {
785
840
  d(U);
786
- }), (F = Z.get("*")) && F.slice().map(function(d) {
841
+ }), (F = t.get("*")) && F.slice().map(function(d) {
787
842
  d(l, U);
788
843
  });
789
844
  } };
790
845
  }
791
- function pl(Z) {
792
- return { all: Z = Z || /* @__PURE__ */ new Map(), on: function(l, U) {
793
- var F = Z.get(l);
794
- F ? F.push(U) : Z.set(l, [U]);
846
+ function pl(t) {
847
+ return { all: t = t || /* @__PURE__ */ new Map(), on: function(l, U) {
848
+ var F = t.get(l);
849
+ F ? F.push(U) : t.set(l, [U]);
795
850
  }, off: function(l, U) {
796
- var F = Z.get(l);
797
- F && (U ? F.splice(F.indexOf(U) >>> 0, 1) : Z.set(l, []));
851
+ var F = t.get(l);
852
+ F && (U ? F.splice(F.indexOf(U) >>> 0, 1) : t.set(l, []));
798
853
  }, emit: function(l, U) {
799
- var F = Z.get(l);
854
+ var F = t.get(l);
800
855
  F && F.slice().map(function(d) {
801
856
  d(U);
802
- }), (F = Z.get("*")) && F.slice().map(function(d) {
857
+ }), (F = t.get("*")) && F.slice().map(function(d) {
803
858
  d(l, U);
804
859
  });
805
860
  } };
@@ -891,14 +946,14 @@ class Bl {
891
946
  console.warn("Metronome buffer not available");
892
947
  return;
893
948
  }
894
- const t = this.audioContext.createBufferSource();
895
- t.buffer = d;
949
+ const Z = this.audioContext.createBufferSource();
950
+ Z.buffer = d;
896
951
  const Q = this.audioContext.createGain();
897
- Q.gain.value = F, t.connect(Q);
952
+ Q.gain.value = F, Z.connect(Q);
898
953
  const V = this.getMetronomeOutput();
899
954
  V ? Q.connect(V) : Q.connect(this.audioContext.destination);
900
955
  const a = Math.max(l, this.audioContext.currentTime);
901
- t.start(a);
956
+ Z.start(a);
902
957
  } catch (d) {
903
958
  console.warn("Buffer metronome playback failed:", d);
904
959
  }
@@ -933,11 +988,11 @@ class Bl {
933
988
  ]), [F, d] = await Promise.all([
934
989
  l.arrayBuffer(),
935
990
  U.arrayBuffer()
936
- ]), [t, Q] = await Promise.all([
991
+ ]), [Z, Q] = await Promise.all([
937
992
  this.audioContext.decodeAudioData(F),
938
993
  this.audioContext.decodeAudioData(d)
939
994
  ]);
940
- this.regularTickBuffer = t, this.accentTickBuffer = Q;
995
+ this.regularTickBuffer = Z, this.accentTickBuffer = Q;
941
996
  return;
942
997
  }
943
998
  } catch (l) {
@@ -1030,15 +1085,15 @@ class il {
1030
1085
  */
1031
1086
  playNote(l, U, F, d) {
1032
1087
  this._validateActive();
1033
- const t = this.engine.audioContext.currentTime, Q = `${this.partId}_${l}_${U}_${Date.now()}`;
1088
+ const Z = this.engine.audioContext.currentTime, Q = `${this.partId}_${l}_${U}_${Date.now()}`;
1034
1089
  let V = l, a = d;
1035
- if (l < t) {
1036
- const c = t - l;
1037
- V = t, a = Math.max(0, d - c);
1090
+ if (l < Z) {
1091
+ const c = Z - l;
1092
+ V = Z, a = Math.max(0, d - c);
1038
1093
  }
1039
1094
  if (a <= 0)
1040
1095
  return Q;
1041
- const n = Math.max(0, (V - t) * 1e3), R = setTimeout(() => {
1096
+ const n = Math.max(0, (V - Z) * 1e3), R = setTimeout(() => {
1042
1097
  this.noteOn(U, F), this.scheduledEvents.delete(`${Q}_on`);
1043
1098
  }, n), m = n + a * 1e3, e = setTimeout(() => {
1044
1099
  this.noteOff(U), this.scheduledEvents.delete(`${Q}_off`);
@@ -1056,9 +1111,9 @@ class il {
1056
1111
  */
1057
1112
  playPreviewNote(l, U = {}) {
1058
1113
  this._validateActive();
1059
- const F = U.startTime ?? this.engine.audioContext.currentTime + 0.01, d = U.duration ?? 0.5, t = U.velocity ?? 100;
1114
+ const F = U.startTime ?? this.engine.audioContext.currentTime + 0.01, d = U.duration ?? 0.5, Z = U.velocity ?? 100;
1060
1115
  let Q = null;
1061
- U.instrument !== void 0 && (Q = this.getInstrument(), this.setInstrument(U.instrument)), this.playNote(F, l, t, d), Q !== null && setTimeout(() => {
1116
+ U.instrument !== void 0 && (Q = this.getInstrument(), this.setInstrument(U.instrument)), this.playNote(F, l, Z, d), Q !== null && setTimeout(() => {
1062
1117
  this.isDestroyed || this.setInstrument(Q);
1063
1118
  }, (d + 0.1) * 1e3);
1064
1119
  }
@@ -1154,7 +1209,7 @@ class il {
1154
1209
  throw new Error("AudioEngine is not initialized");
1155
1210
  }
1156
1211
  }
1157
- const _l = {
1212
+ const $l = {
1158
1213
  // Piano family (0-7)
1159
1214
  piano: 0,
1160
1215
  bright_piano: 1,
@@ -1304,8 +1359,8 @@ const _l = {
1304
1359
  helicopter: 125,
1305
1360
  applause: 126,
1306
1361
  gunshot: 127
1307
- }, rU = Object.entries(_l).reduce((Z, [l, U]) => (Z[U] = l, Z), {});
1308
- class $l {
1362
+ }, rU = Object.entries($l).reduce((t, [l, U]) => (t[U] = l, t), {});
1363
+ class lU {
1309
1364
  /**
1310
1365
  * Map common instrument names to MIDI program numbers
1311
1366
  * @param {string|number} instrument - Instrument name or program number
@@ -1313,7 +1368,7 @@ class $l {
1313
1368
  */
1314
1369
  static getInstrumentProgram(l) {
1315
1370
  if (typeof l == "number") return l;
1316
- const U = _l[l.toLowerCase()];
1371
+ const U = $l[l.toLowerCase()];
1317
1372
  return U !== void 0 ? U : 0;
1318
1373
  }
1319
1374
  /**
@@ -1366,7 +1421,7 @@ class LU extends il {
1366
1421
  }
1367
1422
  async setInstrument(l) {
1368
1423
  this._validateActive();
1369
- const U = $l.getInstrumentProgram(l);
1424
+ const U = lU.getInstrumentProgram(l);
1370
1425
  this.currentInstrument = l;
1371
1426
  const F = this.engine._getSynthesizer();
1372
1427
  F && F.programChange ? F.programChange(this.midiChannel, U) : console.warn("Cannot set instrument: synthesizer not available or no programChange method");
@@ -1406,7 +1461,7 @@ class LU extends il {
1406
1461
  */
1407
1462
  playNote(l, U, F, d) {
1408
1463
  this._validateActive();
1409
- const t = `${this.partId}_${l}_${U}_${Date.now()}`, Q = this.engine._getSynthesizer();
1464
+ const Z = `${this.partId}_${l}_${U}_${Date.now()}`, Q = this.engine._getSynthesizer();
1410
1465
  if (Q && Q.post) {
1411
1466
  const V = Math.round(F * this.currentVolume);
1412
1467
  Q.post({
@@ -1436,7 +1491,7 @@ class LU extends il {
1436
1491
  });
1437
1492
  } else
1438
1493
  return super.playNote(l, U, F, d);
1439
- return t;
1494
+ return Z;
1440
1495
  }
1441
1496
  /**
1442
1497
  * Override allNotesOff to use SpessaSynth messaging system
@@ -1607,11 +1662,11 @@ class xU extends Bl {
1607
1662
  const F = U.headers.get("content-length"), d = F ? parseInt(F, 10) : null;
1608
1663
  if (!d || !U.body)
1609
1664
  return await U.arrayBuffer();
1610
- const t = U.body.getReader();
1665
+ const Z = U.body.getReader();
1611
1666
  let Q = 0;
1612
1667
  const V = [];
1613
1668
  for (; ; ) {
1614
- const { done: R, value: m } = await t.read();
1669
+ const { done: R, value: m } = await Z.read();
1615
1670
  if (R) break;
1616
1671
  V.push(m), Q += m.length;
1617
1672
  const e = Q / d, c = Math.round(e * 100);
@@ -1669,11 +1724,11 @@ class xU extends Bl {
1669
1724
  */
1670
1725
  async playMetronomeTick(l, U, F) {
1671
1726
  try {
1672
- const d = this.getMetronomeChannel(), t = this._getSynthesizer();
1673
- if (!d || !t)
1727
+ const d = this.getMetronomeChannel(), Z = this._getSynthesizer();
1728
+ if (!d || !Z)
1674
1729
  return super.playMetronomeTick(l, U, F);
1675
1730
  const Q = 15, V = U ? 86 : 60, a = Math.round(Math.min(127, Math.max(0, F * (U ? 127 : 100)))), n = this.audioContext.currentTime, R = Math.max(l, n), m = R - n;
1676
- t.post ? (t.post({
1731
+ Z.post ? (Z.post({
1677
1732
  channelNumber: Q,
1678
1733
  type: "midiMessage",
1679
1734
  data: {
@@ -1685,7 +1740,7 @@ class xU extends Bl {
1685
1740
  // Sample-accurate metronome timing!
1686
1741
  }
1687
1742
  }
1688
- }), t.post({
1743
+ }), Z.post({
1689
1744
  channelNumber: Q,
1690
1745
  type: "midiMessage",
1691
1746
  data: {
@@ -1697,11 +1752,11 @@ class xU extends Bl {
1697
1752
  // Precise tick duration!
1698
1753
  }
1699
1754
  }
1700
- })) : m <= 0.01 ? (t.noteOn && t.noteOn(Q, V, a), setTimeout(() => {
1701
- t.noteOff && t.noteOff(Q, V);
1755
+ })) : m <= 0.01 ? (Z.noteOn && Z.noteOn(Q, V, a), setTimeout(() => {
1756
+ Z.noteOff && Z.noteOff(Q, V);
1702
1757
  }, 100)) : setTimeout(() => {
1703
- t.noteOn && t.noteOn(Q, V, a), setTimeout(() => {
1704
- t.noteOff && t.noteOff(Q, V);
1758
+ Z.noteOn && Z.noteOn(Q, V, a), setTimeout(() => {
1759
+ Z.noteOff && Z.noteOff(Q, V);
1705
1760
  }, 100);
1706
1761
  }, m * 1e3);
1707
1762
  } catch (d) {
@@ -1759,13 +1814,13 @@ class MU extends il {
1759
1814
  console.warn(`No samples available for instrument ${this.currentInstrument}`);
1760
1815
  return;
1761
1816
  }
1762
- const d = this.engine._midiNoteToName(l), t = F.get(d);
1763
- if (!t) {
1817
+ const d = this.engine._midiNoteToName(l), Z = F.get(d);
1818
+ if (!Z) {
1764
1819
  console.warn(`No sample found for note ${d} (pitch ${l})`);
1765
1820
  return;
1766
1821
  }
1767
1822
  const Q = this.engine.audioContext.createBufferSource();
1768
- Q.buffer = t, Q.loop = t._shouldLoop || !1, Q.loop && (Q.loopStart = 0.4, Q.loopEnd = t.duration);
1823
+ Q.buffer = Z, Q.loop = Z._shouldLoop || !1, Q.loop && (Q.loopStart = 0.4, Q.loopEnd = Z.duration);
1769
1824
  const V = this.engine.audioContext.createGain(), a = U / 127;
1770
1825
  V.gain.value = a * this.currentVolume, Q.connect(V), V.connect(this.outputGain), this.activeSources.has(l) || this.activeSources.set(l, /* @__PURE__ */ new Set()), this.activeSources.get(l).add(Q), Q.onended = () => {
1771
1826
  V.disconnect();
@@ -1785,8 +1840,8 @@ class MU extends il {
1785
1840
  if (F.loop)
1786
1841
  F.stop();
1787
1842
  else {
1788
- const d = this.engine.audioContext.currentTime, t = F._velocityGain;
1789
- t && t.gain.linearRampToValueAtTime(0, d + 0.05), F.stop(d + 0.05);
1843
+ const d = this.engine.audioContext.currentTime, Z = F._velocityGain;
1844
+ Z && Z.gain.linearRampToValueAtTime(0, d + 0.05), F.stop(d + 0.05);
1790
1845
  }
1791
1846
  } catch {
1792
1847
  }
@@ -1803,12 +1858,12 @@ class MU extends il {
1803
1858
  const d = await this.engine._getTinySynth();
1804
1859
  if (this.tinySynthChannel === null) {
1805
1860
  this.tinySynthChannel = this._allocateTinySynthChannel(), d.setProgram(this.tinySynthChannel, this.currentInstrument);
1806
- const t = Math.round(this.currentVolume * 127);
1807
- d.setChVol(this.tinySynthChannel, t);
1861
+ const Z = Math.round(this.currentVolume * 127);
1862
+ d.setChVol(this.tinySynthChannel, Z);
1808
1863
  }
1809
1864
  if (F) {
1810
- const t = Math.round(U * this.currentVolume);
1811
- d.noteOn(this.tinySynthChannel, l, t);
1865
+ const Z = Math.round(U * this.currentVolume);
1866
+ d.noteOn(this.tinySynthChannel, l, Z);
1812
1867
  } else
1813
1868
  d.noteOff(this.tinySynthChannel, l);
1814
1869
  }
@@ -1829,7 +1884,7 @@ class MU extends il {
1829
1884
  }
1830
1885
  async setInstrument(l) {
1831
1886
  this._validateActive();
1832
- const U = $l.getInstrumentProgram(l);
1887
+ const U = lU.getInstrumentProgram(l);
1833
1888
  this.currentInstrument = U;
1834
1889
  const F = this.engine._getSamplesForInstrument(U), d = this.synthMode;
1835
1890
  this.synthMode = F ? "sample" : "synth", d !== this.synthMode && this.allNotesOff(), this.synthMode === "synth" && this.tinySynthChannel !== null && (await this.engine._getTinySynth()).setProgram(this.tinySynthChannel, U), console.log(`Channel ${this.partId}: Instrument ${l} (${U}) -> ${this.synthMode} mode`);
@@ -1894,14 +1949,14 @@ class KU extends Bl {
1894
1949
  const d = await F.json();
1895
1950
  if (!d || typeof d != "object")
1896
1951
  throw new Error("Invalid sample data format");
1897
- const t = /* @__PURE__ */ new Map(), Q = Object.keys(d);
1952
+ const Z = /* @__PURE__ */ new Map(), Q = Object.keys(d);
1898
1953
  for (let V = 0; V < Q.length; V++) {
1899
1954
  const a = Q[V], n = d[a], R = await this._decodeBase64Audio(n, U);
1900
- t.set(a, R);
1955
+ Z.set(a, R);
1901
1956
  const m = (V + 1) / Q.length;
1902
1957
  this._emitProgress("loading-samples", `Loaded ${V + 1}/${Q.length} samples`, m);
1903
1958
  }
1904
- return t;
1959
+ return Z;
1905
1960
  } catch (F) {
1906
1961
  throw console.error("Failed to load sample file:", F), F;
1907
1962
  }
@@ -1914,10 +1969,10 @@ class KU extends Bl {
1914
1969
  * @private
1915
1970
  */
1916
1971
  async _decodeBase64Audio(l, U) {
1917
- const F = l.split(",")[1], d = atob(F), t = new Uint8Array(d.length);
1972
+ const F = l.split(",")[1], d = atob(F), Z = new Uint8Array(d.length);
1918
1973
  for (let V = 0; V < d.length; V++)
1919
- t[V] = d.charCodeAt(V);
1920
- const Q = await this.audioContext.decodeAudioData(t.buffer);
1974
+ Z[V] = d.charCodeAt(V);
1975
+ const Q = await this.audioContext.decodeAudioData(Z.buffer);
1921
1976
  return Q._shouldLoop = U, Q;
1922
1977
  }
1923
1978
  /**
@@ -1927,12 +1982,12 @@ class KU extends Bl {
1927
1982
  async _loadEmbeddedMetronomeSounds() {
1928
1983
  try {
1929
1984
  const l = atob(vU), U = new Uint8Array(l.length);
1930
- for (let t = 0; t < l.length; t++)
1931
- U[t] = l.charCodeAt(t);
1985
+ for (let Z = 0; Z < l.length; Z++)
1986
+ U[Z] = l.charCodeAt(Z);
1932
1987
  this.regularTickBuffer = await this.audioContext.decodeAudioData(U.buffer);
1933
1988
  const F = atob(gU), d = new Uint8Array(F.length);
1934
- for (let t = 0; t < F.length; t++)
1935
- d[t] = F.charCodeAt(t);
1989
+ for (let Z = 0; Z < F.length; Z++)
1990
+ d[Z] = F.charCodeAt(Z);
1936
1991
  this.accentTickBuffer = await this.audioContext.decodeAudioData(d.buffer);
1937
1992
  } catch (l) {
1938
1993
  console.warn("Failed to load embedded metronome sounds:", l), this.regularTickBuffer = this.audioContext.createBuffer(2, 1024, this.audioContext.sampleRate), this.accentTickBuffer = this.audioContext.createBuffer(2, 1024, this.audioContext.sampleRate);
@@ -2097,8 +2152,8 @@ class HU {
2097
2152
  for (const F of l) {
2098
2153
  if (!F.name || !F.url)
2099
2154
  continue;
2100
- const d = F.name.toLowerCase(), t = this._parseUrlParams(F.url), Q = {};
2101
- t.track !== void 0 && (Q.channel = parseInt(t.track, 10)), t.prog !== void 0 && (Q.instrument = parseInt(t.prog, 10)), Q.channel !== void 0 && (U[d] = Q);
2155
+ const d = F.name.toLowerCase(), Z = this._parseUrlParams(F.url), Q = {};
2156
+ Z.track !== void 0 && (Q.channel = parseInt(Z.track, 10)), Z.prog !== void 0 && (Q.instrument = parseInt(Z.prog, 10)), Q.channel !== void 0 && (U[d] = Q);
2102
2157
  }
2103
2158
  return U;
2104
2159
  }
@@ -2113,8 +2168,8 @@ class HU {
2113
2168
  if (F === -1)
2114
2169
  return U;
2115
2170
  const d = l.substring(F + 1).split("&");
2116
- for (const t of d) {
2117
- const [Q, V] = t.split("=");
2171
+ for (const Z of d) {
2172
+ const [Q, V] = Z.split("=");
2118
2173
  Q && V !== void 0 && (U[Q] = V);
2119
2174
  }
2120
2175
  return U;
@@ -2127,14 +2182,14 @@ class HU {
2127
2182
  const U = new Uint8Array(l);
2128
2183
  if (!(U[0] === 77 && U[1] === 84 && U[2] === 104 && U[3] === 100))
2129
2184
  throw new Error("Not a valid MIDI file");
2130
- const F = this._bytesToNumber(U.slice(4, 8)), d = this._bytesToNumber(U.slice(8, 10)), t = this._bytesToNumber(U.slice(10, 12)), Q = this._bytesToNumber(U.slice(12, 14)), V = Q & 32768 ? null : Q, a = {
2185
+ const F = this._bytesToNumber(U.slice(4, 8)), d = this._bytesToNumber(U.slice(8, 10)), Z = this._bytesToNumber(U.slice(10, 12)), Q = this._bytesToNumber(U.slice(12, 14)), V = Q & 32768 ? null : Q, a = {
2131
2186
  format: d,
2132
2187
  ticksPerBeat: V,
2133
2188
  tracks: [],
2134
2189
  duration: 0
2135
2190
  };
2136
2191
  let n = 8 + F;
2137
- for (let R = 0; R < t; R++)
2192
+ for (let R = 0; R < Z; R++)
2138
2193
  if (U[n] === 77 && U[n + 1] === 84 && U[n + 2] === 114 && U[n + 3] === 107) {
2139
2194
  const m = this._bytesToNumber(U.slice(n + 4, n + 8)), e = U.slice(n + 8, n + 8 + m), c = this._parseTrack(e);
2140
2195
  a.tracks.push(c), n += 8 + m;
@@ -2154,7 +2209,7 @@ class HU {
2154
2209
  events: [],
2155
2210
  duration: 0
2156
2211
  };
2157
- let F = 0, d = 0, t = null;
2212
+ let F = 0, d = 0, Z = null;
2158
2213
  for (; F < l.length; ) {
2159
2214
  let Q = 0, V = 0;
2160
2215
  do
@@ -2163,11 +2218,11 @@ class HU {
2163
2218
  d += Q, V = l[F++];
2164
2219
  let a = V;
2165
2220
  if (V & 128)
2166
- t = a;
2221
+ Z = a;
2167
2222
  else {
2168
- if (t === null)
2223
+ if (Z === null)
2169
2224
  throw new Error("Running status byte encountered before status byte");
2170
- a = t, F--;
2225
+ a = Z, F--;
2171
2226
  }
2172
2227
  if (a === 255) {
2173
2228
  const n = l[F++], R = this._readVariableLengthValue(l, F);
@@ -2295,13 +2350,13 @@ class HU {
2295
2350
  ticksPerBeat: l.ticksPerBeat
2296
2351
  };
2297
2352
  l.tracks.forEach((F, d) => {
2298
- if (F.name && !U.title && (U.title = F.name), F.events.filter((t) => t.type === "text").forEach((t) => {
2299
- const Q = t.text.toLowerCase();
2300
- (Q.includes("compos") || Q.includes("by")) && !U.composer && (U.composer = t.text);
2353
+ if (F.name && !U.title && (U.title = F.name), F.events.filter((Z) => Z.type === "text").forEach((Z) => {
2354
+ const Q = Z.text.toLowerCase();
2355
+ (Q.includes("compos") || Q.includes("by")) && !U.composer && (U.composer = Z.text);
2301
2356
  }), F.name) {
2302
- const t = F.name.toLowerCase();
2357
+ const Z = F.name.toLowerCase();
2303
2358
  for (const Q of this.partNames)
2304
- if (t.includes(Q)) {
2359
+ if (Z.includes(Q)) {
2305
2360
  U.partNames.push({
2306
2361
  index: d,
2307
2362
  name: F.name
@@ -2331,7 +2386,7 @@ class HU {
2331
2386
  m.type === "noteOff" && m.tick > d && (d = m.tick);
2332
2387
  });
2333
2388
  }), d === 0 && (d = U * 8);
2334
- const t = [], Q = F.filter((R) => R.type === "timeSignature").sort((R, m) => R.tick - m.tick);
2389
+ const Z = [], Q = F.filter((R) => R.type === "timeSignature").sort((R, m) => R.tick - m.tick);
2335
2390
  let V = { numerator: 4, denominator: 4 }, a = 0, n = 0;
2336
2391
  for (; a < d; ) {
2337
2392
  for (; n < Q.length && Q[n].tick <= a; )
@@ -2339,16 +2394,16 @@ class HU {
2339
2394
  let R;
2340
2395
  R = a + U * 4 * V.numerator / V.denominator;
2341
2396
  const m = V.numerator, e = [], c = U * (4 / V.denominator);
2342
- for (let s = 0; s < m; s++) {
2343
- const u = a + s * c, B = this._ticksToTime(u, l);
2344
- e.push(B);
2397
+ for (let b = 0; b < m; b++) {
2398
+ const B = a + b * c, u = this._ticksToTime(B, l);
2399
+ e.push(u);
2345
2400
  }
2346
- t.push({
2401
+ Z.push({
2347
2402
  sig: [V.numerator, V.denominator],
2348
2403
  beats: e
2349
2404
  }), a = R;
2350
2405
  }
2351
- this.parsedData.barStructure = t;
2406
+ this.parsedData.barStructure = Z;
2352
2407
  }
2353
2408
  /**
2354
2409
  * Extract notes for each voice part
@@ -2357,27 +2412,27 @@ class HU {
2357
2412
  _extractParts(l) {
2358
2413
  const U = {}, F = l.ticksPerBeat;
2359
2414
  if (this.metadataOverrides.parts)
2360
- for (const [d, t] of Object.entries(this.metadataOverrides.parts)) {
2361
- if (t.channel !== void 0 && t.channel !== null) {
2362
- if (t.channel === 15) {
2415
+ for (const [d, Z] of Object.entries(this.metadataOverrides.parts)) {
2416
+ if (Z.channel !== void 0 && Z.channel !== null) {
2417
+ if (Z.channel === 15) {
2363
2418
  console.error(`Part "${d}" uses channel 15 which is reserved for metronome. Skipping.`);
2364
2419
  continue;
2365
2420
  }
2366
- if (t.channel === 9 && console.warn(`Part "${d}" uses channel 9 (drums/percussion). This may not be appropriate for vocal parts.`), t.channel < 0 || t.channel > 15) {
2367
- console.error(`Part "${d}" has invalid channel ${t.channel}. MIDI channels must be 0-15. Skipping.`);
2421
+ if (Z.channel === 9 && console.warn(`Part "${d}" uses channel 9 (drums/percussion). This may not be appropriate for vocal parts.`), Z.channel < 0 || Z.channel > 15) {
2422
+ console.error(`Part "${d}" has invalid channel ${Z.channel}. MIDI channels must be 0-15. Skipping.`);
2368
2423
  continue;
2369
2424
  }
2370
2425
  }
2371
- if (t.channel === void 0 && !t.trackIndex && t.trackIndex !== 0 && !t.trackName)
2426
+ if (Z.channel === void 0 && !Z.trackIndex && Z.trackIndex !== 0 && !Z.trackName)
2372
2427
  continue;
2373
2428
  let Q;
2374
- if (t.channel !== void 0 && t.channel !== null) {
2375
- if (Q = this._extractPartDataByChannel(t.channel, l, F), !Q || Q.notes.length === 0) {
2376
- console.warn(`Part "${d}" specified channel ${t.channel} but no notes found on that channel. Skipping.`);
2429
+ if (Z.channel !== void 0 && Z.channel !== null) {
2430
+ if (Q = this._extractPartDataByChannel(Z.channel, l, F), !Q || Q.notes.length === 0) {
2431
+ console.warn(`Part "${d}" specified channel ${Z.channel} but no notes found on that channel. Skipping.`);
2377
2432
  continue;
2378
2433
  }
2379
- } else if (t.trackIndex !== void 0 && t.trackIndex !== null) {
2380
- const V = t.trackIndex;
2434
+ } else if (Z.trackIndex !== void 0 && Z.trackIndex !== null) {
2435
+ const V = Z.trackIndex;
2381
2436
  if (V >= 0 && V < l.tracks.length) {
2382
2437
  const a = l.tracks[V];
2383
2438
  Q = this._extractPartDataFromTrack(a, V, l, F);
@@ -2385,20 +2440,20 @@ class HU {
2385
2440
  console.warn(`Part "${d}" specified trackIndex ${V} but track not found. Skipping.`);
2386
2441
  continue;
2387
2442
  }
2388
- } else if (t.trackName) {
2389
- const V = l.tracks.findIndex((a) => a.name === t.trackName);
2443
+ } else if (Z.trackName) {
2444
+ const V = l.tracks.findIndex((a) => a.name === Z.trackName);
2390
2445
  if (V !== -1) {
2391
2446
  const a = l.tracks[V];
2392
2447
  Q = this._extractPartDataFromTrack(a, V, l, F);
2393
2448
  } else {
2394
- console.warn(`Part "${d}" specified trackName "${t.trackName}" but track not found. Skipping.`);
2449
+ console.warn(`Part "${d}" specified trackName "${Z.trackName}" but track not found. Skipping.`);
2395
2450
  continue;
2396
2451
  }
2397
2452
  }
2398
- Q && (t.instrument !== void 0 && t.instrument !== null && (Q.defaultInstrument = this._resolveInstrument(t.instrument), Q.programChanges = []), U[d] = Q);
2453
+ Q && (Z.instrument !== void 0 && Z.instrument !== null && (Q.defaultInstrument = this._resolveInstrument(Z.instrument), Q.programChanges = []), U[d] = Q);
2399
2454
  }
2400
2455
  else
2401
- l.tracks.forEach((d, t) => {
2456
+ l.tracks.forEach((d, Z) => {
2402
2457
  if (!d.notes.length) return;
2403
2458
  let Q = null;
2404
2459
  if (d.name) {
@@ -2414,11 +2469,11 @@ class HU {
2414
2469
  break;
2415
2470
  }
2416
2471
  }
2417
- Q || (Q = d.name || `Track ${t + 1}`), Q === "s" && (Q = "soprano"), Q === "a" && (Q = "alto"), Q === "t" && (Q = "tenor"), Q === "b" && (Q = "bass");
2472
+ Q || (Q = d.name || `Track ${Z + 1}`), Q === "s" && (Q = "soprano"), Q === "a" && (Q = "alto"), Q === "t" && (Q = "tenor"), Q === "b" && (Q = "bass");
2418
2473
  let V = Q, a = 2;
2419
2474
  for (; U[V]; )
2420
2475
  V = `${Q} ${a}`, a++;
2421
- Q = V, U[Q] = this._extractPartDataFromTrack(d, t, l, F);
2476
+ Q = V, U[Q] = this._extractPartDataFromTrack(d, Z, l, F);
2422
2477
  });
2423
2478
  this.parsedData.parts = U;
2424
2479
  }
@@ -2427,7 +2482,7 @@ class HU {
2427
2482
  * @private
2428
2483
  */
2429
2484
  _extractPartDataByChannel(l, U, F) {
2430
- const d = [], t = [], Q = [], V = [];
2485
+ const d = [], Z = [], Q = [], V = [];
2431
2486
  U.tracks.forEach((n, R) => {
2432
2487
  const m = {};
2433
2488
  n.notes.forEach((e) => {
@@ -2438,13 +2493,13 @@ class HU {
2438
2493
  velocity: e.velocity
2439
2494
  };
2440
2495
  else if (e.type === "noteOff" && m[e.noteNumber]) {
2441
- const c = m[e.noteNumber], s = e.tick - c.tick;
2496
+ const c = m[e.noteNumber], b = e.tick - c.tick;
2442
2497
  d.push({
2443
2498
  pitch: e.noteNumber,
2444
2499
  name: this._midiNoteToName(e.noteNumber),
2445
2500
  startTick: c.tick,
2446
2501
  endTick: e.tick,
2447
- duration: s,
2502
+ duration: b,
2448
2503
  startTime: this._ticksToTime(c.tick, U),
2449
2504
  endTime: this._ticksToTime(e.tick, U),
2450
2505
  velocity: c.velocity,
@@ -2454,7 +2509,7 @@ class HU {
2454
2509
  }
2455
2510
  }
2456
2511
  }), n.lyrics.forEach((e) => {
2457
- t.push({
2512
+ Z.push({
2458
2513
  text: e.text,
2459
2514
  tick: e.tick,
2460
2515
  time: e.tick / F
@@ -2467,11 +2522,11 @@ class HU {
2467
2522
  sourceTrackIndex: R
2468
2523
  });
2469
2524
  }), n.notes.some((e) => e.channel === l) && V.push(R);
2470
- }), d.sort((n, R) => n.startTick - R.startTick), t.sort((n, R) => n.tick - R.tick), Q.sort((n, R) => n.tick - R.tick);
2525
+ }), d.sort((n, R) => n.startTick - R.startTick), Z.sort((n, R) => n.tick - R.tick), Q.sort((n, R) => n.tick - R.tick);
2471
2526
  const a = Q.length > 0 ? Q[0].programNumber : 0;
2472
2527
  return {
2473
2528
  notes: d,
2474
- lyrics: t,
2529
+ lyrics: Z,
2475
2530
  channel: l,
2476
2531
  trackIndices: V,
2477
2532
  // All track indices that contributed
@@ -2484,7 +2539,7 @@ class HU {
2484
2539
  * @private
2485
2540
  */
2486
2541
  _extractPartDataFromTrack(l, U, F, d) {
2487
- const t = [], Q = {};
2542
+ const Z = [], Q = {};
2488
2543
  l.notes.forEach((R) => {
2489
2544
  if (R.type === "noteOn")
2490
2545
  Q[R.noteNumber] = {
@@ -2494,7 +2549,7 @@ class HU {
2494
2549
  };
2495
2550
  else if (R.type === "noteOff" && Q[R.noteNumber]) {
2496
2551
  const m = Q[R.noteNumber], e = R.tick - m.tick;
2497
- t.push({
2552
+ Z.push({
2498
2553
  pitch: R.noteNumber,
2499
2554
  name: this._midiNoteToName(R.noteNumber),
2500
2555
  startTick: m.tick,
@@ -2515,14 +2570,14 @@ class HU {
2515
2570
  time: R.tick / d
2516
2571
  // Time in quarter notes
2517
2572
  }));
2518
- t.sort((R, m) => R.startTick - m.startTick);
2573
+ Z.sort((R, m) => R.startTick - m.startTick);
2519
2574
  const a = l.events.filter((R) => R.type === "programChange").map((R) => ({
2520
2575
  programNumber: R.programNumber,
2521
2576
  tick: R.tick,
2522
2577
  time: this._ticksToTime(R.tick, F)
2523
2578
  })).sort((R, m) => R.tick - m.tick), n = a.length > 0 ? a[0].programNumber : 0;
2524
2579
  return {
2525
- notes: t,
2580
+ notes: Z,
2526
2581
  lyrics: V,
2527
2582
  trackIndex: U,
2528
2583
  programChanges: a,
@@ -2584,11 +2639,11 @@ class HU {
2584
2639
  * @private
2585
2640
  */
2586
2641
  _readVariableLengthValue(l, U) {
2587
- let F = 0, d, t = 0;
2642
+ let F = 0, d, Z = 0;
2588
2643
  do
2589
- d = l[U + t++], F = F << 7 | d & 127;
2644
+ d = l[U + Z++], F = F << 7 | d & 127;
2590
2645
  while (d & 128);
2591
- return { value: F, bytesRead: t };
2646
+ return { value: F, bytesRead: Z };
2592
2647
  }
2593
2648
  /**
2594
2649
  * Convert ticks to time in seconds considering tempo changes within bars
@@ -2601,20 +2656,20 @@ class HU {
2601
2656
  n.type === "tempo" && d.push(n);
2602
2657
  });
2603
2658
  }), d.sort((a, n) => a.tick - n.tick);
2604
- let t = 0, Q = 0, V = 120;
2659
+ let Z = 0, Q = 0, V = 120;
2605
2660
  for (const a of d) {
2606
2661
  if (a.tick > l) break;
2607
2662
  if (a.tick > Q) {
2608
2663
  const n = (a.tick - Q) / F * (60 / V);
2609
- t += n, Q = a.tick;
2664
+ Z += n, Q = a.tick;
2610
2665
  }
2611
2666
  V = a.bpm;
2612
2667
  }
2613
2668
  if (l > Q) {
2614
2669
  const a = (l - Q) / F * (60 / V);
2615
- t += a;
2670
+ Z += a;
2616
2671
  }
2617
- return t;
2672
+ return Z;
2618
2673
  }
2619
2674
  }
2620
2675
  class DU {
@@ -2642,18 +2697,18 @@ class DU {
2642
2697
  */
2643
2698
  generateBarOrder(l, U) {
2644
2699
  const F = [], d = {};
2645
- for (const t of U) {
2646
- const Q = l[t.section];
2700
+ for (const Z of U) {
2701
+ const Q = l[Z.section];
2647
2702
  if (!Q)
2648
- throw new Error(`Invalid section index: ${t.section}`);
2649
- const V = t.section;
2703
+ throw new Error(`Invalid section index: ${Z.section}`);
2704
+ const V = Z.section;
2650
2705
  d[V] || (d[V] = 0), d[V]++;
2651
- const a = d[V], n = t.from !== void 0 ? t.from : this._getSectionStartBar(l, t.section), R = t.to !== void 0 ? t.to : Q.to, m = t.as || 1;
2706
+ const a = d[V], n = Z.from !== void 0 ? Z.from : this._getSectionStartBar(l, Z.section), R = Z.to !== void 0 ? Z.to : Q.to, m = Z.as || 1;
2652
2707
  for (let e = n; e <= R; e++)
2653
2708
  this._shouldPlayBar(Q, e, m) && F.push({
2654
2709
  barNumber: e,
2655
2710
  repeat: a,
2656
- sectionIndex: t.section,
2711
+ sectionIndex: Z.section,
2657
2712
  voltaTime: m
2658
2713
  });
2659
2714
  }
@@ -2667,13 +2722,13 @@ class DU {
2667
2722
  */
2668
2723
  generateBarOrderFromLegacyBars(l, U) {
2669
2724
  const F = [];
2670
- let d = 1, t = 0, Q;
2725
+ let d = 1, Z = 0, Q;
2671
2726
  for (const V of l) {
2672
- V.from !== void 0 && (d = V.from === -1 ? 0 : V.from, t = 0), V.timeSig !== void 0 && (Q = V.timeSig);
2727
+ V.from !== void 0 && (d = V.from === -1 ? 0 : V.from, Z = 0), V.timeSig !== void 0 && (Q = V.timeSig);
2673
2728
  const a = V.repeat || 1;
2674
2729
  let n = V.beats;
2675
2730
  for (; n > 0; ) {
2676
- const R = (Q !== void 0 ? Q : this._getBeatsPerBar(d, U)) - t;
2731
+ const R = (Q !== void 0 ? Q : this._getBeatsPerBar(d, U)) - Z;
2677
2732
  n >= R ? (F.push({
2678
2733
  barNumber: d,
2679
2734
  repeat: a,
@@ -2681,10 +2736,10 @@ class DU {
2681
2736
  // Legacy format doesn't have sections
2682
2737
  voltaTime: 1
2683
2738
  // Legacy format doesn't have voltas
2684
- }), n -= R, t = 0, d === 0 ? d = 1 : d++) : (t += n, n = 0);
2739
+ }), n -= R, Z = 0, d === 0 ? d = 1 : d++) : (Z += n, n = 0);
2685
2740
  }
2686
2741
  }
2687
- return t > 0 && F.push({
2742
+ return Z > 0 && F.push({
2688
2743
  barNumber: d,
2689
2744
  repeat: 1,
2690
2745
  sectionIndex: 0,
@@ -2718,8 +2773,8 @@ class DU {
2718
2773
  let d;
2719
2774
  if (F ? d = l : d = l - 1, d < 0 || d >= U.length)
2720
2775
  return 4;
2721
- const t = U[d];
2722
- return t.sig ? t.sig[0] : 4;
2776
+ const Z = U[d];
2777
+ return Z.sig ? Z.sig[0] : 4;
2723
2778
  }
2724
2779
  /**
2725
2780
  * Generate beat table from bar order and MIDI bar structure
@@ -2730,44 +2785,44 @@ class DU {
2730
2785
  */
2731
2786
  generateBeatTable(l, U) {
2732
2787
  const F = [], d = {};
2733
- let t = 0, Q = 0;
2788
+ let Z = 0, Q = 0;
2734
2789
  const V = [...U];
2735
- for (; Q < l.length && t < V.length; ) {
2790
+ for (; Q < l.length && Z < V.length; ) {
2736
2791
  const a = l[Q], n = a.barNumber;
2737
2792
  if (d[n] === void 0) {
2738
- const c = V[t];
2793
+ const c = V[Z];
2739
2794
  if (!c || !c.sig)
2740
- throw new Error(`Invalid MIDI bar structure at index ${t}`);
2795
+ throw new Error(`Invalid MIDI bar structure at index ${Z}`);
2741
2796
  d[n] = c.sig[0];
2742
2797
  }
2743
2798
  const R = d[n];
2744
- let m = V[t], e = m.sig[0];
2745
- for (; e < R && t + 1 < V.length; ) {
2746
- const c = V[t + 1], s = [
2799
+ let m = V[Z], e = m.sig[0];
2800
+ for (; e < R && Z + 1 < V.length; ) {
2801
+ const c = V[Z + 1], b = [
2747
2802
  m.sig[0] + c.sig[0],
2748
2803
  // Total beats
2749
2804
  m.sig[1]
2750
2805
  // Keep original note value
2751
- ], u = [
2806
+ ], B = [
2752
2807
  ...m.beats || [],
2753
2808
  ...c.beats || []
2754
2809
  ];
2755
2810
  m = {
2756
- sig: s,
2757
- beats: u
2758
- }, V[t] = m, V.splice(t + 1, 1), e = s[0];
2811
+ sig: b,
2812
+ beats: B
2813
+ }, V[Z] = m, V.splice(Z + 1, 1), e = b[0];
2759
2814
  }
2760
2815
  if (e > R) {
2761
- const c = R, s = e - R, u = m.beats ? m.beats.slice(0, c) : [], B = m.beats ? m.beats.slice(c) : [], X = {
2816
+ const c = R, b = e - R, B = m.beats ? m.beats.slice(0, c) : [], u = m.beats ? m.beats.slice(c) : [], X = {
2762
2817
  sig: [c, m.sig[1]],
2763
- beats: u
2764
- }, T = {
2765
- sig: [s, m.sig[1]],
2766
2818
  beats: B
2819
+ }, E = {
2820
+ sig: [b, m.sig[1]],
2821
+ beats: u
2767
2822
  };
2768
- V[t] = X, V.splice(t + 1, 0, T), m = X;
2823
+ V[Z] = X, V.splice(Z + 1, 0, E), m = X;
2769
2824
  }
2770
- this._generateBeatsForBar(F, a, m, R), t++, Q++;
2825
+ this._generateBeatsForBar(F, a, m, R), Z++, Q++;
2771
2826
  }
2772
2827
  if (Q < l.length) {
2773
2828
  const a = F.length > 0 ? F[F.length - 1] : null;
@@ -2780,15 +2835,15 @@ class DU {
2780
2835
  for (; Q < l.length; ) {
2781
2836
  const m = l[Q], e = m.barNumber, c = d[e] !== void 0 ? d[e] : 4;
2782
2837
  d[e] === void 0 && (d[e] = c);
2783
- const s = [];
2784
- for (let B = 0; B < c; B++)
2785
- s.push(R), R += n;
2786
- const u = {
2838
+ const b = [];
2839
+ for (let u = 0; u < c; u++)
2840
+ b.push(R), R += n;
2841
+ const B = {
2787
2842
  sig: [c, 4],
2788
2843
  // Default to quarter notes
2789
- beats: s
2844
+ beats: b
2790
2845
  };
2791
- this._generateBeatsForBar(F, m, u, c), Q++;
2846
+ this._generateBeatsForBar(F, m, B, c), Q++;
2792
2847
  }
2793
2848
  }
2794
2849
  return F;
@@ -2798,10 +2853,10 @@ class DU {
2798
2853
  * @private
2799
2854
  */
2800
2855
  _generateBeatsForBar(l, U, F, d) {
2801
- const { beats: t } = F;
2802
- if (!t || !Array.isArray(t))
2856
+ const { beats: Z } = F;
2857
+ if (!Z || !Array.isArray(Z))
2803
2858
  throw new Error(`Invalid MIDI bar: missing beats array. Got: ${JSON.stringify(F)}`);
2804
- const Q = t.slice(0, d);
2859
+ const Q = Z.slice(0, d);
2805
2860
  for (let V = 1; V <= d; V++) {
2806
2861
  const a = {
2807
2862
  time: Q[V - 1],
@@ -2843,8 +2898,8 @@ class Jl {
2843
2898
  if (!U)
2844
2899
  throw new Error("Parsed MIDI data is required");
2845
2900
  this.audioEngine = l, this._audioEngineReady = !!(l && l.isInitialized), this.instrumentMap = F || {}, this.parsedData = U, this._isPlaying = !1, this._currentTime = 0, this._totalDuration = 0, this.playbackSpeed = 1, this.partChannels = /* @__PURE__ */ new Map(), this.partOutputs = /* @__PURE__ */ new Map(), this.playbackStartTime = 0, this.lookAheadTime = 0.05, this.scheduleInterval = null, this.partNotePointers = /* @__PURE__ */ new Map(), this.partProgramPointers = /* @__PURE__ */ new Map(), this.eventBus = pl(), this.beatMapper = new DU(), this.beats = [], this.structureMetadata = d, this._calculateTotalDuration();
2846
- const t = d || this._createDefaultStructureMetadata();
2847
- this.beats = this.beatMapper.mapBeats(U, t), this._audioEngineReady && (this._setupPartChannels(), this._resetNotePointers(), this._resetProgramPointers());
2901
+ const Z = d || this._createDefaultStructureMetadata();
2902
+ this.beats = this.beatMapper.mapBeats(U, Z), this._audioEngineReady && (this._setupPartChannels(), this._resetNotePointers(), this._resetProgramPointers());
2848
2903
  }
2849
2904
  // ========================================
2850
2905
  // PUBLIC API - Initialization Methods
@@ -3028,8 +3083,8 @@ class Jl {
3028
3083
  */
3029
3084
  getAllNextNotes(l) {
3030
3085
  const U = l ?? this.getCurrentTime(), F = {};
3031
- for (const [d, t] of Object.entries(this.parsedData.parts)) {
3032
- const Q = t.notes.find((V) => V.startTime >= U);
3086
+ for (const [d, Z] of Object.entries(this.parsedData.parts)) {
3087
+ const Q = Z.notes.find((V) => V.startTime >= U);
3033
3088
  F[d] = Q ? {
3034
3089
  pitch: Q.pitch,
3035
3090
  startTime: Q.startTime
@@ -3073,17 +3128,17 @@ class Jl {
3073
3128
  Object.keys(this.parsedData.parts).forEach((l) => {
3074
3129
  const U = this.parsedData.parts[l], F = this.instrumentMap[l] || {}, d = F.instrument !== void 0 ? F.instrument : U.defaultInstrument !== void 0 ? U.defaultInstrument : 0;
3075
3130
  try {
3076
- const t = this.audioEngine.createChannel(l, {
3131
+ const Z = this.audioEngine.createChannel(l, {
3077
3132
  instrument: d,
3078
3133
  initialVolume: F.volume || 1
3079
3134
  });
3080
- this.partChannels.set(l, t);
3135
+ this.partChannels.set(l, Z);
3081
3136
  const Q = this.audioEngine.audioContext.createGain();
3082
3137
  Q.gain.value = 1;
3083
- const V = t.getOutputNode();
3138
+ const V = Z.getOutputNode();
3084
3139
  V && V.connect(Q), this.partOutputs.set(l, Q);
3085
- } catch (t) {
3086
- console.error(`Failed to create channel for part '${l}':`, t), this._emitEvent("error", t);
3140
+ } catch (Z) {
3141
+ console.error(`Failed to create channel for part '${l}':`, Z), this._emitEvent("error", Z);
3087
3142
  }
3088
3143
  });
3089
3144
  }
@@ -3115,11 +3170,11 @@ class Jl {
3115
3170
  if (!this._isPlaying) return;
3116
3171
  const l = (this.audioEngine.audioContext.currentTime - this.playbackStartTime) * this.playbackSpeed, U = l + this.lookAheadTime;
3117
3172
  for (const [F, d] of this.partChannels) {
3118
- const t = this.parsedData.parts[F];
3119
- if (t) {
3120
- if (t.programChanges && t.programChanges.length > 0) {
3173
+ const Z = this.parsedData.parts[F];
3174
+ if (Z) {
3175
+ if (Z.programChanges && Z.programChanges.length > 0) {
3121
3176
  let Q = this.partProgramPointers.get(F) || 0;
3122
- const V = t.programChanges;
3177
+ const V = Z.programChanges;
3123
3178
  for (; Q < V.length && V[Q].time < l; )
3124
3179
  Q++;
3125
3180
  for (; Q < V.length && V[Q].time <= U; ) {
@@ -3128,9 +3183,9 @@ class Jl {
3128
3183
  }
3129
3184
  this.partProgramPointers.set(F, Q);
3130
3185
  }
3131
- if (t.notes) {
3186
+ if (Z.notes) {
3132
3187
  let Q = this.partNotePointers.get(F) || 0;
3133
- const V = t.notes;
3188
+ const V = Z.notes;
3134
3189
  for (; Q < V.length && V[Q].endTime < l; )
3135
3190
  Q++;
3136
3191
  for (; Q < V.length && V[Q].startTime <= U; ) {
@@ -3174,10 +3229,10 @@ class Jl {
3174
3229
  this.partProgramPointers.set(U, 0);
3175
3230
  continue;
3176
3231
  }
3177
- let t = 0, Q = d.defaultInstrument;
3178
- for (; t < d.programChanges.length && d.programChanges[t].time <= l; )
3179
- Q = d.programChanges[t].programNumber, t++;
3180
- F.setInstrument(Q), this.partProgramPointers.set(U, t);
3232
+ let Z = 0, Q = d.defaultInstrument;
3233
+ for (; Z < d.programChanges.length && d.programChanges[Z].time <= l; )
3234
+ Q = d.programChanges[Z].programNumber, Z++;
3235
+ F.setInstrument(Q), this.partProgramPointers.set(U, Z);
3181
3236
  }
3182
3237
  }
3183
3238
  /**
@@ -3284,7 +3339,7 @@ class jU {
3284
3339
  }, this.startupConfig = {
3285
3340
  delayMs: 25,
3286
3341
  ...U.startup
3287
- }, this.state = "reset", this.frozenTime = 0, this.leadInData = null, this.leadInStartTime = null, this.leadInProgress = null, this.leadInInterval = null, this.timeUpdateInterval = null, this.metronomeScheduleInterval = null, this.nextBeatIndex = 0, this.measuredLatencyMs = null, this.latencyMeasurements = [], this.isCalibrating = !1, this.baselineLatencyMs = null, this.silentGainNode = null, this._validateConfig(), this._loadBaselineLatency(), this.midiPlayer && this._completeMidiPlayerSetup();
3342
+ }, this.state = "reset", this.frozenTime = 0, this.leadInData = null, this.leadInStartTime = null, this.leadInProgress = null, this.leadInInterval = null, this.timeUpdateInterval = null, this.metronomeScheduleInterval = null, this.nextBeatIndex = 0, this.measuredLatencyMs = null, this.latencyMeasurements = [], this.isCalibrating = !1, this.baselineLatencyMs = null, this.metronomeMasterGain = null, this._validateConfig(), this._loadBaselineLatency(), this._audioEngineReady && this._setupMetronomeMasterGain(), this.midiPlayer && this._completeMidiPlayerSetup();
3288
3343
  }
3289
3344
  // ========================================
3290
3345
  // PUBLIC API - Initialization Methods
@@ -3297,7 +3352,7 @@ class jU {
3297
3352
  setAudioEngine(l) {
3298
3353
  if (!l || !l.isInitialized)
3299
3354
  throw new Error("An initialized AudioEngine is required");
3300
- this.audioEngine = l, this._audioEngineReady = !0, this.parsedData && !this.midiPlayer && this._setupPlayerWithAudio();
3355
+ this.audioEngine = l, this._audioEngineReady = !0, this._setupMetronomeMasterGain(), this.parsedData && !this.midiPlayer && this._setupPlayerWithAudio();
3301
3356
  }
3302
3357
  /**
3303
3358
  * Check if audio engine is ready for playback
@@ -3628,7 +3683,7 @@ class jU {
3628
3683
  throw new Error("Audio engine not ready. Call setAudioEngine() first.");
3629
3684
  if (this.isCalibrating)
3630
3685
  throw new Error("Calibration already in progress");
3631
- const U = l.measurements || 5, F = l.sampleIntervalMs || 10, d = l.threshold || 0.01, t = l.timeout || 3e3, Q = l.silent !== void 0 ? l.silent : !0, V = l.updateBaseline !== void 0 ? l.updateBaseline : !0;
3686
+ const U = l.measurements || 5, F = l.sampleIntervalMs || 10, d = l.threshold || 0.01, Z = l.timeout || 3e3, Q = l.silent !== void 0 ? l.silent : !0, V = l.updateBaseline !== void 0 ? l.updateBaseline : !0;
3632
3687
  this.isCalibrating = !0;
3633
3688
  try {
3634
3689
  Q && await this._setupSilentCalibration();
@@ -3636,7 +3691,7 @@ class jU {
3636
3691
  U,
3637
3692
  F,
3638
3693
  d,
3639
- t
3694
+ Z
3640
3695
  );
3641
3696
  this.measuredLatencyMs = a, V && await this._updateBaselineLatency(a);
3642
3697
  const n = this.hasLatencyDrift();
@@ -3684,39 +3739,51 @@ class jU {
3684
3739
  }
3685
3740
  }
3686
3741
  /**
3687
- * Set up silent calibration (connect metronome to gain=0 node)
3688
- * The signal flows through for analysis but is inaudible
3742
+ * Set up metronome master gain node (permanently in audio chain)
3743
+ * This node sits between the audio engine's metronome output and external connections
3689
3744
  * @private
3690
3745
  */
3691
- async _setupSilentCalibration() {
3746
+ _setupMetronomeMasterGain() {
3747
+ if (!this._audioEngineReady || this.metronomeMasterGain)
3748
+ return;
3692
3749
  const l = this.audioEngine.getMetronomeOutput();
3693
- if (!l)
3694
- throw new Error("Metronome output not available for calibration");
3695
- this.silentGainNode || (this.silentGainNode = this.audioEngine.audioContext.createGain(), this.silentGainNode.gain.value = 0, this.silentGainNode.connect(this.audioEngine.audioContext.destination)), l.connect(this.silentGainNode), console.log("Silent calibration setup complete (gain=0, signal flows for analysis)");
3750
+ if (!l) {
3751
+ console.warn("Metronome output not available - master gain not created");
3752
+ return;
3753
+ }
3754
+ try {
3755
+ l.disconnect();
3756
+ } catch {
3757
+ }
3758
+ this.metronomeMasterGain = this.audioEngine.audioContext.createGain(), this.metronomeMasterGain.gain.value = 1, l.connect(this.metronomeMasterGain), console.log("Metronome master gain node created and connected");
3759
+ }
3760
+ /**
3761
+ * Set up silent calibration (set gain to 0 for inaudible measurement)
3762
+ * @private
3763
+ */
3764
+ async _setupSilentCalibration() {
3765
+ if (!this.metronomeMasterGain)
3766
+ throw new Error("Metronome master gain not available for calibration");
3767
+ this.metronomeMasterGain.gain.value = 0, console.log("Silent calibration active (gain=0)");
3696
3768
  }
3697
3769
  /**
3698
- * Tear down silent calibration
3699
- * Disconnects from the silent gain node
3770
+ * Tear down silent calibration (restore gain to 1 for normal operation)
3700
3771
  * @private
3701
3772
  */
3702
3773
  _teardownSilentCalibration() {
3703
- const l = this.audioEngine.getMetronomeOutput();
3704
- if (!(!l || !this.silentGainNode))
3705
- try {
3706
- l.disconnect(this.silentGainNode), console.log("Silent calibration torn down");
3707
- } catch (U) {
3708
- console.warn("Error disconnecting silent calibration:", U);
3709
- }
3774
+ this.metronomeMasterGain && (this.metronomeMasterGain.gain.value = 1, console.log("Silent calibration ended (gain=1)"));
3710
3775
  }
3711
3776
  // ========================================
3712
3777
  // PUBLIC API - Audio Routing
3713
3778
  // ========================================
3714
3779
  /**
3715
3780
  * Get metronome output node for mixer routing
3716
- * @returns {AudioNode} Metronome output gain node
3781
+ * Returns the master gain node which allows silent calibration via gain control
3782
+ * @returns {AudioNode} Metronome master gain node (or raw output if not set up)
3717
3783
  */
3718
3784
  getMetronomeOutput() {
3719
- return this.audioEngine.getMetronomeOutput();
3785
+ var l;
3786
+ return this.metronomeMasterGain || ((l = this.audioEngine) == null ? void 0 : l.getMetronomeOutput());
3720
3787
  }
3721
3788
  /**
3722
3789
  * Get MIDI part output (delegates to MidiPlayer)
@@ -3745,11 +3812,11 @@ class jU {
3745
3812
  previewNextNotes(l = {}) {
3746
3813
  if (!this.midiPlayer)
3747
3814
  throw new Error("No MIDI data loaded");
3748
- const U = l.delayBetweenParts ?? 0.3, F = l.duration ?? 0.5, d = l.velocity ?? 100, t = this.midiPlayer.getAllNextNotes(), Q = l.partOrder ?? this.getPartNames();
3815
+ const U = l.delayBetweenParts ?? 0.3, F = l.duration ?? 0.5, d = l.velocity ?? 100, Z = this.midiPlayer.getAllNextNotes(), Q = l.partOrder ?? this.getPartNames();
3749
3816
  let V = this.audioEngine.audioContext.currentTime + 0.01;
3750
3817
  const a = [];
3751
3818
  for (const n of Q) {
3752
- const R = t[n];
3819
+ const R = Z[n];
3753
3820
  if (!R) continue;
3754
3821
  const m = this.midiPlayer.getPartChannel(n);
3755
3822
  if (!m) continue;
@@ -3886,11 +3953,11 @@ class jU {
3886
3953
  startBeat: { bar: 1, beat: 1, timeSig: 4 }
3887
3954
  };
3888
3955
  const l = this.midiPlayer.beats, U = this.frozenTime, F = this.leadInConfig.bars;
3889
- let d = l.length - 1, t = 0.5;
3956
+ let d = l.length - 1, Z = 0.5;
3890
3957
  for (; l[d].time > U; ) d--;
3891
3958
  const Q = l[d], V = l[d + 1];
3892
- V ? t = V.time - Q.time : d > 0 && (t = Q.time - l[d - 1].time);
3893
- const a = this.midiPlayer && this.midiPlayer.playbackSpeed || 1, n = t / a, R = Q.timeSig === 1, m = R && V ? V.timeSig : Q.timeSig, e = R ? m - 1 : Q.beat > 1 ? Q.beat - 1 : 0, c = F * m + e;
3959
+ V ? Z = V.time - Q.time : d > 0 && (Z = Q.time - l[d - 1].time);
3960
+ const a = this.midiPlayer && this.midiPlayer.playbackSpeed || 1, n = Z / a, R = Q.timeSig === 1, m = R && V ? V.timeSig : Q.timeSig, e = R ? m - 1 : Q.beat > 1 ? Q.beat - 1 : 0, c = F * m + e;
3894
3961
  return {
3895
3962
  totalBeats: c,
3896
3963
  duration: c * n,
@@ -3909,14 +3976,14 @@ class jU {
3909
3976
  */
3910
3977
  _generateBeatSequence(l, U, F) {
3911
3978
  const d = [];
3912
- for (let t = 0; t < l; t++) {
3913
- const Q = t % F + 1;
3979
+ for (let Z = 0; Z < l; Z++) {
3980
+ const Q = Z % F + 1;
3914
3981
  d.push({
3915
3982
  beat: Q,
3916
3983
  isAccent: Q === 1,
3917
- time: t * U,
3984
+ time: Z * U,
3918
3985
  // Relative time from start of lead-in playback
3919
- absoluteTime: this.leadInStartTime + t * U
3986
+ absoluteTime: this.leadInStartTime + Z * U
3920
3987
  // Absolute time (includes startup delay)
3921
3988
  });
3922
3989
  }
@@ -3933,7 +4000,7 @@ class jU {
3933
4000
  this.leadInStartTime = this.audioEngine.audioContext.currentTime, this.leadInInterval = setInterval(() => {
3934
4001
  const d = this.audioEngine.audioContext.currentTime - this.leadInStartTime;
3935
4002
  for (this.leadInProgress = Math.min(1, d / this.leadInData.duration); this.leadInBeatIndex < U.length; ) {
3936
- const t = U[this.leadInBeatIndex], Q = t.time - d;
4003
+ const Z = U[this.leadInBeatIndex], Q = Z.time - d;
3937
4004
  if (Q > 0.05)
3938
4005
  break;
3939
4006
  if (!this.leadInScheduledBeats.has(this.leadInBeatIndex) && Q >= -0.05 && Q <= 0.05) {
@@ -3941,10 +4008,10 @@ class jU {
3941
4008
  // Add small offset for immediate beats
3942
4009
  this.audioEngine.audioContext.currentTime + Q
3943
4010
  );
3944
- this._scheduleTickAtTime(V, t.isAccent);
4011
+ this._scheduleTickAtTime(V, Z.isAccent);
3945
4012
  const a = {
3946
4013
  bar: Math.floor(this.leadInBeatIndex / this.leadInData.beatsPerBar) + 1,
3947
- beat: t.beat,
4014
+ beat: Z.beat,
3948
4015
  repeat: 1,
3949
4016
  time: this.frozenTime,
3950
4017
  isLeadIn: !0
@@ -3993,8 +4060,8 @@ class jU {
3993
4060
  if (this.state === "playing")
3994
4061
  try {
3995
4062
  this.midiPlayer.play(), l && this._startMetronome();
3996
- } catch (t) {
3997
- this.state = "stopped", this._emitEvent("error", t);
4063
+ } catch (Z) {
4064
+ this.state = "stopped", this._emitEvent("error", Z);
3998
4065
  }
3999
4066
  };
4000
4067
  F ? d() : setTimeout(d, this.startupConfig.delayMs), this.timeUpdateInterval || this._startTimeUpdateLoop();
@@ -4037,13 +4104,13 @@ class jU {
4037
4104
  if (!U || U.length === 0)
4038
4105
  return;
4039
4106
  const F = this.midiPlayer.getCurrentTime(), d = 0.1;
4040
- for (let t = this.nextBeatIndex; t < U.length; t++) {
4041
- const Q = U[t], V = this.midiPlayer.playbackSpeed || 1, a = l + (Q.time - F) / V;
4107
+ for (let Z = this.nextBeatIndex; Z < U.length; Z++) {
4108
+ const Q = U[Z], V = this.midiPlayer.playbackSpeed || 1, a = l + (Q.time - F) / V;
4042
4109
  if (a > this.audioEngine.audioContext.currentTime + d)
4043
4110
  break;
4044
4111
  if (a >= this.audioEngine.audioContext.currentTime - 0.01) {
4045
4112
  const n = Math.max(a, this.audioEngine.audioContext.currentTime + 1e-3), R = Q.isDownbeat || Q.beat === 1;
4046
- this._scheduleTickAtTime(n, R), this.nextBeatIndex = t + 1;
4113
+ this._scheduleTickAtTime(n, R), this.nextBeatIndex = Z + 1;
4047
4114
  }
4048
4115
  }
4049
4116
  }
@@ -4060,11 +4127,11 @@ class jU {
4060
4127
  this.nextBeatIndex++;
4061
4128
  const F = l + 0.15;
4062
4129
  for (; this.nextBeatIndex < U.length; ) {
4063
- const d = U[this.nextBeatIndex], t = d.time - l;
4130
+ const d = U[this.nextBeatIndex], Z = d.time - l;
4064
4131
  if (d.time > F)
4065
4132
  break;
4066
- if (t >= -0.025 && t <= 0.15) {
4067
- const Q = this.audioEngine.audioContext.currentTime + 5e-3, V = this.audioEngine.audioContext.currentTime + Math.max(t, 5e-3), a = Math.max(Q, V), n = d.beat === 1;
4133
+ if (Z >= -0.025 && Z <= 0.15) {
4134
+ const Q = this.audioEngine.audioContext.currentTime + 5e-3, V = this.audioEngine.audioContext.currentTime + Math.max(Z, 5e-3), a = Math.max(Q, V), n = d.beat === 1;
4068
4135
  this._scheduleTickAtTime(a, n);
4069
4136
  }
4070
4137
  this.nextBeatIndex++;
@@ -4204,7 +4271,7 @@ class jU {
4204
4271
  * Clean up resources and destroy the manager
4205
4272
  */
4206
4273
  destroy() {
4207
- this.stop(), this._stopLeadIn(), this._stopMetronome(), this._stopTimeUpdateLoop(), this.silentGainNode && (this.silentGainNode.disconnect(), this.silentGainNode = null), this.eventBus.all.clear();
4274
+ this.stop(), this._stopLeadIn(), this._stopMetronome(), this._stopTimeUpdateLoop(), this.metronomeMasterGain && (this.metronomeMasterGain.disconnect(), this.metronomeMasterGain = null), this.eventBus.all.clear();
4208
4275
  }
4209
4276
  // ========================================
4210
4277
  // PRIVATE HELPER METHODS
@@ -4240,8 +4307,8 @@ class jU {
4240
4307
  */
4241
4308
  _completeMidiPlayerSetup() {
4242
4309
  this._partOutputsMap.clear(), Object.keys(this.midiPlayer.parsedData.parts).sort((l, U) => {
4243
- const F = this.midiPlayer.parsedData.parts[l], d = this.midiPlayer.parsedData.parts[U], t = F.channel !== void 0 ? F.channel : F.trackIndex, Q = d.channel !== void 0 ? d.channel : d.trackIndex;
4244
- return t - Q;
4310
+ const F = this.midiPlayer.parsedData.parts[l], d = this.midiPlayer.parsedData.parts[U], Z = F.channel !== void 0 ? F.channel : F.trackIndex, Q = d.channel !== void 0 ? d.channel : d.trackIndex;
4311
+ return Z - Q;
4245
4312
  }).forEach((l) => {
4246
4313
  const U = this.midiPlayer.getPartOutput(l);
4247
4314
  U && this._partOutputsMap.set(l, U);
@@ -4266,10 +4333,10 @@ class jU {
4266
4333
  trumpet: { instrument: "trumpet", volume: 0.7 }
4267
4334
  };
4268
4335
  return Object.keys(l).forEach((d) => {
4269
- const t = l[d];
4270
- if (t.defaultInstrument !== void 0)
4336
+ const Z = l[d];
4337
+ if (Z.defaultInstrument !== void 0)
4271
4338
  U[d] = {
4272
- instrument: t.defaultInstrument,
4339
+ instrument: Z.defaultInstrument,
4273
4340
  volume: 1
4274
4341
  };
4275
4342
  else {
@@ -4298,16 +4365,16 @@ class jU {
4298
4365
  const U = this.audioEngine.getMetronomeAnalyser();
4299
4366
  if (!U)
4300
4367
  throw new Error("Metronome analyser not available for signal capture");
4301
- const F = l.sampleIntervalMs || 2, d = l.captureDurationMs || 1500, t = this.audioEngine.audioContext.currentTime + 0.1;
4302
- await this.audioEngine.playMetronomeTick(t, !0, 1);
4368
+ const F = l.sampleIntervalMs || 2, d = l.captureDurationMs || 1500, Z = this.audioEngine.audioContext.currentTime + 0.1;
4369
+ await this.audioEngine.playMetronomeTick(Z, !0, 1);
4303
4370
  const Q = await this._captureAnalyserTimeSeries(
4304
4371
  U,
4305
- t,
4372
+ Z,
4306
4373
  F,
4307
4374
  d
4308
4375
  );
4309
4376
  return {
4310
- scheduledTime: t,
4377
+ scheduledTime: Z,
4311
4378
  samples: Q,
4312
4379
  sampleIntervalMs: F,
4313
4380
  captureDurationMs: d
@@ -4323,8 +4390,8 @@ class jU {
4323
4390
  * @private
4324
4391
  */
4325
4392
  async _performLatencyMeasurement(l, U, F, d) {
4326
- const t = this.audioEngine.getMetronomeAnalyser();
4327
- if (!t)
4393
+ const Z = this.audioEngine.getMetronomeAnalyser();
4394
+ if (!Z)
4328
4395
  throw new Error("Metronome analyser not available for latency measurement");
4329
4396
  const Q = this.audioEngine.audioContext, V = [];
4330
4397
  console.log(`Starting calibration: ${l} measurements, ${U}ms sampling, ${F} threshold`);
@@ -4332,18 +4399,18 @@ class jU {
4332
4399
  const e = Q.currentTime + 0.15;
4333
4400
  await this.audioEngine.playMetronomeTick(e, !0, 1);
4334
4401
  const c = await this._detectOnsetByThreshold(
4335
- t,
4402
+ Z,
4336
4403
  e,
4337
4404
  U,
4338
4405
  F,
4339
4406
  d
4340
4407
  );
4341
4408
  if (c) {
4342
- const s = c.latencyMs;
4343
- V.push(s), console.log(`Measurement ${m + 1}/${l}: ${s.toFixed(1)}ms (RMS: ${c.rms.toFixed(4)}, peak: ${c.peak.toFixed(4)})`);
4409
+ const b = c.latencyMs;
4410
+ V.push(b), console.log(`Measurement ${m + 1}/${l}: ${b.toFixed(1)}ms (RMS: ${c.rms.toFixed(4)}, peak: ${c.peak.toFixed(4)})`);
4344
4411
  } else
4345
4412
  console.warn(`Measurement ${m + 1}/${l}: detection timeout (no signal above ${F} threshold)`);
4346
- await new Promise((s) => setTimeout(s, 300));
4413
+ await new Promise((b) => setTimeout(b, 300));
4347
4414
  }
4348
4415
  if (V.length === 0)
4349
4416
  throw new Error(`Failed to detect any metronome onsets. Try lowering threshold (current: ${F}) or check audio routing.`);
@@ -4373,31 +4440,31 @@ class jU {
4373
4440
  * @returns {Promise<Object|null>} Detection result {latencyMs, rms, peak} or null if timeout
4374
4441
  * @private
4375
4442
  */
4376
- async _detectOnsetByThreshold(l, U, F, d, t) {
4443
+ async _detectOnsetByThreshold(l, U, F, d, Z) {
4377
4444
  const Q = this.audioEngine.audioContext, V = l.fftSize, a = new Float32Array(V), n = Math.max(0, (U - Q.currentTime) * 1e3 - 20);
4378
4445
  await new Promise((m) => setTimeout(m, n));
4379
4446
  const R = performance.now();
4380
4447
  return new Promise((m) => {
4381
4448
  const e = setInterval(() => {
4382
- if (performance.now() - R > t) {
4449
+ if (performance.now() - R > Z) {
4383
4450
  clearInterval(e), m(null);
4384
4451
  return;
4385
4452
  }
4386
4453
  l.getFloatTimeDomainData(a);
4387
- let c = 0, s = 0;
4388
- for (let B = 0; B < V; B++) {
4389
- const X = Math.abs(a[B]);
4390
- c += a[B] * a[B], X > s && (s = X);
4454
+ let c = 0, b = 0;
4455
+ for (let u = 0; u < V; u++) {
4456
+ const X = Math.abs(a[u]);
4457
+ c += a[u] * a[u], X > b && (b = X);
4391
4458
  }
4392
- const u = Math.sqrt(c / V);
4393
- if (u >= d) {
4459
+ const B = Math.sqrt(c / V);
4460
+ if (B >= d) {
4394
4461
  clearInterval(e);
4395
- const B = Q.currentTime, X = (B - U) * 1e3;
4462
+ const u = Q.currentTime, X = (u - U) * 1e3;
4396
4463
  m({
4397
4464
  latencyMs: X,
4398
- rms: u,
4399
- peak: s,
4400
- detectedTime: B
4465
+ rms: B,
4466
+ peak: b,
4467
+ detectedTime: u
4401
4468
  });
4402
4469
  }
4403
4470
  }, F);
@@ -4413,7 +4480,7 @@ class jU {
4413
4480
  * @private
4414
4481
  */
4415
4482
  async _captureAnalyserTimeSeries(l, U, F, d) {
4416
- const t = this.audioEngine.audioContext, Q = l.fftSize, V = new Float32Array(Q), a = [], n = performance.now(), R = Math.max(0, (U - t.currentTime) * 1e3 - 20);
4483
+ const Z = this.audioEngine.audioContext, Q = l.fftSize, V = new Float32Array(Q), a = [], n = performance.now(), R = Math.max(0, (U - Z.currentTime) * 1e3 - 20);
4417
4484
  return await new Promise((m) => setTimeout(m, R)), new Promise((m) => {
4418
4485
  const e = setInterval(() => {
4419
4486
  if (performance.now() - n - R >= d) {
@@ -4421,18 +4488,18 @@ class jU {
4421
4488
  return;
4422
4489
  }
4423
4490
  l.getFloatTimeDomainData(V);
4424
- let c = 0, s = 0;
4491
+ let c = 0, b = 0;
4425
4492
  for (let X = 0; X < Q; X++) {
4426
- const T = Math.abs(V[X]);
4427
- c += V[X] * V[X], T > s && (s = T);
4493
+ const E = Math.abs(V[X]);
4494
+ c += V[X] * V[X], E > b && (b = E);
4428
4495
  }
4429
- const u = Math.sqrt(c / Q), B = t.currentTime;
4496
+ const B = Math.sqrt(c / Q), u = Z.currentTime;
4430
4497
  a.push({
4431
- time: B,
4432
- relativeTime: (B - U) * 1e3,
4498
+ time: u,
4499
+ relativeTime: (u - U) * 1e3,
4433
4500
  // ms relative to scheduled time
4434
- rms: u,
4435
- peak: s
4501
+ rms: B,
4502
+ peak: b
4436
4503
  });
4437
4504
  }, F);
4438
4505
  });
@@ -4472,7 +4539,7 @@ class qU {
4472
4539
  const PU = new qU();
4473
4540
  class wU {
4474
4541
  constructor() {
4475
- this.eventBus = fl(), this.currentTime = 0, this.isPlaying = !1, this.playbackSpeed = 1, this.masterVolume = 0.75, this.metronomeVolume = 0.7, this.parts = /* @__PURE__ */ new Map(), this.playbackTimer = null, this.lastTimestamp = 0, this.audioContext = null, this.audioEngine = null, this.playbackManager = null, this.musicData = null, this.beats = [], this.practiceMarks = {}, this.songDuration = 0, this.maxBar = 0, this.masterGain = null, this.metronomeGain = null, this.partGainNodes = /* @__PURE__ */ new Map(), this.partAnalyserNodes = /* @__PURE__ */ new Map(), this.isInitialized = !1;
4542
+ this.eventBus = _l(), this.currentTime = 0, this.isPlaying = !1, this.playbackSpeed = 1, this.masterVolume = 0.75, this.metronomeVolume = 0.7, this.parts = /* @__PURE__ */ new Map(), this.playbackTimer = null, this.lastTimestamp = 0, this.audioContext = null, this.audioEngine = null, this.playbackManager = null, this.musicData = null, this.beats = [], this.practiceMarks = {}, this.songDuration = 0, this.maxBar = 0, this.masterGain = null, this.metronomeGain = null, this.partGainNodes = /* @__PURE__ */ new Map(), this.partAnalyserNodes = /* @__PURE__ */ new Map(), this.isInitialized = !1;
4476
4543
  }
4477
4544
  // Sanitize part names to ensure consistent lookup
4478
4545
  // Remove non-printable characters, convert to lowercase, trim whitespace
@@ -4492,20 +4559,20 @@ class wU {
4492
4559
  "/FluidR3_GM.sf2",
4493
4560
  "/soundfont.sf2"
4494
4561
  ];
4495
- let d = !1, t = null;
4562
+ let d = !1, Z = null;
4496
4563
  for (const Q of F)
4497
4564
  try {
4498
4565
  await this.audioEngine.initialize(Q), console.log(`Loaded soundfont: ${Q}`), d = !0;
4499
4566
  break;
4500
4567
  } catch (V) {
4501
- console.warn(`Failed to load soundfont ${Q}:`, V.message), t = V;
4568
+ console.warn(`Failed to load soundfont ${Q}:`, V.message), Z = V;
4502
4569
  }
4503
4570
  if (!d) {
4504
4571
  const Q = "No soundfont could be loaded";
4505
4572
  throw this.eventBus.emit("initProgress", {
4506
4573
  stage: "error",
4507
4574
  message: Q,
4508
- error: t
4575
+ error: Z
4509
4576
  }), new Error(Q);
4510
4577
  }
4511
4578
  } else
@@ -4532,7 +4599,7 @@ class wU {
4532
4599
  else {
4533
4600
  if (this.beats = l.beats || [], this.practiceMarks = l.marks || l.practiceMarks || {}, this.beats.length > 0) {
4534
4601
  const F = this.beats[this.beats.length - 1], d = F.tempo > 0 ? 60 / F.tempo : 0.75;
4535
- this.songDuration = F.time + d, this.maxBar = Math.max(...this.beats.map((t) => t.bar));
4602
+ this.songDuration = F.time + d, this.maxBar = Math.max(...this.beats.map((Z) => Z.bar));
4536
4603
  } else
4537
4604
  this.songDuration = 0, this.maxBar = 0;
4538
4605
  this.setupLegacyParts(l.parts || []), this.eventBus.emit("initialized", { parts: Array.from(this.parts.values()) });
@@ -4599,8 +4666,8 @@ class wU {
4599
4666
  F.gain.value = 1;
4600
4667
  const d = this.audioContext.createAnalyser();
4601
4668
  d.fftSize = 256, d.smoothingTimeConstant = 0.3, U.connect(F), F.connect(d), d.connect(this.masterGain);
4602
- const t = this.sanitizePartName(l);
4603
- this.partGainNodes.set(t, F), this.partAnalyserNodes.set(t, d), console.log(`Audio routing established for part: ${l}`);
4669
+ const Z = this.sanitizePartName(l);
4670
+ this.partGainNodes.set(Z, F), this.partAnalyserNodes.set(Z, d), console.log(`Audio routing established for part: ${l}`);
4604
4671
  }
4605
4672
  }
4606
4673
  // Set up metronome audio routing (separate from parts)
@@ -4648,8 +4715,8 @@ class wU {
4648
4715
  setupPlaybackManagerEventDelegation() {
4649
4716
  this.playbackManager.on("timeupdate", ({ audioTime: l, leadInProgress: U }) => {
4650
4717
  this.currentTime = l, this.eventBus.emit("timeChanged", { currentTime: l, leadInProgress: U });
4651
- }), this.playbackManager.on("beatAudible", ({ bar: l, beat: U, isLeadIn: F, repeat: d, time: t }) => {
4652
- this.eventBus.emit("barChanged", { bar: l, beat: U, repeat: d, time: t, isLeadIn: F });
4718
+ }), this.playbackManager.on("beatAudible", ({ bar: l, beat: U, isLeadIn: F, repeat: d, time: Z }) => {
4719
+ this.eventBus.emit("barChanged", { bar: l, beat: U, repeat: d, time: Z, isLeadIn: F });
4653
4720
  }), this.playbackManager.on("leadInStarted", ({ totalBeats: l, duration: U, bars: F }) => {
4654
4721
  this.eventBus.emit("leadInStarted", { bars: F, totalBeats: l, duration: U });
4655
4722
  }), this.playbackManager.on("leadInEnded", () => {
@@ -4774,7 +4841,7 @@ class wU {
4774
4841
  // Helper method to determine if a part should be effectively muted
4775
4842
  isPartEffectivelyMuted(l) {
4776
4843
  const U = this.sanitizePartName(l), F = this.parts.get(U);
4777
- return !F || F.muted ? !0 : Array.from(this.parts.values()).some((t) => t.solo) && !F.solo;
4844
+ return !F || F.muted ? !0 : Array.from(this.parts.values()).some((Z) => Z.solo) && !F.solo;
4778
4845
  }
4779
4846
  // Update audio state for a specific part
4780
4847
  updatePartAudioState(l) {
@@ -4798,11 +4865,11 @@ class wU {
4798
4865
  if (!F)
4799
4866
  return 0;
4800
4867
  try {
4801
- const d = F.frequencyBinCount, t = new Uint8Array(d);
4802
- F.getByteFrequencyData(t);
4868
+ const d = F.frequencyBinCount, Z = new Uint8Array(d);
4869
+ F.getByteFrequencyData(Z);
4803
4870
  let Q = 0;
4804
4871
  for (let a = 0; a < d; a++) {
4805
- const n = t[a] / 255;
4872
+ const n = Z[a] / 255;
4806
4873
  Q += n * n;
4807
4874
  }
4808
4875
  const V = Math.sqrt(Q / d);
@@ -4861,6 +4928,12 @@ class wU {
4861
4928
  this.playbackManager.pause();
4862
4929
  } catch {
4863
4930
  }
4931
+ if (this.playbackManager && this.metronomeGain)
4932
+ try {
4933
+ const l = this.playbackManager.getMetronomeOutput();
4934
+ l && l.disconnect(this.metronomeGain);
4935
+ } catch {
4936
+ }
4864
4937
  if (this.partGainNodes.forEach((l) => {
4865
4938
  try {
4866
4939
  l.disconnect();
@@ -4885,11 +4958,11 @@ class wU {
4885
4958
  this.cleanup(), this.audioEngine && this.audioEngine.destroy(), this.audioContext && this.audioContext.state !== "closed" && this.audioContext.close(), this.eventBus.all.clear();
4886
4959
  }
4887
4960
  }
4888
- const b = new wU();
4889
- function Vl(Z = {}) {
4890
- const l = Fl(), U = Ql(), F = EU(), d = {
4891
- soundfontUrl: Z.soundfontUrl
4892
- }, t = ({ currentTime: W }) => {
4961
+ const s = new wU();
4962
+ function Vl(t = {}) {
4963
+ const l = dl(), U = ll(), F = fl(), d = {
4964
+ soundfontUrl: t.soundfontUrl
4965
+ }, Z = ({ currentTime: W }) => {
4893
4966
  l.setCurrentTime(W);
4894
4967
  }, Q = ({ isPlaying: W }) => {
4895
4968
  l.setPlaybackState(W), F.setTransportState(W ? "playing" : "stopped");
@@ -4899,139 +4972,140 @@ function Vl(Z = {}) {
4899
4972
  l.setPlaybackSpeed(W);
4900
4973
  }, n = ({ volume: W }) => {
4901
4974
  l.setMasterVolume(W);
4902
- }, R = ({ partName: W, volume: N }) => {
4903
- l.setPartVolume(W, N);
4904
- }, m = ({ partName: W, muted: N }) => {
4905
- l.setPartMuted(W, N);
4906
- }, e = ({ partName: W, solo: N }) => {
4907
- l.setPartSolo(W, N);
4975
+ }, R = ({ partName: W, volume: S }) => {
4976
+ l.setPartVolume(W, S);
4977
+ }, m = ({ partName: W, muted: S }) => {
4978
+ l.setPartMuted(W, S);
4979
+ }, e = ({ partName: W, solo: S }) => {
4980
+ l.setPartSolo(W, S);
4908
4981
  }, c = ({ bars: W }) => {
4909
4982
  l.setLeadInActive(!0, W);
4910
- }, s = () => {
4983
+ }, b = () => {
4911
4984
  l.setLeadInActive(!1);
4912
- }, u = () => {
4913
- l.setStartingNotesActive(!0);
4914
4985
  }, B = () => {
4986
+ l.setStartingNotesActive(!0);
4987
+ }, u = () => {
4915
4988
  l.setStartingNotesActive(!1);
4916
4989
  }, X = ({ mark: W }) => {
4917
4990
  F.updateLastPracticeMarkUsed(W);
4918
- }, T = ({ parts: W }) => {
4991
+ }, E = ({ parts: W }) => {
4919
4992
  l.initializeParts(W), U.setParts(W);
4920
- }, I = ({ finalTime: W }) => {
4993
+ }, z = ({ finalTime: W }) => {
4921
4994
  l.setPlaybackState(!1), F.setTransportState("stopped"), console.log(`Song ended at time: ${W}`);
4922
- }, K = ({ duration: W }) => {
4995
+ }, D = ({ duration: W }) => {
4923
4996
  console.log("Updating total duration in store to:", W), U.setTotalDuration(W);
4924
- }, H = ({ beats: W, practiceMarks: N, maxBar: _ }) => {
4925
- console.log(`Updating music data store with ${W.length} beats and ${Object.keys(N).length} practice marks`), U.updateBeats(W), U.practiceMarks = N, U.maxBar = _;
4926
- }, E = () => {
4927
- b.on("timeChanged", t), b.on("playbackStateChanged", Q), b.on("barChanged", V), b.on("speedChanged", a), b.on("masterVolumeChanged", n), b.on("partVolumeChanged", R), b.on("partMutedChanged", m), b.on("partSoloChanged", e), b.on("leadInStarted", c), b.on("leadInCompleted", s), b.on("startingNotesStarted", u), b.on("startingNotesCompleted", B), b.on("practiceMarkChanged", X), b.on("initialized", T), b.on("songEnded", I), b.on("durationUpdated", K), b.on("musicDataExtracted", H);
4928
- }, G = () => {
4929
- b.off("timeChanged", t), b.off("playbackStateChanged", Q), b.off("barChanged", V), b.off("speedChanged", a), b.off("masterVolumeChanged", n), b.off("partVolumeChanged", R), b.off("partMutedChanged", m), b.off("partSoloChanged", e), b.off("leadInStarted", c), b.off("leadInCompleted", s), b.off("startingNotesStarted", u), b.off("startingNotesCompleted", B), b.off("practiceMarkChanged", X), b.off("initialized", T), b.off("songEnded", I), b.off("durationUpdated", K), b.off("musicDataExtracted", H);
4997
+ }, g = ({ beats: W, practiceMarks: S, maxBar: P }) => {
4998
+ console.log(`Updating music data store with ${W.length} beats and ${Object.keys(S).length} practice marks`), U.updateBeats(W), U.practiceMarks = S, U.maxBar = P;
4999
+ }, j = () => {
5000
+ s.on("timeChanged", Z), s.on("playbackStateChanged", Q), s.on("barChanged", V), s.on("speedChanged", a), s.on("masterVolumeChanged", n), s.on("partVolumeChanged", R), s.on("partMutedChanged", m), s.on("partSoloChanged", e), s.on("leadInStarted", c), s.on("leadInCompleted", b), s.on("startingNotesStarted", B), s.on("startingNotesCompleted", u), s.on("practiceMarkChanged", X), s.on("initialized", E), s.on("songEnded", z), s.on("durationUpdated", D), s.on("musicDataExtracted", g);
5001
+ }, Y = () => {
5002
+ s.off("timeChanged", Z), s.off("playbackStateChanged", Q), s.off("barChanged", V), s.off("speedChanged", a), s.off("masterVolumeChanged", n), s.off("partVolumeChanged", R), s.off("partMutedChanged", m), s.off("partSoloChanged", e), s.off("leadInStarted", c), s.off("leadInCompleted", b), s.off("startingNotesStarted", B), s.off("startingNotesCompleted", u), s.off("practiceMarkChanged", X), s.off("initialized", E), s.off("songEnded", z), s.off("durationUpdated", D), s.off("musicDataExtracted", g);
4930
5003
  };
4931
5004
  (() => {
4932
5005
  kl(() => {
4933
5006
  const W = l.masterVolume;
4934
5007
  try {
4935
- b.getMasterVolume() !== W && b.setMasterVolume(W);
4936
- } catch (N) {
4937
- console.warn("Master volume sync skipped during initialization:", N.message);
5008
+ s.getMasterVolume() !== W && s.setMasterVolume(W);
5009
+ } catch (S) {
5010
+ console.warn("Master volume sync skipped during initialization:", S.message);
4938
5011
  }
4939
5012
  }), kl(() => {
4940
5013
  const W = l.metronomeVolume;
4941
5014
  try {
4942
- b.getMetronomeVolume() !== W && b.setMetronomeVolume(W);
4943
- } catch (N) {
4944
- console.warn("Metronome volume sync skipped during initialization:", N.message);
5015
+ s.getMetronomeVolume() !== W && s.setMetronomeVolume(W);
5016
+ } catch (S) {
5017
+ console.warn("Metronome volume sync skipped during initialization:", S.message);
4945
5018
  }
4946
5019
  });
4947
5020
  })();
4948
- const Y = async (W) => {
5021
+ const r = async (W) => {
4949
5022
  try {
4950
- if (l.setLoaded(!1), E(), U.loadMusicData(W), await b.initialize(W, d), !W.midiData && W.beats && W.beats.length > 0) {
4951
- const N = W.beats[0];
4952
- l.setCurrentBar(N.bar, N.beat, N.repeat), b.setTime(N.time);
5023
+ if (l.setLoaded(!1), j(), U.loadMusicData(W), await s.initialize(W, d), F.buildFixedNavigationPoints(), !W.midiData && W.beats && W.beats.length > 0) {
5024
+ const S = W.beats[0];
5025
+ l.setCurrentBar(S.bar, S.beat, S.repeat), s.setTime(S.time);
4953
5026
  }
4954
- b.updateToggleStates(l.metronomeEnabled, l.leadInEnabled), l.setLoaded(!0);
4955
- } catch (N) {
4956
- throw console.error("Failed to initialize audio engine:", N), l.setLoaded(!1), N;
5027
+ s.updateToggleStates(l.metronomeEnabled, l.leadInEnabled), l.setLoaded(!0);
5028
+ } catch (S) {
5029
+ throw console.error("Failed to initialize audio engine:", S), l.setLoaded(!1), S;
4957
5030
  }
4958
5031
  }, q = () => {
4959
- b.play();
4960
- }, o = () => {
4961
- b.stop();
4962
- }, z = () => {
4963
- b.pause();
4964
- }, w = (W) => {
4965
- b.setTime(W);
4966
- }, i = (W, N = 0) => {
4967
- b.setBar(W, N);
4968
- }, S = (W) => {
4969
- b.goToPracticeMark(W);
5032
+ const W = l.currentBar, S = l.currentRepeat, P = l.currentTime;
5033
+ F.setLastPlayStart(W, S, P), F.setNavigationAction("play"), s.play();
5034
+ }, G = () => {
5035
+ F.setNavigationAction("pause"), s.stop();
5036
+ }, M = () => {
5037
+ F.setNavigationAction("pause"), s.pause();
5038
+ }, O = (W) => {
5039
+ F.setNavigationAction("manual"), s.setTime(W);
5040
+ }, i = (W, S = 0) => {
5041
+ F.setNavigationAction("manual"), s.setBar(W, S);
5042
+ }, o = (W) => {
5043
+ s.goToPracticeMark(W);
4970
5044
  }, k = (W) => {
4971
- b.setPlaybackSpeed(W);
4972
- }, v = (W) => {
4973
- b.setMasterVolume(W);
4974
- }, O = (W, N) => {
4975
- b.setPartVolume(W, N);
4976
- }, al = (W, N) => {
4977
- b.setPartMuted(W, N);
4978
- }, ul = (W, N) => {
4979
- b.setPartSolo(W, N);
5045
+ s.setPlaybackSpeed(W);
5046
+ }, I = (W) => {
5047
+ s.setMasterVolume(W);
5048
+ }, A = (W, S) => {
5049
+ s.setPartVolume(W, S);
5050
+ }, al = (W, S) => {
5051
+ s.setPartMuted(W, S);
5052
+ }, ul = (W, S) => {
5053
+ s.setPartSolo(W, S);
4980
5054
  }, yl = (W = 1) => {
4981
- b.playLeadIn(W);
4982
- }, UU = () => {
4983
- b.playStartingNotes();
4984
- }, Yl = (W, N = !0, _ = 0) => {
4985
- N && F.leadInEnabled ? (i(W, _), yl(F.leadInBars)) : (i(W, _), q());
4986
- }, FU = (W, N = !0) => {
4987
- const _ = U.getBarForMark(W);
4988
- _ && Yl(_, N);
4989
- }, dU = () => {
5055
+ s.playLeadIn(W);
5056
+ }, FU = () => {
5057
+ s.playStartingNotes();
5058
+ }, Yl = (W, S = !0, P = 0) => {
5059
+ S && F.leadInEnabled ? (i(W, P), yl(F.leadInBars)) : (i(W, P), q());
5060
+ }, dU = (W, S = !0) => {
5061
+ const P = U.getBarForMark(W);
5062
+ P && Yl(P, S);
5063
+ }, tU = () => {
4990
5064
  const W = !l.metronomeEnabled;
4991
- return l.setMetronomeEnabled(W), b.setMetronomeEnabled(W), W;
5065
+ return l.setMetronomeEnabled(W), s.setMetronomeEnabled(W), W;
4992
5066
  }, ZU = () => {
4993
5067
  const W = !l.leadInEnabled;
4994
- return l.setLeadInEnabled(W), b.updateToggleStates(l.metronomeEnabled, W), W;
5068
+ return l.setLeadInEnabled(W), s.updateToggleStates(l.metronomeEnabled, W), W;
4995
5069
  };
4996
5070
  return cl(() => {
4997
- G();
5071
+ Y();
4998
5072
  }), {
4999
5073
  // Initialization
5000
- initialize: Y,
5074
+ initialize: r,
5001
5075
  // Transport controls
5002
5076
  play: q,
5003
- stop: o,
5004
- pause: z,
5077
+ stop: G,
5078
+ pause: M,
5005
5079
  // Time controls
5006
- setTime: w,
5080
+ setTime: O,
5007
5081
  setBar: i,
5008
5082
  // Navigation
5009
- goToPracticeMark: S,
5083
+ goToPracticeMark: o,
5010
5084
  setPlaybackSpeed: k,
5011
5085
  // Volume controls
5012
- setMasterVolume: v,
5013
- setPartVolume: O,
5086
+ setMasterVolume: I,
5087
+ setPartVolume: A,
5014
5088
  setPartMuted: al,
5015
5089
  setPartSolo: ul,
5016
- getPartLevel: (W) => b.getPartLevel(W),
5090
+ getPartLevel: (W) => s.getPartLevel(W),
5017
5091
  // Special features
5018
5092
  playLeadIn: yl,
5019
- playStartingNotes: UU,
5093
+ playStartingNotes: FU,
5020
5094
  // Feature toggles
5021
- toggleMetronome: dU,
5095
+ toggleMetronome: tU,
5022
5096
  toggleLeadIn: ZU,
5023
5097
  setMetronomeEnabled: (W) => {
5024
- l.setMetronomeEnabled(W), b.setMetronomeEnabled(W);
5098
+ l.setMetronomeEnabled(W), s.setMetronomeEnabled(W);
5025
5099
  },
5026
5100
  // Complex operations
5027
5101
  playFromBar: Yl,
5028
- playFromMark: FU,
5102
+ playFromMark: dU,
5029
5103
  // Access to stores for components
5030
5104
  audioState: l,
5031
5105
  musicData: U,
5032
5106
  playbackState: F,
5033
5107
  // Direct access to engine for advanced use
5034
- audioEngine: b
5108
+ audioEngine: s
5035
5109
  };
5036
5110
  }
5037
5111
  const OU = {
@@ -5044,7 +5118,7 @@ const OU = {
5044
5118
  level: {
5045
5119
  type: Number,
5046
5120
  default: 0,
5047
- validator: (Z) => Z >= 0 && Z <= 1
5121
+ validator: (t) => t >= 0 && t <= 1
5048
5122
  }
5049
5123
  }, {
5050
5124
  volume: { default: 0.75 },
@@ -5055,25 +5129,25 @@ const OU = {
5055
5129
  soloModifiers: {}
5056
5130
  }),
5057
5131
  emits: ["update:volume", "update:mute", "update:solo"],
5058
- setup(Z) {
5059
- ll((c) => ({
5132
+ setup(t) {
5133
+ Ul((c) => ({
5060
5134
  "746d5fc3": n.value
5061
5135
  }));
5062
- const l = Z;
5063
- Fl();
5064
- const U = Vl(), F = $(Z, "volume"), d = $(Z, "mute"), t = $(Z, "solo");
5065
- g(F, (c) => {
5136
+ const l = t;
5137
+ dl();
5138
+ const U = Vl(), F = $(t, "volume"), d = $(t, "mute"), Z = $(t, "solo");
5139
+ v(F, (c) => {
5066
5140
  U.setPartVolume(l.name, c);
5067
- }), g(d, (c) => {
5141
+ }), v(d, (c) => {
5068
5142
  U.setPartMuted(l.name, c);
5069
- }), g(t, (c) => {
5143
+ }), v(Z, (c) => {
5070
5144
  U.setPartSolo(l.name, c);
5071
5145
  });
5072
- const Q = A("el"), { width: V, height: a } = Ul(Q), n = J(() => Math.min(V.value, a.value) + "px"), R = J(
5146
+ const Q = f("el"), { width: V, height: a } = Fl(Q), n = J(() => Math.min(V.value, a.value) + "px"), R = J(
5073
5147
  () => V.value > a.value ? "mobile" : V.value < 60 ? "tablet" : "desktop"
5074
5148
  );
5075
5149
  let m = null;
5076
- const e = M(0);
5150
+ const e = x(0);
5077
5151
  return bl(() => {
5078
5152
  m = setInterval(() => {
5079
5153
  if (d.value)
@@ -5087,176 +5161,176 @@ const OU = {
5087
5161
  }, 16);
5088
5162
  }), cl(() => {
5089
5163
  m && (clearInterval(m), m = null);
5090
- }), (c, s) => (p(), y("div", {
5164
+ }), (c, b) => (N(), y("div", {
5091
5165
  ref_key: "el",
5092
5166
  ref: Q,
5093
- class: C([R.value, "part"])
5167
+ class: L([R.value, "part"])
5094
5168
  }, [
5095
- x(YU, {
5169
+ C(EU, {
5096
5170
  class: "tri",
5097
5171
  mute: d.value,
5098
- "onUpdate:mute": s[0] || (s[0] = (u) => d.value = u),
5099
- solo: t.value,
5100
- "onUpdate:solo": s[1] || (s[1] = (u) => t.value = u)
5172
+ "onUpdate:mute": b[0] || (b[0] = (B) => d.value = B),
5173
+ solo: Z.value,
5174
+ "onUpdate:solo": b[1] || (b[1] = (B) => Z.value = B)
5101
5175
  }, null, 8, ["mute", "solo"]),
5102
- x(Ol, {
5176
+ C(Ol, {
5103
5177
  align: "left",
5104
5178
  class: "name"
5105
5179
  }, {
5106
- default: P(() => [
5107
- Nl(D(Z.name), 1)
5180
+ default: w(() => [
5181
+ Nl(K(t.name), 1)
5108
5182
  ]),
5109
5183
  _: 1
5110
5184
  }),
5111
- x(Wl, {
5185
+ C(Wl, {
5112
5186
  level: e.value,
5113
5187
  "show-level": !0,
5114
5188
  class: "vol",
5115
5189
  value: F.value,
5116
- "onUpdate:value": s[2] || (s[2] = (u) => F.value = u)
5190
+ "onUpdate:value": b[2] || (b[2] = (B) => F.value = B)
5117
5191
  }, null, 8, ["level", "value"])
5118
5192
  ], 2));
5119
5193
  }
5120
- }, AU = /* @__PURE__ */ j(OU, [["__scopeId", "data-v-9ca7f6e9"]]), fU = { class: "mark" }, _U = { class: "rpt" }, $U = { class: "beat-ind" }, lF = { class: "beat" }, UF = {
5194
+ }, AU = /* @__PURE__ */ H(OU, [["__scopeId", "data-v-9ca7f6e9"]]), fU = { class: "mark" }, _U = { class: "rpt" }, $U = { class: "beat-ind" }, lF = { class: "beat" }, UF = {
5121
5195
  key: 1,
5122
5196
  class: "mark-grid-container"
5123
- }, FF = { class: "mark-grid" }, dF = ["onClick"], ZF = {
5197
+ }, FF = { class: "mark-grid" }, dF = ["onClick"], tF = {
5124
5198
  __name: "BarInput",
5125
- setup(Z) {
5126
- ll((i) => ({
5199
+ setup(t) {
5200
+ Ul((i) => ({
5127
5201
  b117cda6: X.value,
5128
- "7cd7b1c8": T.value
5202
+ "7cd7b1c8": E.value
5129
5203
  }));
5130
- const l = A("el"), U = A("rpt"), { width: F, height: d } = Ul(l), t = Ql(), Q = Fl(), V = Vl(), a = M("1"), n = M("A"), R = M(0), m = M(2), e = M(!1), c = M(!1), s = M(!1), u = M(!0);
5131
- let B = null;
5132
- g(() => {
5204
+ const l = f("el"), U = f("rpt"), { width: F, height: d } = Fl(l), Z = ll(), Q = dl(), V = Vl(), a = x("1"), n = x("A"), R = x(0), m = x(2), e = x(!1), c = x(!1), b = x(!1), B = x(!0);
5205
+ let u = null;
5206
+ v(() => {
5133
5207
  var i;
5134
- return ((i = t.beats) == null ? void 0 : i.length) > 0;
5208
+ return ((i = Z.beats) == null ? void 0 : i.length) > 0;
5135
5209
  }, (i) => {
5136
- console.log(i), i && !e.value && (a.value = Q.currentBar.toString(), R.value = Q.currentRepeat, m.value = t.getRepeatCountForBar(Q.currentBar), H(Q.currentBar), e.value = !0);
5137
- }), g(() => Q.currentBar, (i) => {
5138
- m.value = t.getRepeatCountForBar(i);
5139
- }), g(a, () => {
5210
+ console.log(i), i && !e.value && (a.value = Q.currentBar.toString(), R.value = Q.currentRepeat, m.value = Z.getRepeatCountForBar(Q.currentBar), g(Q.currentBar), e.value = !0);
5211
+ }), v(() => Q.currentBar, (i) => {
5212
+ m.value = Z.getRepeatCountForBar(i);
5213
+ }), v(a, () => {
5140
5214
  a.value = a.value.replace(/\D/g, ""), a.value.length > 3 && (a.value = a.value.slice(0, 3));
5141
- }), g(() => Q.currentBar, (i) => {
5142
- a.value = i.toString(), H(i);
5143
- }), g(() => Q.currentBeat, () => {
5144
- u.value = !0, setTimeout(() => {
5145
- u.value = !1;
5215
+ }), v(() => Q.currentBar, (i) => {
5216
+ a.value = i.toString(), g(i);
5217
+ }), v(() => Q.currentBeat, () => {
5218
+ B.value = !0, setTimeout(() => {
5219
+ B.value = !1;
5146
5220
  }, 50);
5147
- }), g(c, () => {
5148
- c.value && w();
5221
+ }), v(c, () => {
5222
+ c.value && O();
5149
5223
  });
5150
- const X = J(() => Math.min(d.value / 2.25, F.value / 4.5) + "px"), T = J(() => Math.min(F.value / 15, d.value / 6.4) + "px"), I = J(() => Object.keys(t.practiceMarks).sort()), K = J(() => I.value.length > 0);
5151
- function H(i) {
5152
- const S = Object.keys(t.practiceMarks).filter((k) => t.practiceMarks[k] <= i).sort((k, v) => t.practiceMarks[v] - t.practiceMarks[k]);
5153
- S.length > 0 && (n.value = S[0]);
5224
+ const X = J(() => Math.min(d.value / 2.25, F.value / 4.5) + "px"), E = J(() => Math.min(F.value / 15, d.value / 6.4) + "px"), z = J(() => Object.keys(Z.practiceMarks).sort()), D = J(() => z.value.length > 0);
5225
+ function g(i) {
5226
+ const o = Object.keys(Z.practiceMarks).filter((k) => Z.practiceMarks[k] <= i).sort((k, I) => Z.practiceMarks[I] - Z.practiceMarks[k]);
5227
+ o.length > 0 && (n.value = o[0]);
5154
5228
  }
5155
- function E() {
5229
+ function j() {
5156
5230
  const i = parseInt(a.value);
5157
- i && i > 0 && G(i);
5231
+ i && i > 0 && Y(i);
5158
5232
  }
5159
- function G(i) {
5233
+ function Y(i) {
5160
5234
  V.setBar(i, 0);
5161
5235
  }
5162
- function L(i, S) {
5163
- S && S.stopPropagation(), n.value = i, c.value = !1, V.goToPracticeMark(i);
5236
+ function p(i, o) {
5237
+ o && o.stopPropagation(), n.value = i, c.value = !1, V.goToPracticeMark(i);
5164
5238
  }
5165
- function Y() {
5166
- m.value > 1 && (s.value = !0), Q.currentRepeat < m.value && V.setBar(Q.currentBar, Q.currentRepeat + 1);
5239
+ function r() {
5240
+ m.value > 1 && (b.value = !0), Q.currentRepeat < m.value && V.setBar(Q.currentBar, Q.currentRepeat + 1);
5167
5241
  }
5168
5242
  function q() {
5169
- m.value > 1 && (s.value = !0), Q.currentRepeat > 1 && V.setBar(Q.currentBar, Q.currentRepeat - 1);
5243
+ m.value > 1 && (b.value = !0), Q.currentRepeat > 1 && V.setBar(Q.currentBar, Q.currentRepeat - 1);
5170
5244
  }
5171
- function o(i) {
5172
- K.value && (i.stopPropagation(), s.value = !1, c.value = !c.value);
5245
+ function G(i) {
5246
+ D.value && (i.stopPropagation(), b.value = !1, c.value = !c.value);
5173
5247
  }
5174
- function z(i) {
5175
- var S, k;
5176
- (S = l.value) != null && S.contains(i.target) || (c.value = !1), (k = U.value) != null && k.contains(i.target) || (s.value = !1);
5248
+ function M(i) {
5249
+ var o, k;
5250
+ (o = l.value) != null && o.contains(i.target) || (c.value = !1), (k = U.value) != null && k.contains(i.target) || (b.value = !1);
5177
5251
  }
5178
- function w() {
5252
+ function O() {
5179
5253
  c.value && setTimeout(() => {
5180
- var k, v;
5181
- const i = (k = l.value) == null ? void 0 : k.querySelector(".mark-grid"), S = (v = l.value) == null ? void 0 : v.querySelector(".mark-option.selected");
5182
- if (S && i) {
5183
- const O = i.getBoundingClientRect(), al = S.getBoundingClientRect(), ul = al.left - O.left - O.width / 2 + al.width / 2;
5254
+ var k, I;
5255
+ const i = (k = l.value) == null ? void 0 : k.querySelector(".mark-grid"), o = (I = l.value) == null ? void 0 : I.querySelector(".mark-option.selected");
5256
+ if (o && i) {
5257
+ const A = i.getBoundingClientRect(), al = o.getBoundingClientRect(), ul = al.left - A.left - A.width / 2 + al.width / 2;
5184
5258
  i.scrollLeft = Math.max(0, i.scrollLeft + ul);
5185
5259
  }
5186
5260
  }, 50);
5187
5261
  }
5188
5262
  return bl(() => {
5189
- document.addEventListener("click", z), Al("beatAnimation") && (B = setInterval(() => {
5190
- const i = Q.currentBeat % t.timeSignature + 1;
5263
+ document.addEventListener("click", M), Al("beatAnimation") && (u = setInterval(() => {
5264
+ const i = Q.currentBeat % Z.timeSignature + 1;
5191
5265
  Q.setCurrentBar(Q.currentBar, i, Q.currentRepeat);
5192
5266
  }, 800));
5193
5267
  }), cl(() => {
5194
- document.removeEventListener("click", z), B && (clearInterval(B), B = null);
5195
- }), (i, S) => (p(), y("div", {
5268
+ document.removeEventListener("click", M), u && (clearInterval(u), u = null);
5269
+ }), (i, o) => (N(), y("div", {
5196
5270
  ref_key: "el",
5197
5271
  ref: l,
5198
- class: C(["outer", { pulse: u.value, "mark-selecting": c.value }])
5272
+ class: L(["outer", { pulse: B.value, "mark-selecting": c.value }])
5199
5273
  }, [
5200
- S[6] || (S[6] = h("div", { class: "frame" }, null, -1)),
5274
+ o[6] || (o[6] = h("div", { class: "frame" }, null, -1)),
5201
5275
  h("div", {
5202
- class: C(["mark-input", { empty: !n.value, edit: c.value, disabled: !K.value }]),
5203
- onClick: o
5276
+ class: L(["mark-input", { empty: !n.value, edit: c.value, disabled: !D.value }]),
5277
+ onClick: G
5204
5278
  }, [
5205
- h("div", fU, D(K.value ? n.value : "-"), 1)
5279
+ h("div", fU, K(D.value ? n.value : "-"), 1)
5206
5280
  ], 2),
5207
- S[7] || (S[7] = h("div", { class: "mark-title" }, "Mark", -1)),
5208
- c.value ? f("", !0) : (p(), y(nl, { key: 0 }, [
5281
+ o[7] || (o[7] = h("div", { class: "mark-title" }, "Mark", -1)),
5282
+ c.value ? _("", !0) : (N(), y(nl, { key: 0 }, [
5209
5283
  Kl(h("input", {
5210
5284
  type: "text",
5211
5285
  class: "bar-input",
5212
- "onUpdate:modelValue": S[0] || (S[0] = (k) => a.value = k),
5286
+ "onUpdate:modelValue": o[0] || (o[0] = (k) => a.value = k),
5213
5287
  inputmode: "decimal",
5214
5288
  pattern: "\\d*",
5215
- onChange: E,
5216
- onKeyup: QU(E, ["enter"])
5289
+ onChange: j,
5290
+ onKeyup: VU(j, ["enter"])
5217
5291
  }, null, 544), [
5218
5292
  [Hl, a.value]
5219
5293
  ]),
5220
- S[3] || (S[3] = h("div", { class: "bar-title" }, "Bar", -1)),
5294
+ o[3] || (o[3] = h("div", { class: "bar-title" }, "Bar", -1)),
5221
5295
  h("div", {
5222
5296
  ref_key: "rpt",
5223
5297
  ref: U,
5224
- class: C(["rpt-input", { edit: s.value, available: m.value > 1 }])
5298
+ class: L(["rpt-input", { edit: b.value, available: m.value > 1 }])
5225
5299
  }, [
5226
- h("div", _U, D(r(Q).currentRepeat || "-"), 1),
5227
- (p(), y("svg", {
5228
- class: C(["inc", { disabled: r(Q).currentRepeat >= m.value }]),
5300
+ h("div", _U, K(T(Q).currentRepeat || "-"), 1),
5301
+ (N(), y("svg", {
5302
+ class: L(["inc", { disabled: T(Q).currentRepeat >= m.value }]),
5229
5303
  viewBox: "0 -100 100 100",
5230
- onClick: Tl(Y, ["prevent"])
5231
- }, S[1] || (S[1] = [
5304
+ onClick: Tl(r, ["prevent"])
5305
+ }, o[1] || (o[1] = [
5232
5306
  h("path", { d: "m10-20 40-60 40 60H10Z" }, null, -1)
5233
5307
  ]), 2)),
5234
- (p(), y("svg", {
5235
- class: C(["dec", { disabled: r(Q).currentRepeat <= 1 }]),
5308
+ (N(), y("svg", {
5309
+ class: L(["dec", { disabled: T(Q).currentRepeat <= 1 }]),
5236
5310
  viewBox: "0 -100 100 100",
5237
5311
  onClick: Tl(q, ["prevent"])
5238
- }, S[2] || (S[2] = [
5312
+ }, o[2] || (o[2] = [
5239
5313
  h("path", { d: "m10-80 40 60 40-60H10Z" }, null, -1)
5240
5314
  ]), 2))
5241
5315
  ], 2),
5242
- S[4] || (S[4] = h("div", { class: "rpt-title" }, "Rpt", -1)),
5316
+ o[4] || (o[4] = h("div", { class: "rpt-title" }, "Rpt", -1)),
5243
5317
  h("div", $U, [
5244
- h("div", lF, D(r(Q).currentBeat), 1)
5318
+ h("div", lF, K(T(Q).currentBeat), 1)
5245
5319
  ]),
5246
- S[5] || (S[5] = h("div", { class: "beat-title" }, "Beat", -1))
5320
+ o[5] || (o[5] = h("div", { class: "beat-title" }, "Beat", -1))
5247
5321
  ], 64)),
5248
- c.value ? (p(), y("div", UF, [
5322
+ c.value ? (N(), y("div", UF, [
5249
5323
  h("div", FF, [
5250
- (p(!0), y(nl, null, Xl(I.value, (k) => (p(), y("div", {
5324
+ (N(!0), y(nl, null, Xl(z.value, (k) => (N(), y("div", {
5251
5325
  key: k,
5252
- class: C(["mark-option", { selected: k === n.value }]),
5253
- onClick: (v) => L(k, v)
5254
- }, D(k), 11, dF))), 128))
5326
+ class: L(["mark-option", { selected: k === n.value }]),
5327
+ onClick: (I) => p(k, I)
5328
+ }, K(k), 11, dF))), 128))
5255
5329
  ])
5256
- ])) : f("", !0)
5330
+ ])) : _("", !0)
5257
5331
  ], 2));
5258
5332
  }
5259
- }, tF = /* @__PURE__ */ j(ZF, [["__scopeId", "data-v-6281baf2"]]), QF = { class: "title" }, VF = {
5333
+ }, ZF = /* @__PURE__ */ H(tF, [["__scopeId", "data-v-6281baf2"]]), QF = { class: "title" }, VF = {
5260
5334
  __name: "BaseNumericInput",
5261
5335
  props: /* @__PURE__ */ Sl({
5262
5336
  title: {
@@ -5293,23 +5367,23 @@ const OU = {
5293
5367
  },
5294
5368
  formatValue: {
5295
5369
  type: Function,
5296
- default: (Z) => Z.toString()
5370
+ default: (t) => t.toString()
5297
5371
  },
5298
5372
  parseValue: {
5299
5373
  type: Function,
5300
- default: (Z) => parseFloat(Z)
5374
+ default: (t) => parseFloat(t)
5301
5375
  },
5302
5376
  validateInput: {
5303
5377
  type: Function,
5304
- default: (Z) => Z.replace(/[^0-9.]/g, "")
5378
+ default: (t) => t.replace(/[^0-9.]/g, "")
5305
5379
  },
5306
5380
  transformSliderToDisplay: {
5307
5381
  type: Function,
5308
- default: (Z) => Z
5382
+ default: (t) => t
5309
5383
  },
5310
5384
  transformDisplayToSlider: {
5311
5385
  type: Function,
5312
- default: (Z) => Z
5386
+ default: (t) => t
5313
5387
  },
5314
5388
  maxChars: {
5315
5389
  type: Number,
@@ -5320,28 +5394,28 @@ const OU = {
5320
5394
  valueModifiers: {}
5321
5395
  }),
5322
5396
  emits: ["update:value"],
5323
- setup(Z) {
5324
- ll((R) => ({
5325
- "0d0963e0": Z.textColor,
5326
- "4ad34b2f": Z.backgroundColor,
5327
- "02156786": Z.color,
5397
+ setup(t) {
5398
+ Ul((R) => ({
5399
+ "0d0963e0": t.textColor,
5400
+ "4ad34b2f": t.backgroundColor,
5401
+ "02156786": t.color,
5328
5402
  "715a9528": a.value,
5329
5403
  "30d64f7d": V.value,
5330
- b8fbe65e: Z.focusColor
5404
+ b8fbe65e: t.focusColor
5331
5405
  }));
5332
- const l = Z, U = A("el"), { width: F, height: d } = Ul(U), t = $(Z, "value"), Q = M(l.formatValue(l.transformSliderToDisplay(t.value)));
5333
- g(t, () => {
5334
- const R = l.transformSliderToDisplay(t.value);
5406
+ const l = t, U = f("el"), { width: F, height: d } = Fl(U), Z = $(t, "value"), Q = x(l.formatValue(l.transformSliderToDisplay(Z.value)));
5407
+ v(Z, () => {
5408
+ const R = l.transformSliderToDisplay(Z.value);
5335
5409
  Q.value = l.formatValue(R);
5336
- }), g(Q, () => {
5410
+ }), v(Q, () => {
5337
5411
  Q.value = l.validateInput(Q.value), l.maxChars && Q.value.length > l.maxChars && (Q.value = Q.value.slice(0, l.maxChars));
5338
5412
  });
5339
5413
  const V = J(() => Math.min(d.value / 2.25, F.value / 2.2) + "px"), a = J(() => Math.min(F.value / 3, d.value / 6.4) + "px");
5340
5414
  function n() {
5341
5415
  const R = l.parseValue(Q.value), m = l.transformDisplayToSlider(R);
5342
- t.value = Math.min(Math.max(m, l.sliderMin), l.sliderMax);
5416
+ Z.value = Math.min(Math.max(m, l.sliderMin), l.sliderMax);
5343
5417
  }
5344
- return (R, m) => (p(), y("div", {
5418
+ return (R, m) => (N(), y("div", {
5345
5419
  class: "outer",
5346
5420
  ref_key: "el",
5347
5421
  ref: U
@@ -5357,38 +5431,38 @@ const OU = {
5357
5431
  }, null, 544), [
5358
5432
  [Hl, Q.value]
5359
5433
  ]),
5360
- h("div", QF, D(Z.title), 1),
5361
- x(Wl, {
5434
+ h("div", QF, K(t.title), 1),
5435
+ C(Wl, {
5362
5436
  class: "slider",
5363
- value: t.value,
5364
- "onUpdate:value": m[1] || (m[1] = (e) => t.value = e),
5365
- "thumb-length": Z.thumbLength,
5366
- max: Z.sliderMax,
5367
- min: Z.sliderMin
5437
+ value: Z.value,
5438
+ "onUpdate:value": m[1] || (m[1] = (e) => Z.value = e),
5439
+ "thumb-length": t.thumbLength,
5440
+ max: t.sliderMax,
5441
+ min: t.sliderMin
5368
5442
  }, null, 8, ["value", "thumb-length", "max", "min"])
5369
5443
  ], 512));
5370
5444
  }
5371
- }, lU = /* @__PURE__ */ j(VF, [["__scopeId", "data-v-79c7a539"]]), aF = {
5445
+ }, UU = /* @__PURE__ */ H(VF, [["__scopeId", "data-v-79c7a539"]]), aF = {
5372
5446
  __name: "SpeedInput",
5373
- setup(Z) {
5374
- const l = Fl(), U = Vl(), F = J({
5447
+ setup(t) {
5448
+ const l = dl(), U = Vl(), F = J({
5375
5449
  get: () => Math.log2(l.playbackSpeed) * 0.5 + 0.5,
5376
5450
  set: (n) => {
5377
5451
  const R = Math.pow(2, n * 2 - 1);
5378
5452
  U.setPlaybackSpeed(R);
5379
5453
  }
5380
- }), d = (n) => Math.floor(Math.pow(2, n * 2 - 1) * 100 + 0.5) + "", t = (n) => parseFloat(n), Q = (n) => n.replace(/\D/g, ""), V = (n) => n, a = (n) => {
5454
+ }), d = (n) => Math.floor(Math.pow(2, n * 2 - 1) * 100 + 0.5) + "", Z = (n) => parseFloat(n), Q = (n) => n.replace(/\D/g, ""), V = (n) => n, a = (n) => {
5381
5455
  const R = Math.log2(n / 100) * 0.5 + 0.5;
5382
5456
  return Math.min(Math.max(R, 0), 1);
5383
5457
  };
5384
- return (n, R) => (p(), Rl(lU, {
5458
+ return (n, R) => (N(), Rl(UU, {
5385
5459
  value: F.value,
5386
5460
  "onUpdate:value": R[0] || (R[0] = (m) => F.value = m),
5387
5461
  title: "Speed",
5388
5462
  color: "#336",
5389
5463
  "text-color": "#aad",
5390
5464
  "format-value": d,
5391
- "parse-value": t,
5465
+ "parse-value": Z,
5392
5466
  "validate-input": Q,
5393
5467
  "transform-slider-to-display": V,
5394
5468
  "transform-display-to-slider": a,
@@ -5398,23 +5472,23 @@ const OU = {
5398
5472
  }
5399
5473
  }, nF = {
5400
5474
  __name: "TimeInput",
5401
- setup(Z) {
5402
- const l = Fl(), U = Ql(), F = Vl(), d = (n) => n.toFixed(1), t = (n) => parseFloat(n), Q = (n) => n.replace(/[^0-9.]/g, ""), V = (n) => n, a = (n) => n;
5403
- return (n, R) => (p(), Rl(lU, {
5404
- value: r(l).currentTime,
5475
+ setup(t) {
5476
+ const l = dl(), U = ll(), F = Vl(), d = (n) => n.toFixed(1), Z = (n) => parseFloat(n), Q = (n) => n.replace(/[^0-9.]/g, ""), V = (n) => n, a = (n) => n;
5477
+ return (n, R) => (N(), Rl(UU, {
5478
+ value: T(l).currentTime,
5405
5479
  "onUpdate:value": [
5406
- R[0] || (R[0] = (m) => r(l).currentTime = m),
5407
- r(F).setTime
5480
+ R[0] || (R[0] = (m) => T(l).currentTime = m),
5481
+ T(F).setTime
5408
5482
  ],
5409
5483
  title: "Time",
5410
5484
  color: "#344",
5411
5485
  "focus-color": "#556868",
5412
5486
  "text-color": "#acc",
5413
5487
  "background-color": "#111117",
5414
- "slider-max": r(U).totalDuration,
5488
+ "slider-max": T(U).totalDuration,
5415
5489
  "slider-min": 0,
5416
5490
  "format-value": d,
5417
- "parse-value": t,
5491
+ "parse-value": Z,
5418
5492
  "validate-input": Q,
5419
5493
  "transform-slider-to-display": V,
5420
5494
  "transform-display-to-slider": a,
@@ -5423,20 +5497,20 @@ const OU = {
5423
5497
  }
5424
5498
  }, RF = { class: "inner" }, mF = {
5425
5499
  __name: "AudioButton",
5426
- setup(Z) {
5427
- const l = M(!1), U = () => l.value = !0, F = () => l.value = !1;
5428
- return (d, t) => (p(), y("div", {
5429
- class: C(["button-outer", { down: l.value }]),
5500
+ setup(t) {
5501
+ const l = x(!1), U = () => l.value = !0, F = () => l.value = !1;
5502
+ return (d, Z) => (N(), y("div", {
5503
+ class: L(["button-outer", { down: l.value }]),
5430
5504
  onPointerdown: U,
5431
5505
  onPointerup: F,
5432
5506
  onPointerleave: F
5433
5507
  }, [
5434
5508
  h("div", RF, [
5435
- tl(d.$slots, "default", {}, void 0, !0)
5509
+ Ql(d.$slots, "default", {}, void 0, !0)
5436
5510
  ])
5437
5511
  ], 34));
5438
5512
  }
5439
- }, dl = /* @__PURE__ */ j(mF, [["__scopeId", "data-v-0d7af06e"]]), eF = { class: "outer" }, WF = { class: "title" }, cF = { class: "buttons" }, bF = {
5513
+ }, tl = /* @__PURE__ */ H(mF, [["__scopeId", "data-v-0d7af06e"]]), eF = { class: "outer" }, WF = { class: "title" }, cF = { class: "buttons" }, bF = {
5440
5514
  class: "icon",
5441
5515
  viewBox: "0 0 48 48"
5442
5516
  }, sF = ["d"], hF = {
@@ -5449,125 +5523,118 @@ const OU = {
5449
5523
  }
5450
5524
  },
5451
5525
  emits: ["menu-click"],
5452
- setup(Z, { emit: l }) {
5453
- const U = Z, F = l, d = Ql(), t = Fl(), Q = Vl();
5454
- function V() {
5455
- t.isPlaying ? Q.stop() : Q.play();
5456
- }
5526
+ setup(t, { emit: l }) {
5527
+ const U = t, F = l, d = ll(), Z = dl(), Q = fl(), V = Vl();
5457
5528
  function a() {
5458
- const E = t.currentTime, G = d.beats.filter((Y) => Y.beat === 1).sort((Y, q) => Y.time - q.time);
5459
- let L = null;
5460
- for (let Y = G.length - 1; Y >= 0; Y--)
5461
- if (G[Y].time < E) {
5462
- L = G[Y];
5463
- break;
5464
- }
5465
- L && Q.setBar(L.bar, L.repeat);
5529
+ Z.isPlaying ? V.stop() : V.play();
5466
5530
  }
5467
5531
  function n() {
5468
- const E = t.currentTime, G = d.beats.filter((Y) => Y.beat === 1).sort((Y, q) => Y.time - q.time);
5469
- let L = null;
5470
- for (let Y = 0; Y < G.length; Y++)
5471
- if (G[Y].time > E) {
5472
- L = G[Y];
5473
- break;
5474
- }
5475
- L && Q.setBar(L.bar, L.repeat);
5532
+ const Y = Q.navigationPoints;
5533
+ if (Q.lastNavigationAction === "pause" && Q.lastPlayStartTime !== null) {
5534
+ V.setTime(Q.lastPlayStartTime), Q.setNavigationAction(null);
5535
+ return;
5536
+ }
5537
+ const p = Z.currentTime, r = Y.filter((q) => q.time < p - 0.01).pop();
5538
+ r && V.setTime(r.time);
5476
5539
  }
5477
5540
  function R() {
5478
- Q.playStartingNotes();
5541
+ const Y = Q.navigationPoints, p = Z.currentTime, r = Y.find((q) => q.time > p + 0.01);
5542
+ r && V.setTime(r.time);
5543
+ }
5544
+ function m() {
5545
+ V.playStartingNotes();
5479
5546
  }
5480
- const m = J(() => t.metronomeEnabled), e = J(() => t.leadInEnabled), c = M(!1), s = M(null);
5547
+ const e = J(() => Z.metronomeEnabled), c = J(() => Z.leadInEnabled), b = x(!1), B = x(null);
5481
5548
  function u() {
5482
5549
  if (U.externalMenuControl) {
5483
- F("menu-click"), Q.audioEngine.initializeAudioSystem().catch((E) => {
5484
- console.warn("Audio system pre-initialization failed:", E);
5550
+ F("menu-click"), V.audioEngine.initializeAudioSystem().catch((Y) => {
5551
+ console.warn("Audio system pre-initialization failed:", Y);
5485
5552
  });
5486
5553
  return;
5487
5554
  }
5488
- c.value = !c.value, c.value && Q.audioEngine.initializeAudioSystem().catch((E) => {
5489
- console.warn("Audio system pre-initialization failed:", E);
5555
+ b.value = !b.value, b.value && V.audioEngine.initializeAudioSystem().catch((Y) => {
5556
+ console.warn("Audio system pre-initialization failed:", Y);
5490
5557
  });
5491
5558
  }
5492
- function B() {
5493
- c.value = !1;
5559
+ function X() {
5560
+ b.value = !1;
5494
5561
  }
5495
- function X(E) {
5496
- s.value && !s.value.contains(E.target) && B();
5562
+ function E(Y) {
5563
+ B.value && !B.value.contains(Y.target) && X();
5497
5564
  }
5498
5565
  bl(() => {
5499
- document.addEventListener("click", X);
5566
+ document.addEventListener("click", E);
5500
5567
  }), cl(() => {
5501
- document.removeEventListener("click", X);
5568
+ document.removeEventListener("click", E);
5502
5569
  });
5503
- function T() {
5504
- Q.toggleMetronome();
5570
+ function z() {
5571
+ V.toggleMetronome();
5505
5572
  }
5506
- function I() {
5507
- Q.toggleLeadIn();
5573
+ function D() {
5574
+ V.toggleLeadIn();
5508
5575
  }
5509
- const K = J({
5510
- get: () => t.masterVolume,
5511
- set: (E) => t.setMasterVolume(E)
5512
- }), H = J({
5513
- get: () => t.metronomeVolume,
5514
- set: (E) => t.setMetronomeVolume(E)
5576
+ const g = J({
5577
+ get: () => Z.masterVolume,
5578
+ set: (Y) => Z.setMasterVolume(Y)
5579
+ }), j = J({
5580
+ get: () => Z.metronomeVolume,
5581
+ set: (Y) => Z.setMetronomeVolume(Y)
5515
5582
  });
5516
- return (E, G) => (p(), y("div", eF, [
5583
+ return (Y, p) => (N(), y("div", eF, [
5517
5584
  h("div", WF, [
5518
- x(Ol, {
5585
+ C(Ol, {
5519
5586
  class: "text",
5520
5587
  align: "centre"
5521
5588
  }, {
5522
- default: P(() => [
5523
- Nl(D(r(d).title), 1)
5589
+ default: w(() => [
5590
+ Nl(K(T(d).title), 1)
5524
5591
  ]),
5525
5592
  _: 1
5526
5593
  }),
5527
5594
  h("div", {
5528
5595
  class: "menu-container",
5529
5596
  ref_key: "menuRef",
5530
- ref: s
5597
+ ref: B
5531
5598
  }, [
5532
- (p(), y("svg", {
5599
+ (N(), y("svg", {
5533
5600
  class: "menu",
5534
5601
  viewBox: "0 -960 960 960",
5535
5602
  onClick: u
5536
- }, G[2] || (G[2] = [
5603
+ }, p[2] || (p[2] = [
5537
5604
  h("path", { d: "M120-240v-80h720v80H120Zm0-200v-80h720v80H120Zm0-200v-80h720v80H120Z" }, null, -1)
5538
5605
  ]))),
5539
- !Z.externalMenuControl && c.value && E.$slots.menu ? (p(), y("div", {
5606
+ !t.externalMenuControl && b.value && Y.$slots.menu ? (N(), y("div", {
5540
5607
  key: 0,
5541
5608
  class: "dropdown-menu",
5542
- onClick: B
5609
+ onClick: X
5543
5610
  }, [
5544
- tl(E.$slots, "menu", {}, void 0, !0)
5545
- ])) : f("", !0)
5611
+ Ql(Y.$slots, "menu", {}, void 0, !0)
5612
+ ])) : _("", !0)
5546
5613
  ], 512)
5547
5614
  ]),
5548
- x(Wl, {
5615
+ C(Wl, {
5549
5616
  class: "main",
5550
5617
  colour: "red",
5551
- value: K.value,
5552
- "onUpdate:value": G[0] || (G[0] = (L) => K.value = L)
5618
+ value: g.value,
5619
+ "onUpdate:value": p[0] || (p[0] = (r) => g.value = r)
5553
5620
  }, null, 8, ["value"]),
5554
- x(Wl, {
5621
+ C(Wl, {
5555
5622
  class: "tick",
5556
5623
  colour: "blue",
5557
- value: H.value,
5558
- "onUpdate:value": G[1] || (G[1] = (L) => H.value = L)
5624
+ value: j.value,
5625
+ "onUpdate:value": p[1] || (p[1] = (r) => j.value = r)
5559
5626
  }, null, 8, ["value"]),
5560
- G[8] || (G[8] = h("div", { class: "main-t" }, "Main", -1)),
5561
- G[9] || (G[9] = h("div", { class: "tick-t" }, "Tick", -1)),
5562
- x(tF, { class: "bar" }),
5563
- x(nF, { class: "time" }),
5564
- x(aF, { class: "speed" }),
5627
+ p[8] || (p[8] = h("div", { class: "main-t" }, "Main", -1)),
5628
+ p[9] || (p[9] = h("div", { class: "tick-t" }, "Tick", -1)),
5629
+ C(ZF, { class: "bar" }),
5630
+ C(nF, { class: "time" }),
5631
+ C(aF, { class: "speed" }),
5565
5632
  h("div", cF, [
5566
- x(dl, {
5633
+ C(tl, {
5567
5634
  class: "button",
5568
- onClick: a
5635
+ onClick: n
5569
5636
  }, {
5570
- default: P(() => G[3] || (G[3] = [
5637
+ default: w(() => p[3] || (p[3] = [
5571
5638
  h("svg", {
5572
5639
  class: "icon",
5573
5640
  viewBox: "0 0 48 48"
@@ -5578,24 +5645,24 @@ const OU = {
5578
5645
  _: 1,
5579
5646
  __: [3]
5580
5647
  }),
5581
- x(dl, {
5648
+ C(tl, {
5582
5649
  class: "button",
5583
- onClick: V
5650
+ onClick: a
5584
5651
  }, {
5585
- default: P(() => [
5586
- (p(), y("svg", bF, [
5652
+ default: w(() => [
5653
+ (N(), y("svg", bF, [
5587
5654
  h("path", {
5588
- d: r(t).isPlaying ? "M27.4 35.4V12.6h8v22.8Zm-14.8 0V12.6h8.05v22.8Z" : "M16 37.85v-28l22 14Z"
5655
+ d: T(Z).isPlaying ? "M27.4 35.4V12.6h8v22.8Zm-14.8 0V12.6h8.05v22.8Z" : "M16 37.85v-28l22 14Z"
5589
5656
  }, null, 8, sF)
5590
5657
  ]))
5591
5658
  ]),
5592
5659
  _: 1
5593
5660
  }),
5594
- x(dl, {
5661
+ C(tl, {
5595
5662
  class: "button",
5596
- onClick: n
5663
+ onClick: R
5597
5664
  }, {
5598
- default: P(() => G[4] || (G[4] = [
5665
+ default: w(() => p[4] || (p[4] = [
5599
5666
  h("svg", {
5600
5667
  class: "icon",
5601
5668
  viewBox: "0 0 48 48"
@@ -5606,39 +5673,39 @@ const OU = {
5606
5673
  _: 1,
5607
5674
  __: [4]
5608
5675
  }),
5609
- x(dl, {
5676
+ C(tl, {
5610
5677
  class: "button",
5611
- onClick: T
5678
+ onClick: z
5612
5679
  }, {
5613
- default: P(() => [
5614
- (p(), y("svg", {
5615
- class: C(["icon", m.value ? "on" : "off"]),
5680
+ default: w(() => [
5681
+ (N(), y("svg", {
5682
+ class: L(["icon", e.value ? "on" : "off"]),
5616
5683
  viewBox: "-128 -128 768 768"
5617
- }, G[5] || (G[5] = [
5684
+ }, p[5] || (p[5] = [
5618
5685
  h("path", { d: "m 463.84136,154.89339 c -6.42,-6.42 -16.83,-6.42 -23.251,0 -71.31197,70.35135 -136.61146,132.25426 -208.741,199.7 h -105.82 c 23.35495,-140.1063 67.13099,-217.59716 120.727,-318.357996 0.86,-0.803 2.209,-0.801 3.067,-10e-4 20.50653,37.383983 48.51152,88.812606 72.26194,147.190756 1.186,9.002 12.2214,17.4338 23.3242,11.71391 9.002,-1.186 11.1594,-12.2324 9.9724,-21.2344 -21.69905,-53.89113 -30.43965,-85.078342 -83.11454,-161.702266 -13.446,-12.55299965 -34.508,-12.55699965 -47.954,10e-4 C 126.80877,149.30021 96.099465,324.74626 77.091365,474.25139 c -2.829,21.473 13.907,40.535 35.543995,40.535 h 271.311 c 21.661,0 38.373,-19.087 35.544,-40.535 -8.26237,-52.34207 -14.88466,-100.7074 -24.7871,-157.02622 -6.40949,-11.78839 -8.3911,-14.9907 -17.4031,-13.8037 -9.002,1.186 -13.59751,8.0528 -12.41051,17.0548 l 5.66371,34.11712 h -83.159 c 64.35441,-63.86663 129.29308,-130.29894 176.448,-176.449 6.42,-6.42 6.42,-16.83 -10e-4,-23.251 z m -88.956,232.582 12.004,91.074 c 0.112,0.846 -0.148,1.701 -0.708,2.341 -0.566,0.645 -1.38,1.014 -2.235,1.014 h -271.311 c -0.855,0 -1.668,-0.369 -2.231,-1.011 -0.564,-0.643 -0.824,-1.499 -0.712,-2.347 l 12.003,-91.072 h 253.19 z" }, null, -1)
5619
5686
  ]), 2))
5620
5687
  ]),
5621
5688
  _: 1
5622
5689
  }),
5623
- x(dl, {
5690
+ C(tl, {
5624
5691
  class: "button",
5625
- onClick: I
5692
+ onClick: D
5626
5693
  }, {
5627
- default: P(() => [
5628
- (p(), y("svg", {
5629
- class: C(["icon", e.value ? "on" : "off"]),
5694
+ default: w(() => [
5695
+ (N(), y("svg", {
5696
+ class: L(["icon", c.value ? "on" : "off"]),
5630
5697
  viewBox: "-2 -2 28 28"
5631
- }, G[6] || (G[6] = [
5698
+ }, p[6] || (p[6] = [
5632
5699
  h("path", { d: "m 8.9838564,1.5166215 v 2 h 5.9999996 v -2 z m 2.9999996,3 c -4.9699996,0 -8.9999996,4.0299999 -8.9999996,8.9999995 0,4.97 4.02,9 8.9999996,9 4.98,0 9,-4.03 9,-9 0,-2.12 -0.740703,-4.0693745 -1.970703,-5.6093745 l 1.419922,-1.421875 c -0.43,-0.51 -0.900156,-0.9882031 -1.410156,-1.4082031 l -1.419922,1.4199219 c -1.55,-1.24 -3.499141,-1.9804688 -5.619141,-1.9804688 z m -1.789062,4.7480469 6,4.4999996 -6,4.5 z" }, null, -1)
5633
5700
  ]), 2))
5634
5701
  ]),
5635
5702
  _: 1
5636
5703
  }),
5637
- x(dl, {
5704
+ C(tl, {
5638
5705
  class: "button",
5639
- onClick: R
5706
+ onClick: m
5640
5707
  }, {
5641
- default: P(() => G[7] || (G[7] = [
5708
+ default: w(() => p[7] || (p[7] = [
5642
5709
  h("svg", {
5643
5710
  class: "icon",
5644
5711
  viewBox: "0 -960 960 960"
@@ -5653,7 +5720,7 @@ const OU = {
5653
5720
  ])
5654
5721
  ]));
5655
5722
  }
5656
- }, BF = /* @__PURE__ */ j(hF, [["__scopeId", "data-v-267b0f7a"]]), iF = { class: "init-progress" }, uF = {
5723
+ }, BF = /* @__PURE__ */ H(hF, [["__scopeId", "data-v-5e330688"]]), iF = { class: "init-progress" }, uF = {
5657
5724
  key: 0,
5658
5725
  class: "progress-track"
5659
5726
  }, JF = { class: "message-container" }, GF = {
@@ -5685,23 +5752,23 @@ const OU = {
5685
5752
  default: null
5686
5753
  }
5687
5754
  },
5688
- setup(Z) {
5689
- const l = Z, U = J(() => l.progress !== null), F = J(() => l.progress === null ? 0 : Math.max(0, Math.min(100, l.progress * 100))), d = J(() => l.hasError ? l.errorMessage : l.message);
5690
- return (t, Q) => (p(), y("div", iF, [
5691
- U.value ? (p(), y("div", uF, [
5755
+ setup(t) {
5756
+ const l = t, U = J(() => l.progress !== null), F = J(() => l.progress === null ? 0 : Math.max(0, Math.min(100, l.progress * 100))), d = J(() => l.hasError ? l.errorMessage : l.message);
5757
+ return (Z, Q) => (N(), y("div", iF, [
5758
+ U.value ? (N(), y("div", uF, [
5692
5759
  h("div", {
5693
5760
  class: "progress-fill",
5694
5761
  style: gl({ width: `${F.value}%` })
5695
5762
  }, null, 4)
5696
- ])) : f("", !0),
5763
+ ])) : _("", !0),
5697
5764
  h("div", JF, [
5698
5765
  h("div", {
5699
- class: C(["message", { error: Z.hasError }])
5700
- }, D(d.value), 3)
5766
+ class: L(["message", { error: t.hasError }])
5767
+ }, K(d.value), 3)
5701
5768
  ])
5702
5769
  ]));
5703
5770
  }
5704
- }, oF = /* @__PURE__ */ j(GF, [["__scopeId", "data-v-a9ed87f2"]]), SF = sl("initialization", {
5771
+ }, oF = /* @__PURE__ */ H(GF, [["__scopeId", "data-v-a9ed87f2"]]), SF = sl("initialization", {
5705
5772
  state: () => ({
5706
5773
  // Current initialization stage
5707
5774
  currentStage: null,
@@ -5725,15 +5792,15 @@ const OU = {
5725
5792
  * @param {string} event.message - Human-readable message
5726
5793
  * @param {number} [event.progress] - Optional progress (0-1)
5727
5794
  */
5728
- updateProgress(Z) {
5729
- this.currentStage = Z.stage, this.message = Z.message, this.progress = Z.progress ?? null, Z.stage === "ready" ? (this.isInitializing = !1, this.isReady = !0) : (this.isInitializing = !0, this.isReady = !1), this.hasError = !1, this.errorMessage = null;
5795
+ updateProgress(t) {
5796
+ this.currentStage = t.stage, this.message = t.message, this.progress = t.progress ?? null, t.stage === "ready" ? (this.isInitializing = !1, this.isReady = !0) : (this.isInitializing = !0, this.isReady = !1), this.hasError = !1, this.errorMessage = null;
5730
5797
  },
5731
5798
  /**
5732
5799
  * Set error state
5733
5800
  * @param {string} message - Error message
5734
5801
  */
5735
- setError(Z) {
5736
- this.hasError = !0, this.errorMessage = Z, this.isInitializing = !1, this.isReady = !1;
5802
+ setError(t) {
5803
+ this.hasError = !0, this.errorMessage = t, this.isInitializing = !1, this.isReady = !1;
5737
5804
  },
5738
5805
  /**
5739
5806
  * Reset initialization state
@@ -5746,8 +5813,8 @@ const OU = {
5746
5813
  * Should be called once during app startup
5747
5814
  */
5748
5815
  initializeListeners() {
5749
- b.on("initProgress", (Z) => {
5750
- this.updateProgress(Z);
5816
+ s.on("initProgress", (t) => {
5817
+ this.updateProgress(t);
5751
5818
  });
5752
5819
  }
5753
5820
  },
@@ -5755,12 +5822,12 @@ const OU = {
5755
5822
  /**
5756
5823
  * Whether to show the progress indicator
5757
5824
  */
5758
- shouldShowProgress: (Z) => Z.isInitializing || Z.hasError,
5825
+ shouldShowProgress: (t) => t.isInitializing || t.hasError,
5759
5826
  /**
5760
5827
  * Whether the progress bar should be visible
5761
5828
  * Only show for stages that have progress data
5762
5829
  */
5763
- hasProgressBar: (Z) => Z.progress !== null
5830
+ hasProgressBar: (t) => t.progress !== null
5764
5831
  }
5765
5832
  }), XF = { class: "container" }, NF = { class: "panel" }, pF = {
5766
5833
  key: 0,
@@ -5780,19 +5847,19 @@ const OU = {
5780
5847
  }
5781
5848
  },
5782
5849
  emits: ["menu-click"],
5783
- setup(Z, { emit: l }) {
5784
- ll((s) => ({
5850
+ setup(t, { emit: l }) {
5851
+ Ul((b) => ({
5785
5852
  "3579bdbc": m.value,
5786
5853
  "3572ead6": e.value,
5787
5854
  "78cf8203": c.value
5788
5855
  }));
5789
- const U = Z, F = l, d = Ql(), t = Fl(), Q = SF();
5856
+ const U = t, F = l, d = ll(), Z = dl(), Q = SF();
5790
5857
  bl(() => {
5791
5858
  Q.initializeListeners();
5792
5859
  });
5793
- const V = A("container"), { width: a } = Ul(V), n = J(() => t.isLoaded), R = J(() => {
5794
- const s = a.value, u = d.parts.length;
5795
- return s < 640 || s < Cl * u + zl ? 0 : s < xl * u + Il ? 1 : s < Ml * u + vl ? 2 : 3;
5860
+ const V = f("container"), { width: a } = Fl(V), n = J(() => Z.isLoaded), R = J(() => {
5861
+ const b = a.value, B = d.parts.length;
5862
+ return b < 640 || b < Cl * B + zl ? 0 : b < xl * B + Il ? 1 : b < Ml * B + vl ? 2 : 3;
5796
5863
  }), m = J(() => {
5797
5864
  switch (R.value) {
5798
5865
  case 0:
@@ -5816,54 +5883,54 @@ const OU = {
5816
5883
  return `${Ml}px `.repeat(d.parts.length) + `${vl}px`;
5817
5884
  }
5818
5885
  }), c = J(() => {
5819
- const s = [...d.parts.keys()];
5820
- return R.value > 0 ? '"' + s.map((u) => "part" + u).join(" ") + ' controls"' : '"controls" ' + s.map((u) => '"part' + u + '"').join(" ");
5886
+ const b = [...d.parts.keys()];
5887
+ return R.value > 0 ? '"' + b.map((B) => "part" + B).join(" ") + ' controls"' : '"controls" ' + b.map((B) => '"part' + B + '"').join(" ");
5821
5888
  });
5822
- return (s, u) => (p(), y("div", {
5889
+ return (b, B) => (N(), y("div", {
5823
5890
  class: "outer",
5824
5891
  ref_key: "container",
5825
5892
  ref: V
5826
5893
  }, [
5827
5894
  h("div", XF, [
5828
5895
  h("div", NF, [
5829
- (p(!0), y(nl, null, Xl(r(d).parts, (B, X) => (p(), Rl(AU, {
5830
- key: B.name,
5831
- class: C("part" + X),
5832
- name: B.name,
5833
- volume: B.volume,
5834
- "onUpdate:volume": (T) => B.volume = T,
5835
- solo: B.solo,
5836
- "onUpdate:solo": (T) => B.solo = T,
5837
- mute: B.mute,
5838
- "onUpdate:mute": (T) => B.mute = T,
5896
+ (N(!0), y(nl, null, Xl(T(d).parts, (u, X) => (N(), Rl(AU, {
5897
+ key: u.name,
5898
+ class: L("part" + X),
5899
+ name: u.name,
5900
+ volume: u.volume,
5901
+ "onUpdate:volume": (E) => u.volume = E,
5902
+ solo: u.solo,
5903
+ "onUpdate:solo": (E) => u.solo = E,
5904
+ mute: u.mute,
5905
+ "onUpdate:mute": (E) => u.mute = E,
5839
5906
  ref_for: !0,
5840
5907
  ref: "parts"
5841
5908
  }, null, 8, ["class", "name", "volume", "onUpdate:volume", "solo", "onUpdate:solo", "mute", "onUpdate:mute"]))), 128)),
5842
- x(BF, {
5843
- title: r(d).title,
5909
+ C(BF, {
5910
+ title: T(d).title,
5844
5911
  "external-menu-control": U.externalMenuControl,
5845
- onMenuClick: u[0] || (u[0] = (B) => F("menu-click")),
5912
+ onMenuClick: B[0] || (B[0] = (u) => F("menu-click")),
5846
5913
  class: "controls"
5847
5914
  }, {
5848
- menu: P(() => [
5849
- tl(s.$slots, "menu", {}, void 0, !0)
5915
+ menu: w(() => [
5916
+ Ql(b.$slots, "menu", {}, void 0, !0)
5850
5917
  ]),
5851
5918
  _: 3
5852
5919
  }, 8, ["title", "external-menu-control"]),
5853
- n.value ? f("", !0) : (p(), y("div", pF)),
5854
- U.showInitProgress && r(Q).shouldShowProgress ? (p(), Rl(oF, {
5920
+ n.value ? _("", !0) : (N(), y("div", pF)),
5921
+ U.showInitProgress && T(Q).shouldShowProgress ? (N(), Rl(oF, {
5855
5922
  key: 1,
5856
- stage: r(Q).currentStage,
5857
- message: r(Q).message,
5858
- progress: r(Q).progress,
5859
- "has-error": r(Q).hasError,
5860
- "error-message": r(Q).errorMessage
5861
- }, null, 8, ["stage", "message", "progress", "has-error", "error-message"])) : f("", !0)
5923
+ stage: T(Q).currentStage,
5924
+ message: T(Q).message,
5925
+ progress: T(Q).progress,
5926
+ "has-error": T(Q).hasError,
5927
+ "error-message": T(Q).errorMessage
5928
+ }, null, 8, ["stage", "message", "progress", "has-error", "error-message"])) : _("", !0)
5862
5929
  ])
5863
5930
  ])
5864
5931
  ], 512));
5865
5932
  }
5866
- }, HF = /* @__PURE__ */ j(rF, [["__scopeId", "data-v-7163154f"]]), LF = { class: "outer" }, CF = { class: "mid" }, xF = { class: "inner" }, MF = {
5933
+ }, HF = /* @__PURE__ */ H(rF, [["__scopeId", "data-v-7163154f"]]), LF = { class: "outer" }, CF = { class: "mid" }, xF = { class: "inner" }, MF = {
5867
5934
  key: 0,
5868
5935
  class: "content"
5869
5936
  }, zF = {
@@ -5878,24 +5945,24 @@ const OU = {
5878
5945
  default: ""
5879
5946
  }
5880
5947
  },
5881
- setup(Z) {
5882
- return ll((l) => ({
5883
- "66bea586": Z.colour
5884
- })), (l, U) => (p(), y("div", LF, [
5948
+ setup(t) {
5949
+ return Ul((l) => ({
5950
+ "66bea586": t.colour
5951
+ })), (l, U) => (N(), y("div", LF, [
5885
5952
  h("div", CF, [
5886
5953
  h("div", xF, [
5887
- Z.text || l.$slots.default ? (p(), y("div", MF, [
5888
- Nl(D(Z.text) + " ", 1),
5889
- tl(l.$slots, "default", {}, void 0, !0)
5890
- ])) : f("", !0)
5954
+ t.text || l.$slots.default ? (N(), y("div", MF, [
5955
+ Nl(K(t.text) + " ", 1),
5956
+ Ql(l.$slots, "default", {}, void 0, !0)
5957
+ ])) : _("", !0)
5891
5958
  ])
5892
5959
  ])
5893
5960
  ]));
5894
5961
  }
5895
- }, DF = /* @__PURE__ */ j(zF, [["__scopeId", "data-v-dff76c48"]]);
5962
+ }, DF = /* @__PURE__ */ H(zF, [["__scopeId", "data-v-dff76c48"]]);
5896
5963
  class IF {
5897
5964
  constructor() {
5898
- this.eventBus = fl(), this.currentTime = 0, this.isPlaying = !1, this.playbackSpeed = 1, this.masterVolume = 0.75, this.parts = /* @__PURE__ */ new Map(), this.playbackTimer = null, this.lastTimestamp = 0;
5965
+ this.eventBus = _l(), this.currentTime = 0, this.isPlaying = !1, this.playbackSpeed = 1, this.masterVolume = 0.75, this.parts = /* @__PURE__ */ new Map(), this.playbackTimer = null, this.lastTimestamp = 0;
5899
5966
  }
5900
5967
  // Initialize with musical data
5901
5968
  initialize(l) {
@@ -6041,10 +6108,10 @@ class IF {
6041
6108
  }
6042
6109
  new IF();
6043
6110
  export {
6044
- dl as AudioButton,
6111
+ tl as AudioButton,
6045
6112
  Wl as AudioSlider,
6046
- tF as BarInput,
6047
- lU as BaseNumericInput,
6113
+ ZF as BarInput,
6114
+ UU as BaseNumericInput,
6048
6115
  ol as DEV_MODE,
6049
6116
  IF as DummyAudioEngine,
6050
6117
  oF as InitializationProgress,
@@ -6055,14 +6122,14 @@ export {
6055
6122
  aF as SpeedInput,
6056
6123
  nF as TimeInput,
6057
6124
  Ol as TitleText,
6058
- YU as TriState,
6125
+ EU as TriState,
6059
6126
  PU as audioEngineConfig,
6060
6127
  Al as isDevFeature,
6061
6128
  KF as isDevMode,
6062
- Fl as useAudioStateStore,
6063
- Ul as useElementSize,
6129
+ dl as useAudioStateStore,
6130
+ Fl as useElementSize,
6064
6131
  SF as useInitializationState,
6065
6132
  Vl as useMasterAudioControl,
6066
- Ql as useMusicDataStore,
6067
- EU as usePlaybackStateStore
6133
+ ll as useMusicDataStore,
6134
+ fl as usePlaybackStateStore
6068
6135
  };