@hfd-sdk/keyboard-kit 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,8 @@
1
- import { c as Y, o as xe, w as ae, t as F, r as L, d as be, a as He, b as ee, e as te, f as X, g as ge, n as se, u as $, F as ve, h as fe, i as ke, j as oe, s as Ce, k as Ee, l as Me, m as _e, p as he, q as Ve, v as Ne, x as Pe } from "../runtime-core.es.js";
1
+ import { d as Y, o as xe, w as ae, t as D, r as M, e as be, f as _e, g as ee, h as te, i as j, j as ge, n as se, u as $, F as ve, k as fe, l as Ce, m as oe, s as ke, c as Ee, p as Me, q as He, v as he, x as Ve, y as Ne, z as Pe } from "../runtime-core.es.js";
2
2
  import { serializePreset as Ke } from "../runtime.es.js";
3
- import { deserializePreset as Pt } from "../runtime.es.js";
4
- const me = 40, De = 0.1, qe = 3;
3
+ import { deserializePreset as Mt } from "../runtime.es.js";
4
+ import { c as qe, g as Be, b as Fe, a as De } from "../assert-hfd-device.js";
5
+ const me = 40, We = 0.1, Oe = 3;
5
6
  function J(e) {
6
7
  return Math.round(e * 100) / 100;
7
8
  }
@@ -14,346 +15,303 @@ function ye(e) {
14
15
  rotation: J(e.rotation)
15
16
  };
16
17
  }
17
- const Be = {
18
+ const $e = {
18
19
  "scale-se": { x: 1, y: 1 },
19
20
  "scale-sw": { x: -1, y: 1 },
20
21
  "scale-ne": { x: 1, y: -1 },
21
22
  "scale-nw": { x: -1, y: -1 }
22
- }, Fe = {
23
+ }, je = {
23
24
  "resize-e": { x: -1, y: 0 },
24
25
  "resize-w": { x: 1, y: 0 },
25
26
  "resize-n": { x: 0, y: 1 },
26
27
  "resize-s": { x: 0, y: -1 }
27
- }, Oe = {
28
+ }, Ge = {
28
29
  "scale-se": { x: -1, y: -1 },
29
30
  "scale-sw": { x: 1, y: -1 },
30
31
  "scale-ne": { x: -1, y: 1 },
31
32
  "scale-nw": { x: 1, y: 1 }
32
33
  };
33
- function We(e) {
34
- const t = L({ x: 0, y: 0 }), a = L(1), o = L(1), n = L(0), c = L(!0), k = L(1), i = L({ width: 0, height: 0 }), f = Y(() => c.value ? a.value : o.value), m = Y(() => ({
34
+ function Ue(e) {
35
+ const t = M({ x: 0, y: 0 }), a = M(1), i = M(1), s = M(0), d = M(!0), P = M(1), u = M({ width: 0, height: 0 }), y = Y(() => d.value ? a.value : i.value), k = Y(() => ({
35
36
  left: `${t.value.x}px`,
36
37
  top: `${t.value.y}px`,
37
- transform: `translate(-50%, -50%) scale(${a.value}, ${f.value}) rotate(${n.value}deg)`,
38
+ transform: `translate(-50%, -50%) scale(${a.value}, ${y.value}) rotate(${s.value}deg)`,
38
39
  transformOrigin: "center center"
39
40
  }));
40
- let d = null;
41
- function w() {
41
+ let g = null;
42
+ function p() {
42
43
  return {
43
- width: F(e.canvasWidth),
44
- height: F(e.canvasHeight)
44
+ width: D(e.canvasWidth),
45
+ height: D(e.canvasHeight)
45
46
  };
46
47
  }
47
- function y(r, s) {
48
- const { width: l, height: v } = w();
49
- return !r || !s ? 1 : Math.min((l - me * 2) / r, (v - me * 2) / s, 1);
48
+ function b(n, r) {
49
+ const { width: o, height: c } = p();
50
+ return !n || !r ? 1 : Math.min((o - me * 2) / n, (c - me * 2) / r, 1);
50
51
  }
51
- function x(r) {
52
- return Math.min(qe, Math.max(De, r));
52
+ function x(n) {
53
+ return Math.min(Oe, Math.max(We, n));
53
54
  }
54
- function b(r, s) {
55
- const { width: l, height: v } = w(), h = i.value.width * a.value / 2, g = i.value.height * f.value / 2;
55
+ function w(n, r) {
56
+ const { width: o, height: c } = p(), v = u.value.width * a.value / 2, f = u.value.height * y.value / 2;
56
57
  return {
57
- x: Math.max(h, Math.min(l - h, r)),
58
- y: Math.max(g, Math.min(v - g, s))
58
+ x: Math.max(v, Math.min(o - v, n)),
59
+ y: Math.max(f, Math.min(c - f, r))
59
60
  };
60
61
  }
61
- function E() {
62
+ function L() {
62
63
  return ye({
63
64
  x: t.value.x,
64
65
  y: t.value.y,
65
- width: i.value.width * a.value,
66
- height: i.value.height * f.value,
67
- rotation: n.value
66
+ width: u.value.width * a.value,
67
+ height: u.value.height * y.value,
68
+ rotation: s.value
68
69
  });
69
70
  }
70
- function A(r) {
71
- if (!i.value.width || !i.value.height) return;
72
- const s = ye(r), l = x(s.width / i.value.width), v = x(s.height / i.value.height);
73
- a.value = l, o.value = v, c.value = Math.abs(l - v) < 1e-3, n.value = s.rotation, t.value = b(s.x, s.y);
74
- }
75
- function H() {
76
- var r;
77
- (r = F(e.onLayoutChange)) == null || r(E());
78
- }
79
- function M() {
80
- H();
81
- }
82
- async function K(r, s = !1) {
83
- if (!r) return;
84
- if (i.value = {
85
- width: r.offsetWidth,
86
- height: r.offsetHeight
87
- }, !s) {
88
- const g = F(e.initialLayout);
89
- if (g) {
90
- A(g);
71
+ function A(n) {
72
+ if (!u.value.width || !u.value.height) return;
73
+ const r = ye(n), o = x(r.width / u.value.width), c = x(r.height / u.value.height);
74
+ a.value = o, i.value = c, d.value = Math.abs(o - c) < 1e-3, s.value = r.rotation, t.value = w(r.x, r.y);
75
+ }
76
+ function _() {
77
+ var n;
78
+ (n = D(e.onLayoutChange)) == null || n(L());
79
+ }
80
+ function C() {
81
+ _();
82
+ }
83
+ async function K(n, r = !1) {
84
+ if (!n) return;
85
+ if (u.value = {
86
+ width: n.offsetWidth,
87
+ height: n.offsetHeight
88
+ }, !r) {
89
+ const f = D(e.initialLayout);
90
+ if (f) {
91
+ A(f);
91
92
  return;
92
93
  }
93
94
  }
94
- const l = y(i.value.width, i.value.height);
95
- k.value = l, a.value = l, o.value = l, n.value = 0, c.value = !0;
96
- const { width: v, height: h } = w();
97
- t.value = { x: v / 2, y: h / 2 };
95
+ const o = b(u.value.width, u.value.height);
96
+ P.value = o, a.value = o, i.value = o, s.value = 0, d.value = !0;
97
+ const { width: c, height: v } = p();
98
+ t.value = { x: c / 2, y: v / 2 };
98
99
  }
99
- async function D(r) {
100
- await K(r, !0), H();
100
+ async function q(n) {
101
+ await K(n, !0), _();
101
102
  }
102
- function p() {
103
- c.value = !c.value, c.value && (o.value = a.value);
103
+ function h() {
104
+ d.value = !d.value, d.value && (i.value = a.value);
104
105
  }
105
- function S(r, s, l, v) {
106
- const h = -n.value * Math.PI / 180, g = r - l, P = s - v;
106
+ function z(n, r, o, c) {
107
+ const v = -s.value * Math.PI / 180, f = n - o, E = r - c;
107
108
  return {
108
- x: g * Math.cos(h) - P * Math.sin(h),
109
- y: g * Math.sin(h) + P * Math.cos(h)
109
+ x: f * Math.cos(v) - E * Math.sin(v),
110
+ y: f * Math.sin(v) + E * Math.cos(v)
110
111
  };
111
112
  }
112
- function V(r, s) {
113
- var h;
114
- const l = (h = e.getOverlayEl) == null ? void 0 : h.call(e);
115
- if (!l) return { x: r, y: s };
116
- const v = l.getBoundingClientRect();
117
- return { x: r - v.left, y: s - v.top };
113
+ function V(n, r) {
114
+ var v;
115
+ const o = (v = e.getOverlayEl) == null ? void 0 : v.call(e);
116
+ if (!o) return { x: n, y: r };
117
+ const c = o.getBoundingClientRect();
118
+ return { x: n - c.left, y: r - c.top };
118
119
  }
119
- function B(r, s, l, v) {
120
- return Math.atan2(s - v, r - l) * 180 / Math.PI;
120
+ function F(n, r, o, c) {
121
+ return Math.atan2(r - c, n - o) * 180 / Math.PI;
121
122
  }
122
- function C(r, s, l, v, h) {
123
- const g = h * Math.PI / 180;
123
+ function m(n, r, o, c, v) {
124
+ const f = v * Math.PI / 180;
124
125
  return {
125
- x: r + l * Math.cos(g) - v * Math.sin(g),
126
- y: s + l * Math.sin(g) + v * Math.cos(g)
126
+ x: n + o * Math.cos(f) - c * Math.sin(f),
127
+ y: r + o * Math.sin(f) + c * Math.cos(f)
127
128
  };
128
129
  }
129
- function O(r, s, l, v, h) {
130
- const g = [
131
- C(r, s, -l, -v, h),
132
- C(r, s, l, -v, h),
133
- C(r, s, -l, v, h),
134
- C(r, s, l, v, h)
130
+ function W(n, r, o, c, v) {
131
+ const f = [
132
+ m(n, r, -o, -c, v),
133
+ m(n, r, o, -c, v),
134
+ m(n, r, -o, c, v),
135
+ m(n, r, o, c, v)
135
136
  ];
136
137
  return {
137
- minX: Math.min(...g.map((P) => P.x)),
138
- minY: Math.min(...g.map((P) => P.y)),
139
- maxX: Math.max(...g.map((P) => P.x)),
140
- maxY: Math.max(...g.map((P) => P.y))
138
+ minX: Math.min(...f.map((E) => E.x)),
139
+ minY: Math.min(...f.map((E) => E.y)),
140
+ maxX: Math.max(...f.map((E) => E.x)),
141
+ maxY: Math.max(...f.map((E) => E.y))
141
142
  };
142
143
  }
143
- function j(r, s, l, v, h, g, P) {
144
- const R = g * l / 2, _ = P * v / 2, T = C(r.x, r.y, -s.x * R, -s.y * _, h), z = O(T.x, T.y, R, _, h), { width: q, height: N } = w();
145
- return z.minX >= 0 && z.minY >= 0 && z.maxX <= q && z.maxY <= N;
146
- }
147
- function le(r, s, l, v, h, g, P, R, _) {
148
- if (j(r, s, h, g, P, R, _))
149
- return { scale: h, scaleY: g };
150
- if (!j(r, s, l, v, P, R, _))
151
- return { scale: l, scaleY: v };
152
- let T = 0, z = 1;
153
- for (let q = 0; q < 20; q++) {
154
- const N = (T + z) / 2, G = l + N * (h - l), Z = v + N * (g - v);
155
- j(r, s, G, Z, P, R, _) ? T = N : z = N;
144
+ function G(n, r, o, c, v, f, E) {
145
+ const I = f * o / 2, H = E * c / 2, T = m(n.x, n.y, -r.x * I, -r.y * H, v), S = W(T.x, T.y, I, H, v), { width: B, height: N } = p();
146
+ return S.minX >= 0 && S.minY >= 0 && S.maxX <= B && S.maxY <= N;
147
+ }
148
+ function le(n, r, o, c, v, f, E, I, H) {
149
+ if (G(n, r, v, f, E, I, H))
150
+ return { scale: v, scaleY: f };
151
+ if (!G(n, r, o, c, E, I, H))
152
+ return { scale: o, scaleY: c };
153
+ let T = 0, S = 1;
154
+ for (let B = 0; B < 20; B++) {
155
+ const N = (T + S) / 2, U = o + N * (v - o), Z = c + N * (f - c);
156
+ G(n, r, U, Z, E, I, H) ? T = N : S = N;
156
157
  }
157
158
  return {
158
- scale: l + T * (h - l),
159
- scaleY: v + T * (g - v)
159
+ scale: o + T * (v - o),
160
+ scaleY: c + T * (f - c)
160
161
  };
161
162
  }
162
- function ne(r, s, l, v, h, g, P, R) {
163
- const _ = i.value.width || 1, T = i.value.height || 1, z = _ * g / 2, q = T * P / 2, N = C(
163
+ function ne(n, r, o, c, v, f, E, I) {
164
+ const H = u.value.width || 1, T = u.value.height || 1, S = H * f / 2, B = T * E / 2, N = m(
165
+ c,
164
166
  v,
165
- h,
166
- r.x * z,
167
- r.y * q,
168
- R
169
- ), G = le(
167
+ n.x * S,
168
+ n.y * B,
169
+ I
170
+ ), U = le(
170
171
  N,
172
+ n,
173
+ f,
174
+ E,
171
175
  r,
172
- g,
173
- P,
174
- s,
175
- l,
176
- R,
177
- _,
176
+ o,
177
+ I,
178
+ H,
178
179
  T
179
- ), Z = _ * G.scale / 2, Re = T * G.scaleY / 2, Ae = C(
180
+ ), Z = H * U.scale / 2, Ie = T * U.scaleY / 2, Ae = m(
180
181
  N.x,
181
182
  N.y,
182
- -r.x * Z,
183
- -r.y * Re,
184
- R
183
+ -n.x * Z,
184
+ -n.y * Ie,
185
+ I
185
186
  );
186
- a.value = G.scale, o.value = G.scaleY, t.value = Ae;
187
- }
188
- function ce(r, s, l, v, h, g, P) {
189
- const R = Be[r], _ = Oe[r], T = i.value.width || 1, z = i.value.height || 1;
190
- let q, N;
191
- if (c.value) {
192
- const G = Math.max(T, z), Z = (s.x * R.x + s.y * R.y) / 2;
193
- q = x(h + Z / G), N = q;
187
+ a.value = U.scale, i.value = U.scaleY, t.value = Ae;
188
+ }
189
+ function ue(n, r, o, c, v, f, E) {
190
+ const I = $e[n], H = Ge[n], T = u.value.width || 1, S = u.value.height || 1;
191
+ let B, N;
192
+ if (d.value) {
193
+ const U = Math.max(T, S), Z = (r.x * I.x + r.y * I.y) / 2;
194
+ B = x(v + Z / U), N = B;
194
195
  } else
195
- q = x(h + s.x * R.x / T), N = x(g + s.y * R.y / z);
196
- ne(_, q, N, l, v, h, g, P);
197
- }
198
- function ue(r, s, l, v, h, g, P) {
199
- const R = i.value.width || 1, _ = i.value.height || 1;
200
- let T = h, z = g;
201
- r === "resize-e" ? (T = x(h + s.x / R), c.value && (z = T)) : r === "resize-w" ? (T = x(h - s.x / R), c.value && (z = T)) : r === "resize-s" ? (z = x(g + s.y / _), c.value && (T = z)) : r === "resize-n" && (z = x(g - s.y / _), c.value && (T = z)), ne(
202
- Fe[r],
196
+ B = x(v + r.x * I.x / T), N = x(f + r.y * I.y / S);
197
+ ne(H, B, N, o, c, v, f, E);
198
+ }
199
+ function ce(n, r, o, c, v, f, E) {
200
+ const I = u.value.width || 1, H = u.value.height || 1;
201
+ let T = v, S = f;
202
+ n === "resize-e" ? (T = x(v + r.x / I), d.value && (S = T)) : n === "resize-w" ? (T = x(v - r.x / I), d.value && (S = T)) : n === "resize-s" ? (S = x(f + r.y / H), d.value && (T = S)) : n === "resize-n" && (S = x(f - r.y / H), d.value && (T = S)), ne(
203
+ je[n],
203
204
  T,
204
- z,
205
- l,
205
+ S,
206
+ o,
207
+ c,
206
208
  v,
207
- h,
208
- g,
209
- P
209
+ f,
210
+ E
210
211
  );
211
212
  }
212
- function U(r, s) {
213
- s.preventDefault(), s.stopPropagation();
214
- const l = V(s.clientX, s.clientY), v = B(l.x, l.y, t.value.x, t.value.y);
215
- d = {
216
- mode: r,
217
- startLocalX: l.x,
218
- startLocalY: l.y,
213
+ function X(n, r) {
214
+ r.preventDefault(), r.stopPropagation();
215
+ const o = V(r.clientX, r.clientY), c = F(o.x, o.y, t.value.x, t.value.y);
216
+ g = {
217
+ mode: n,
218
+ startLocalX: o.x,
219
+ startLocalY: o.y,
219
220
  startPosX: t.value.x,
220
221
  startPosY: t.value.y,
221
222
  startScale: a.value,
222
- startScaleY: o.value,
223
- startRotation: n.value,
224
- startAngle: v
223
+ startScaleY: i.value,
224
+ startRotation: s.value,
225
+ startAngle: c
225
226
  }, window.addEventListener("mousemove", re), window.addEventListener("mouseup", Q);
226
227
  }
227
- function re(r) {
228
- if (!d) return;
229
- const s = V(r.clientX, r.clientY), { mode: l, startLocalX: v, startLocalY: h, startPosX: g, startPosY: P, startScale: R, startScaleY: _, startRotation: T, startAngle: z } = d;
230
- if (l === "drag") {
231
- t.value = b(g + (s.x - v), P + (s.y - h));
228
+ function re(n) {
229
+ if (!g) return;
230
+ const r = V(n.clientX, n.clientY), { mode: o, startLocalX: c, startLocalY: v, startPosX: f, startPosY: E, startScale: I, startScaleY: H, startRotation: T, startAngle: S } = g;
231
+ if (o === "drag") {
232
+ t.value = w(f + (r.x - c), E + (r.y - v));
232
233
  return;
233
234
  }
234
- if (l.startsWith("rotate-")) {
235
- const N = B(s.x, s.y, t.value.x, t.value.y);
236
- n.value = T + (N - z);
235
+ if (o.startsWith("rotate-")) {
236
+ const N = F(r.x, r.y, t.value.x, t.value.y);
237
+ s.value = T + (N - S);
237
238
  return;
238
239
  }
239
- const q = S(s.x, s.y, v, h);
240
- if (l.startsWith("scale-")) {
241
- ce(
242
- l,
243
- q,
244
- g,
245
- P,
246
- R,
247
- _,
240
+ const B = z(r.x, r.y, c, v);
241
+ if (o.startsWith("scale-")) {
242
+ ue(
243
+ o,
244
+ B,
245
+ f,
246
+ E,
247
+ I,
248
+ H,
248
249
  T
249
250
  );
250
251
  return;
251
252
  }
252
- (l === "resize-e" || l === "resize-w" || l === "resize-n" || l === "resize-s") && ue(l, q, g, P, R, _, T);
253
+ (o === "resize-e" || o === "resize-w" || o === "resize-n" || o === "resize-s") && ce(o, B, f, E, I, H, T);
253
254
  }
254
255
  function Q() {
255
- d && M(), d = null, window.removeEventListener("mousemove", re), window.removeEventListener("mouseup", Q);
256
+ g && C(), g = null, window.removeEventListener("mousemove", re), window.removeEventListener("mouseup", Q);
256
257
  }
257
- function de(r) {
258
- U("drag", r);
258
+ function de(n) {
259
+ X("drag", n);
259
260
  }
260
- function u(r, s) {
261
- U(r, s);
261
+ function l(n, r) {
262
+ X(n, r);
262
263
  }
263
- function I(r, s) {
264
- U(r, s);
264
+ function R(n, r) {
265
+ X(n, r);
265
266
  }
266
- function W(r, s) {
267
- U(r, s);
267
+ function O(n, r) {
268
+ X(n, r);
268
269
  }
269
270
  return xe(() => {
270
271
  Q();
271
272
  }), ae(
272
- () => [F(e.canvasWidth), F(e.canvasHeight)],
273
+ () => [D(e.canvasWidth), D(e.canvasHeight)],
273
274
  () => {
274
- t.value = b(t.value.x, t.value.y);
275
+ t.value = w(t.value.x, t.value.y);
275
276
  }
276
277
  ), {
277
- lockAspectRatio: c,
278
- rotation: n,
279
- wrapperStyle: m,
278
+ lockAspectRatio: d,
279
+ rotation: s,
280
+ wrapperStyle: k,
280
281
  applyFitScale: K,
281
- getLayout: E,
282
- resetKeyboardLayout: D,
283
- toggleLockAspectRatio: p,
282
+ getLayout: L,
283
+ resetKeyboardLayout: q,
284
+ toggleLockAspectRatio: h,
284
285
  onDragStart: de,
285
- onResizeStart: u,
286
- onScaleCornerStart: I,
287
- onRotateStart: W
286
+ onResizeStart: l,
287
+ onScaleCornerStart: R,
288
+ onRotateStart: O
288
289
  };
289
290
  }
290
- function $e(e, t, a) {
291
- var d, w;
292
- const { keys: o, musicConfig: n } = e, c = o[t], k = c == null ? void 0 : c[a];
293
- if (!k) return a;
294
- let i = 0;
295
- for (let y = 0; y < a; y++) {
296
- const x = (d = n == null ? void 0 : n.keyOffset) == null ? void 0 : d.find((b) => {
297
- var E;
298
- return b.value === ((E = c[y]) == null ? void 0 : E.value);
299
- });
300
- x && (i += x.offsetX);
301
- }
302
- let f = a + i;
303
- const m = (w = n == null ? void 0 : n.keyOffset) == null ? void 0 : w.find((y) => y.value === k.value);
304
- return m && (f += m.offsetX), f;
305
- }
306
291
  function Xe(e) {
307
- const { keys: t, musicConfig: a } = e, o = t.reduce((k, i) => Math.max(k, i.length), 0), n = (a == null ? void 0 : a.maxColOffset) || 0, c = o + n + 1;
308
- return Array.from({ length: t.length }, () => Array.from({ length: c }, () => ({ r: 0, g: 0, b: 0 })));
309
- }
310
- function je(e, t) {
311
- var k;
312
- const { keys: a, musicConfig: o } = t, n = a.flatMap((i, f) => {
313
- let m = 0;
314
- return i.map((d, w) => {
315
- let y = w + m;
316
- if (o != null && o.keyOffset) {
317
- const x = o.keyOffset.find((b) => b.value === d.value);
318
- x && (y += x.offsetX, m += x.offsetX);
319
- }
320
- return {
321
- row: f,
322
- col: y,
323
- value: d.value
324
- };
325
- });
326
- }), c = new Array(n.length * 4).fill(0);
327
- for (let i = 0; i < n.length; i++) {
328
- const f = n[i], m = ((k = e[f.row]) == null ? void 0 : k[f.col]) ?? { r: 0, g: 0, b: 0 }, d = i * 4;
329
- c[d] = f.value, c[d + 1] = m.r, c[d + 2] = m.g, c[d + 3] = m.b;
330
- }
331
- return c;
332
- }
333
- function Ge(e) {
334
292
  const t = e.length / 4;
335
293
  if (!t) return { r: 0, g: 0, b: 0 };
336
- let a = 0, o = 0, n = 0;
337
- for (let c = 0; c < e.length; c += 4)
338
- a += e[c] ?? 0, o += e[c + 1] ?? 0, n += e[c + 2] ?? 0;
294
+ let a = 0, i = 0, s = 0;
295
+ for (let d = 0; d < e.length; d += 4)
296
+ a += e[d] ?? 0, i += e[d + 1] ?? 0, s += e[d + 2] ?? 0;
339
297
  return {
340
298
  r: Math.round(a / t),
341
- g: Math.round(o / t),
342
- b: Math.round(n / t)
299
+ g: Math.round(i / t),
300
+ b: Math.round(s / t)
343
301
  };
344
302
  }
345
- function Ue(e, t, a, o) {
346
- const n = o.getBoundingClientRect(), c = t.width / a.width, k = t.height / a.height, i = (n.left - a.left) * c, f = (n.top - a.top) * k, m = i + n.width * c, d = f + n.height * k, w = Math.max(0, i), y = Math.max(0, f), x = Math.min(t.width, m), b = Math.min(t.height, d);
347
- if (w >= x || y >= b)
303
+ function Ye(e, t, a, i) {
304
+ const s = i.getBoundingClientRect(), d = t.width / a.width, P = t.height / a.height, u = (s.left - a.left) * d, y = (s.top - a.top) * P, k = u + s.width * d, g = y + s.height * P, p = Math.max(0, u), b = Math.max(0, y), x = Math.min(t.width, k), w = Math.min(t.height, g);
305
+ if (p >= x || b >= w)
348
306
  return { r: 0, g: 0, b: 0 };
349
- const E = Math.floor(w), A = Math.floor(y), H = Math.max(1, Math.ceil(x - w)), M = Math.max(1, Math.ceil(b - y));
350
- return Ge(e.getImageData(E, A, H, M).data);
307
+ const L = Math.floor(p), A = Math.floor(b), _ = Math.max(1, Math.ceil(x - p)), C = Math.max(1, Math.ceil(w - b));
308
+ return Xe(e.getImageData(L, A, _, C).data);
351
309
  }
352
310
  function Le(e) {
353
311
  const t = e.querySelector("slot");
354
312
  if (t instanceof HTMLSlotElement) {
355
313
  const a = t.assignedElements();
356
- return a.length ? a.flatMap((o) => Le(o)) : [];
314
+ return a.length ? a.flatMap((i) => Le(i)) : [];
357
315
  }
358
316
  return [e];
359
317
  }
@@ -366,19 +324,19 @@ function Te(e) {
366
324
  }))
367
325
  );
368
326
  }
369
- function Ye(e) {
370
- const { canvas: t, keyboardConfig: a, getKeyElements: o } = e, n = o();
371
- if (!n.length) return null;
372
- const c = t.getContext("2d", { willReadFrequently: !0 });
373
- if (!c) return null;
374
- const k = Xe(a), i = t.getBoundingClientRect();
375
- return n.forEach(({ row: f, col: m, el: d }) => {
327
+ function Qe(e) {
328
+ const { canvas: t, keyboardConfig: a, getKeyElements: i } = e, s = i();
329
+ if (!s.length) return null;
330
+ const d = t.getContext("2d", { willReadFrequently: !0 });
331
+ if (!d) return null;
332
+ const P = qe(a), u = t.getBoundingClientRect();
333
+ return s.forEach(({ row: y, col: k, el: g }) => {
376
334
  var x;
377
- const w = $e(a, f, m), y = Ue(c, t, i, d);
378
- (x = k[f]) != null && x[w] && (k[f][w] = y);
379
- }), k;
335
+ const p = Be(a, y, k), b = Ye(d, t, u, g);
336
+ (x = P[y]) != null && x[p] && (P[y][p] = b);
337
+ }), P;
380
338
  }
381
- const Qe = { class: "relative" }, Ze = ["onMousedown"], Je = ["onMousedown"], et = ["onMousedown"], tt = /* @__PURE__ */ be({
339
+ const Ze = { class: "relative" }, Je = ["onMousedown"], et = ["onMousedown"], tt = ["onMousedown"], at = /* @__PURE__ */ be({
382
340
  __name: "keyboard-overlay.ce",
383
341
  props: {
384
342
  canvasWidth: { default: 800, type: Number },
@@ -388,22 +346,22 @@ const Qe = { class: "relative" }, Ze = ["onMousedown"], Je = ["onMousedown"], et
388
346
  getKeyElements: { type: Function }
389
347
  },
390
348
  setup(e, { expose: t }) {
391
- const a = e, o = L(null), n = L(null), {
392
- lockAspectRatio: c,
393
- rotation: k,
394
- wrapperStyle: i,
395
- applyFitScale: f,
396
- getLayout: m,
397
- resetKeyboardLayout: d,
398
- toggleLockAspectRatio: w,
399
- onDragStart: y,
349
+ const a = e, i = M(null), s = M(null), {
350
+ lockAspectRatio: d,
351
+ rotation: P,
352
+ wrapperStyle: u,
353
+ applyFitScale: y,
354
+ getLayout: k,
355
+ resetKeyboardLayout: g,
356
+ toggleLockAspectRatio: p,
357
+ onDragStart: b,
400
358
  onResizeStart: x,
401
- onScaleCornerStart: b,
402
- onRotateStart: E
403
- } = We({
359
+ onScaleCornerStart: w,
360
+ onRotateStart: L
361
+ } = Ue({
404
362
  canvasWidth: () => a.canvasWidth,
405
363
  canvasHeight: () => a.canvasHeight,
406
- getOverlayEl: () => o.value,
364
+ getOverlayEl: () => i.value,
407
365
  initialLayout: () => a.initialLayout,
408
366
  onLayoutChange: () => a.onLayoutChange
409
367
  }), A = [
@@ -411,111 +369,111 @@ const Qe = { class: "relative" }, Ze = ["onMousedown"], Je = ["onMousedown"], et
411
369
  { mode: "resize-s", baseAngle: 0, className: "resize-s" },
412
370
  { mode: "resize-w", baseAngle: 90, className: "resize-w" },
413
371
  { mode: "resize-e", baseAngle: 90, className: "resize-e" }
414
- ], H = [
372
+ ], _ = [
415
373
  { mode: "scale-nw", baseAngle: 135, className: "corner-nw" },
416
374
  { mode: "scale-ne", baseAngle: 45, className: "corner-ne" },
417
375
  { mode: "scale-sw", baseAngle: 45, className: "corner-sw" },
418
376
  { mode: "scale-se", baseAngle: 135, className: "corner-se" }
419
- ], M = [
377
+ ], C = [
420
378
  { mode: "rotate-nw", className: "rotate-nw" },
421
379
  { mode: "rotate-ne", className: "rotate-ne" },
422
380
  { mode: "rotate-sw", className: "rotate-sw" },
423
381
  { mode: "rotate-se", className: "rotate-se" }
424
382
  ], K = ["ns-resize", "nesw-resize", "ew-resize", "nwse-resize"];
425
- function D(V) {
426
- const B = ((V + k.value) % 360 + 360) % 360, C = Math.round(B / 45) % 4;
427
- return K[C];
383
+ function q(V) {
384
+ const F = ((V + P.value) % 360 + 360) % 360, m = Math.round(F / 45) % 4;
385
+ return K[m];
428
386
  }
429
- function p() {
387
+ function h() {
430
388
  if (a.getKeyElements) return a.getKeyElements();
431
- const V = n.value;
389
+ const V = s.value;
432
390
  return V ? Te(V) : [];
433
391
  }
434
- function S() {
435
- d(n.value);
392
+ function z() {
393
+ g(s.value);
436
394
  }
437
- return He(() => {
438
- f(n.value);
395
+ return _e(() => {
396
+ y(s.value);
439
397
  }), ae(
440
398
  () => [a.canvasWidth, a.canvasHeight],
441
399
  () => {
442
- f(n.value);
400
+ y(s.value);
443
401
  }
444
402
  ), t({
445
- getMountEl: () => n.value,
446
- getKeyElements: p,
447
- getLayout: m,
448
- resetLayout: S,
449
- applyFitScale: () => f(n.value)
450
- }), (V, B) => (ee(), te("div", {
403
+ getMountEl: () => s.value,
404
+ getKeyElements: h,
405
+ getLayout: k,
406
+ resetLayout: z,
407
+ applyFitScale: () => y(s.value)
408
+ }), (V, F) => (ee(), te("div", {
451
409
  ref_key: "overlayRef",
452
- ref: o,
410
+ ref: i,
453
411
  class: "overlay-root",
454
412
  part: "overlay-root"
455
413
  }, [
456
- X("div", {
414
+ j("div", {
457
415
  class: "transform-wrapper",
458
416
  part: "transform-wrapper",
459
- style: oe($(i))
417
+ style: oe($(u))
460
418
  }, [
461
- X("div", Qe, [
462
- X("button", {
419
+ j("div", Ze, [
420
+ j("button", {
463
421
  type: "button",
464
422
  class: "lock-btn",
465
423
  part: "lock-button",
466
- onMousedown: B[0] || (B[0] = ge(() => {
424
+ onMousedown: F[0] || (F[0] = ge(() => {
467
425
  }, ["stop"])),
468
- onClick: B[1] || (B[1] = ge(
426
+ onClick: F[1] || (F[1] = ge(
469
427
  //@ts-ignore
470
- (...C) => $(w) && $(w)(...C),
428
+ (...m) => $(p) && $(p)(...m),
471
429
  ["stop"]
472
430
  ))
473
431
  }, [
474
- X("i", {
475
- class: se(["lock-icon", $(c) ? "lock-icon--locked" : "lock-icon--open"])
432
+ j("i", {
433
+ class: se(["lock-icon", $(d) ? "lock-icon--locked" : "lock-icon--open"])
476
434
  }, null, 2)
477
435
  ], 32),
478
- (ee(), te(ve, null, fe(M, (C) => X("div", {
479
- key: C.mode,
480
- class: se(["rotate-handle", C.className]),
436
+ (ee(), te(ve, null, fe(C, (m) => j("div", {
437
+ key: m.mode,
438
+ class: se(["rotate-handle", m.className]),
481
439
  part: "rotate-handle",
482
- onMousedown: (O) => $(E)(C.mode, O)
483
- }, null, 42, Ze)), 64)),
484
- (ee(), te(ve, null, fe(A, (C) => X("div", {
485
- key: C.mode,
486
- class: se(["resize-handle", C.className]),
440
+ onMousedown: (W) => $(L)(m.mode, W)
441
+ }, null, 42, Je)), 64)),
442
+ (ee(), te(ve, null, fe(A, (m) => j("div", {
443
+ key: m.mode,
444
+ class: se(["resize-handle", m.className]),
487
445
  part: "resize-handle",
488
- style: oe({ cursor: D(C.baseAngle) }),
489
- onMousedown: (O) => $(x)(C.mode, O)
490
- }, null, 46, Je)), 64)),
491
- (ee(), te(ve, null, fe(H, (C) => X("div", {
492
- key: C.mode,
493
- class: se(["corner-handle", C.className]),
494
- part: "corner-handle",
495
- style: oe({ cursor: D(C.baseAngle) }),
496
- onMousedown: (O) => $(b)(C.mode, O)
446
+ style: oe({ cursor: q(m.baseAngle) }),
447
+ onMousedown: (W) => $(x)(m.mode, W)
497
448
  }, null, 46, et)), 64)),
498
- X("div", {
449
+ (ee(), te(ve, null, fe(_, (m) => j("div", {
450
+ key: m.mode,
451
+ class: se(["corner-handle", m.className]),
452
+ part: "corner-handle",
453
+ style: oe({ cursor: q(m.baseAngle) }),
454
+ onMousedown: (W) => $(w)(m.mode, W)
455
+ }, null, 46, tt)), 64)),
456
+ j("div", {
499
457
  ref_key: "mountRef",
500
- ref: n,
458
+ ref: s,
501
459
  class: "keyboard-mount",
502
460
  part: "keyboard-mount",
503
- onMousedown: B[2] || (B[2] = //@ts-ignore
504
- (...C) => $(y) && $(y)(...C))
461
+ onMousedown: F[2] || (F[2] = //@ts-ignore
462
+ (...m) => $(b) && $(b)(...m))
505
463
  }, [
506
- ke(V.$slots, "keyboard", {}, void 0)
464
+ Ce(V.$slots, "keyboard", {}, void 0)
507
465
  ], 544)
508
466
  ])
509
467
  ], 4)
510
468
  ], 512));
511
469
  }
512
- }), at = `.overlay-root[data-v-1403efc7]{pointer-events:none;position:absolute;top:0;right:0;bottom:0;left:0;overflow:hidden}.transform-wrapper[data-v-1403efc7]{pointer-events:auto;position:absolute;-webkit-user-select:none;user-select:none}.lock-btn[data-v-1403efc7]{position:absolute;top:16px;right:-40px;z-index:20;width:32px;height:32px;display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:9999px;border-style:none;--un-bg-opacity:1;background-color:rgb(22 22 22 / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(255 255 255 / var(--un-text-opacity));--un-shadow:var(--un-shadow-inset) 0 4px 6px -1px var(--un-shadow-color, rgb(0 0 0 / .1)),var(--un-shadow-inset) 0 2px 4px -2px var(--un-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow);transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.lock-btn[data-v-1403efc7]:hover{--un-bg-opacity:1;background-color:rgb(32 128 240 / var(--un-bg-opacity))}.lock-icon[data-v-1403efc7]{pointer-events:none;display:inline-block;font-size:24px}.lock-icon--locked[data-v-1403efc7],.lock-icon--open[data-v-1403efc7]{width:1em;height:1em;background-color:currentColor;-webkit-mask:no-repeat center / 100% 100%;mask:no-repeat center / 100% 100%}.lock-icon--locked[data-v-1403efc7]{-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M6 22q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8h1V6q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22zm7.413-5.587Q14 15.825 14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17t1.413-.587M9 8h6V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M6 22q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8h1V6q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22zm7.413-5.587Q14 15.825 14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17t1.413-.587M9 8h6V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6z'/%3E%3C/svg%3E")}.lock-icon--open[data-v-1403efc7]{-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M6 8h9V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6H7q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22H6q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8m7.413 8.413Q14 15.825 14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17t1.413-.587'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M6 8h9V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6H7q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22H6q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8m7.413 8.413Q14 15.825 14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17t1.413-.587'/%3E%3C/svg%3E")}.rotate-handle[data-v-1403efc7]{position:absolute;z-index:20;width:32px;height:32px;cursor:grab;--un-text-opacity:1;color:rgb(156 163 175 / var(--un-text-opacity));background-color:currentColor;-webkit-mask:no-repeat center / 100% 100%;mask:no-repeat center / 100% 100%}.rotate-nw[data-v-1403efc7]{top:-40px;left:-40px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M20.92 6.62a1 1 0 0 0-.21-.33l-3-3a1 1 0 0 0-1.42 1.42L17.59 6H9a3 3 0 0 0-3 3v8.59l-1.29-1.3a1 1 0 0 0-1.42 1.42l3 3a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l3-3a1 1 0 0 0-1.42-1.42L8 17.59V9a1 1 0 0 1 1-1h8.59l-1.3 1.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l3-3a1 1 0 0 0 .21-.33a1 1 0 0 0 0-.76'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M20.92 6.62a1 1 0 0 0-.21-.33l-3-3a1 1 0 0 0-1.42 1.42L17.59 6H9a3 3 0 0 0-3 3v8.59l-1.29-1.3a1 1 0 0 0-1.42 1.42l3 3a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l3-3a1 1 0 0 0-1.42-1.42L8 17.59V9a1 1 0 0 1 1-1h8.59l-1.3 1.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l3-3a1 1 0 0 0 .21-.33a1 1 0 0 0 0-.76'/%3E%3C/svg%3E")}.rotate-ne[data-v-1403efc7]{top:-40px;right:-40px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M21.71 16.29a1 1 0 0 0-1.42 0L18 18.59V9a3 3 0 0 0-3-3H5.41l2.3-2.29a1 1 0 0 0-1.42-1.42l-4 4a1 1 0 0 0-.21.33a1 1 0 0 0 0 .76a1 1 0 0 0 .21.33l4 4a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42L5.41 8H15a1 1 0 0 1 1 1v9.59l-2.29-2.3a1 1 0 0 0-1.42 1.42l4 4a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l4-4a1 1 0 0 0 0-1.42'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M21.71 16.29a1 1 0 0 0-1.42 0L18 18.59V9a3 3 0 0 0-3-3H5.41l2.3-2.29a1 1 0 0 0-1.42-1.42l-4 4a1 1 0 0 0-.21.33a1 1 0 0 0 0 .76a1 1 0 0 0 .21.33l4 4a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42L5.41 8H15a1 1 0 0 1 1 1v9.59l-2.29-2.3a1 1 0 0 0-1.42 1.42l4 4a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l4-4a1 1 0 0 0 0-1.42'/%3E%3C/svg%3E")}.rotate-sw[data-v-1403efc7]{bottom:-40px;left:-40px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cg fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='m17 21l4-4l-4-4'/%3E%3Cpath d='M21 17H10a3 3 0 0 1-3-3V3'/%3E%3Cpath d='M11 7L7 3L3 7'/%3E%3C/g%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cg fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='m17 21l4-4l-4-4'/%3E%3Cpath d='M21 17H10a3 3 0 0 1-3-3V3'/%3E%3Cpath d='M11 7L7 3L3 7'/%3E%3C/g%3E%3C/svg%3E")}.rotate-se[data-v-1403efc7]{bottom:-40px;right:-40px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cg fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='m21 7l-4-4l-4 4'/%3E%3Cpath d='M17 3v11a3 3 0 0 1-3 3H3'/%3E%3Cpath d='m7 13l-4 4l4 4'/%3E%3C/g%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cg fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='m21 7l-4-4l-4 4'/%3E%3Cpath d='M17 3v11a3 3 0 0 1-3 3H3'/%3E%3Cpath d='m7 13l-4 4l4 4'/%3E%3C/g%3E%3C/svg%3E")}.resize-handle[data-v-1403efc7]{position:absolute;z-index:10}.resize-n[data-v-1403efc7]{top:-4px;left:12px;right:12px;height:4px}.resize-s[data-v-1403efc7]{bottom:-4px;left:12px;right:12px;height:4px}.resize-w[data-v-1403efc7]{left:-4px;top:12px;bottom:12px;width:4px}.resize-e[data-v-1403efc7]{right:-4px;top:12px;bottom:12px;width:4px}.corner-handle[data-v-1403efc7]{position:absolute;z-index:20;width:16px;height:16px;border-radius:9999px;--un-bg-opacity:1;background-color:rgb(156 163 175 / var(--un-bg-opacity))}.corner-nw[data-v-1403efc7]{top:-8px;left:-8px}.corner-ne[data-v-1403efc7]{top:-8px;right:-8px}.corner-sw[data-v-1403efc7]{bottom:-8px;left:-8px}.corner-se[data-v-1403efc7]{bottom:-8px;right:-8px}.keyboard-mount[data-v-1403efc7]{position:relative;width:fit-content;cursor:move}`, Se = (e, t) => {
470
+ }), nt = `.overlay-root[data-v-1403efc7]{pointer-events:none;position:absolute;top:0;right:0;bottom:0;left:0;overflow:hidden}.transform-wrapper[data-v-1403efc7]{pointer-events:auto;position:absolute;-webkit-user-select:none;user-select:none}.lock-btn[data-v-1403efc7]{position:absolute;top:16px;right:-40px;z-index:20;width:32px;height:32px;display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:9999px;border-style:none;--un-bg-opacity:1;background-color:rgb(22 22 22 / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(255 255 255 / var(--un-text-opacity));--un-shadow:var(--un-shadow-inset) 0 4px 6px -1px var(--un-shadow-color, rgb(0 0 0 / .1)),var(--un-shadow-inset) 0 2px 4px -2px var(--un-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow);transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.lock-btn[data-v-1403efc7]:hover{--un-bg-opacity:1;background-color:rgb(32 128 240 / var(--un-bg-opacity))}.lock-icon[data-v-1403efc7]{pointer-events:none;display:inline-block;font-size:24px}.lock-icon--locked[data-v-1403efc7],.lock-icon--open[data-v-1403efc7]{width:1em;height:1em;background-color:currentColor;-webkit-mask:no-repeat center / 100% 100%;mask:no-repeat center / 100% 100%}.lock-icon--locked[data-v-1403efc7]{-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M6 22q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8h1V6q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22zm7.413-5.587Q14 15.825 14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17t1.413-.587M9 8h6V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M6 22q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8h1V6q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22zm7.413-5.587Q14 15.825 14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17t1.413-.587M9 8h6V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6z'/%3E%3C/svg%3E")}.lock-icon--open[data-v-1403efc7]{-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M6 8h9V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6H7q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22H6q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8m7.413 8.413Q14 15.825 14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17t1.413-.587'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M6 8h9V6q0-1.25-.875-2.125T12 3t-2.125.875T9 6H7q0-2.075 1.463-3.537T12 1t3.538 1.463T17 6v2h1q.825 0 1.413.588T20 10v10q0 .825-.587 1.413T18 22H6q-.825 0-1.412-.587T4 20V10q0-.825.588-1.412T6 8m7.413 8.413Q14 15.825 14 15t-.587-1.412T12 13t-1.412.588T10 15t.588 1.413T12 17t1.413-.587'/%3E%3C/svg%3E")}.rotate-handle[data-v-1403efc7]{position:absolute;z-index:20;width:32px;height:32px;cursor:grab;--un-text-opacity:1;color:rgb(156 163 175 / var(--un-text-opacity));background-color:currentColor;-webkit-mask:no-repeat center / 100% 100%;mask:no-repeat center / 100% 100%}.rotate-nw[data-v-1403efc7]{top:-40px;left:-40px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M20.92 6.62a1 1 0 0 0-.21-.33l-3-3a1 1 0 0 0-1.42 1.42L17.59 6H9a3 3 0 0 0-3 3v8.59l-1.29-1.3a1 1 0 0 0-1.42 1.42l3 3a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l3-3a1 1 0 0 0-1.42-1.42L8 17.59V9a1 1 0 0 1 1-1h8.59l-1.3 1.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l3-3a1 1 0 0 0 .21-.33a1 1 0 0 0 0-.76'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M20.92 6.62a1 1 0 0 0-.21-.33l-3-3a1 1 0 0 0-1.42 1.42L17.59 6H9a3 3 0 0 0-3 3v8.59l-1.29-1.3a1 1 0 0 0-1.42 1.42l3 3a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l3-3a1 1 0 0 0-1.42-1.42L8 17.59V9a1 1 0 0 1 1-1h8.59l-1.3 1.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l3-3a1 1 0 0 0 .21-.33a1 1 0 0 0 0-.76'/%3E%3C/svg%3E")}.rotate-ne[data-v-1403efc7]{top:-40px;right:-40px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M21.71 16.29a1 1 0 0 0-1.42 0L18 18.59V9a3 3 0 0 0-3-3H5.41l2.3-2.29a1 1 0 0 0-1.42-1.42l-4 4a1 1 0 0 0-.21.33a1 1 0 0 0 0 .76a1 1 0 0 0 .21.33l4 4a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42L5.41 8H15a1 1 0 0 1 1 1v9.59l-2.29-2.3a1 1 0 0 0-1.42 1.42l4 4a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l4-4a1 1 0 0 0 0-1.42'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M21.71 16.29a1 1 0 0 0-1.42 0L18 18.59V9a3 3 0 0 0-3-3H5.41l2.3-2.29a1 1 0 0 0-1.42-1.42l-4 4a1 1 0 0 0-.21.33a1 1 0 0 0 0 .76a1 1 0 0 0 .21.33l4 4a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42L5.41 8H15a1 1 0 0 1 1 1v9.59l-2.29-2.3a1 1 0 0 0-1.42 1.42l4 4a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l4-4a1 1 0 0 0 0-1.42'/%3E%3C/svg%3E")}.rotate-sw[data-v-1403efc7]{bottom:-40px;left:-40px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cg fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='m17 21l4-4l-4-4'/%3E%3Cpath d='M21 17H10a3 3 0 0 1-3-3V3'/%3E%3Cpath d='M11 7L7 3L3 7'/%3E%3C/g%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cg fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='m17 21l4-4l-4-4'/%3E%3Cpath d='M21 17H10a3 3 0 0 1-3-3V3'/%3E%3Cpath d='M11 7L7 3L3 7'/%3E%3C/g%3E%3C/svg%3E")}.rotate-se[data-v-1403efc7]{bottom:-40px;right:-40px;-webkit-mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cg fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='m21 7l-4-4l-4 4'/%3E%3Cpath d='M17 3v11a3 3 0 0 1-3 3H3'/%3E%3Cpath d='m7 13l-4 4l4 4'/%3E%3C/g%3E%3C/svg%3E");mask-image:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cg fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='m21 7l-4-4l-4 4'/%3E%3Cpath d='M17 3v11a3 3 0 0 1-3 3H3'/%3E%3Cpath d='m7 13l-4 4l4 4'/%3E%3C/g%3E%3C/svg%3E")}.resize-handle[data-v-1403efc7]{position:absolute;z-index:10}.resize-n[data-v-1403efc7]{top:-4px;left:12px;right:12px;height:4px}.resize-s[data-v-1403efc7]{bottom:-4px;left:12px;right:12px;height:4px}.resize-w[data-v-1403efc7]{left:-4px;top:12px;bottom:12px;width:4px}.resize-e[data-v-1403efc7]{right:-4px;top:12px;bottom:12px;width:4px}.corner-handle[data-v-1403efc7]{position:absolute;z-index:20;width:16px;height:16px;border-radius:9999px;--un-bg-opacity:1;background-color:rgb(156 163 175 / var(--un-bg-opacity))}.corner-nw[data-v-1403efc7]{top:-8px;left:-8px}.corner-ne[data-v-1403efc7]{top:-8px;right:-8px}.corner-sw[data-v-1403efc7]{bottom:-8px;left:-8px}.corner-se[data-v-1403efc7]{bottom:-8px;right:-8px}.keyboard-mount[data-v-1403efc7]{position:relative;width:fit-content;cursor:move}`, ze = (e, t) => {
513
471
  const a = e.__vccOpts || e;
514
- for (const [o, n] of t)
515
- a[o] = n;
472
+ for (const [i, s] of t)
473
+ a[i] = s;
516
474
  return a;
517
- }, ze = /* @__PURE__ */ Se(tt, [["styles", [at]], ["__scopeId", "data-v-1403efc7"]]);
518
- function nt(e) {
475
+ }, Se = /* @__PURE__ */ ze(at, [["styles", [nt]], ["__scopeId", "data-v-1403efc7"]]);
476
+ function rt(e) {
519
477
  var t, a;
520
478
  if (e.default !== void 0) return e.default;
521
479
  switch (e.type) {
@@ -529,265 +487,249 @@ function nt(e) {
529
487
  return 0;
530
488
  }
531
489
  }
532
- function Ie(e) {
533
- return Object.fromEntries((e.params ?? []).map((t) => [t.key, nt(t)]));
490
+ function Re(e) {
491
+ return Object.fromEntries((e.params ?? []).map((t) => [t.key, rt(t)]));
534
492
  }
535
493
  function ie(e, t = {}) {
536
494
  if (!e) return {};
537
- const a = Ie(e);
538
- for (const o of e.params ?? [])
539
- o.key in t && t[o.key] !== void 0 && (a[o.key] = t[o.key]);
495
+ const a = Re(e);
496
+ for (const i of e.params ?? [])
497
+ i.key in t && t[i.key] !== void 0 && (a[i.key] = t[i.key]);
540
498
  return a;
541
499
  }
542
- const rt = 50;
500
+ const st = 50;
543
501
  function pe(e, t, a) {
544
502
  e.setTransform(1, 0, 0, 1, 0, 0), e.globalAlpha = 1, e.globalCompositeOperation = "source-over", e.clearRect(0, 0, t, a);
545
503
  }
546
- function st(e, t, a) {
547
- const o = e.getContext("2d");
548
- if (!o) return null;
549
- const n = {
550
- canvas2d: o,
504
+ function ot(e, t, a) {
505
+ const i = e.getContext("2d");
506
+ if (!i) return null;
507
+ const s = {
508
+ canvas2d: i,
551
509
  width: e.width,
552
510
  height: e.height
553
- }, c = { ...Ie(t), ...a }, k = t.initialize(n, c);
554
- let i = 0, f = 0, m = 0, d = 0;
555
- const w = (D) => {
556
- pe(o, e.width, e.height), d || (d = D);
557
- const p = m ? D - m : 16, S = D - d;
558
- m = D, t.render(n, k, { deltaTime: p, elapsedTime: S }, c);
559
- }, y = () => {
560
- i && (cancelAnimationFrame(i), i = 0);
511
+ }, d = { ...Re(t), ...a }, P = t.initialize(s, d);
512
+ let u = 0, y = 0, k = 0, g = 0;
513
+ const p = (q) => {
514
+ pe(i, e.width, e.height), g || (g = q);
515
+ const h = k ? q - k : 16, z = q - g;
516
+ k = q, t.render(s, P, { deltaTime: h, elapsedTime: z }, d);
517
+ }, b = () => {
518
+ u && (cancelAnimationFrame(u), u = 0);
561
519
  }, x = () => {
562
- f && (Ee(f), f = 0);
563
- }, b = (D) => {
564
- w(D), i = requestAnimationFrame(b);
565
- }, E = () => {
566
- w(performance.now());
520
+ y && (Ee(y), y = 0);
521
+ }, w = (q) => {
522
+ p(q), u = requestAnimationFrame(w);
523
+ }, L = () => {
524
+ p(performance.now());
567
525
  }, A = () => {
568
- x(), y(), i = requestAnimationFrame(b);
569
- }, H = () => {
570
- y(), x(), E(), f = Ce(E, rt);
571
- }, M = () => {
572
- document.visibilityState === "visible" ? A() : H();
526
+ x(), b(), u = requestAnimationFrame(w);
527
+ }, _ = () => {
528
+ b(), x(), L(), y = ke(L, st);
529
+ }, C = () => {
530
+ document.visibilityState === "visible" ? A() : _();
573
531
  }, K = () => {
574
- M();
532
+ C();
575
533
  };
576
- return document.addEventListener("visibilitychange", K), M(), () => {
577
- document.removeEventListener("visibilitychange", K), y(), x(), t.shutdown(n, k), pe(o, e.width, e.height);
534
+ return document.addEventListener("visibilitychange", K), C(), () => {
535
+ document.removeEventListener("visibilitychange", K), b(), x(), t.shutdown(s, P), pe(i, e.width, e.height);
578
536
  };
579
537
  }
580
- function ot(e, t = {}) {
538
+ function it(e, t = {}) {
581
539
  return ie(e, t);
582
540
  }
583
- function it(e) {
584
- const t = L(null), a = Y(() => F(e.canvasRef) ?? t.value), o = L(null), n = L({}), c = L(!1), k = Y(() => {
585
- var p;
586
- return ((p = o.value) == null ? void 0 : p.params) ?? [];
541
+ function lt(e) {
542
+ const t = M(null), a = Y(() => D(e.canvasRef) ?? t.value), i = M(null), s = M({}), d = M(!1), P = Y(() => {
543
+ var h;
544
+ return ((h = i.value) == null ? void 0 : h.params) ?? [];
587
545
  });
588
- let i = null;
589
- function f() {
590
- const p = o.value, S = a.value;
591
- if (!p || !S) return !1;
592
- i == null || i(), i = null;
593
- const V = st(S, p, n.value);
594
- return V && (i = V, c.value = !0), !0;
546
+ let u = null;
547
+ function y() {
548
+ const h = i.value, z = a.value;
549
+ if (!h || !z) return !1;
550
+ u == null || u(), u = null;
551
+ const V = ot(z, h, s.value);
552
+ return V && (u = V, d.value = !0), !0;
595
553
  }
596
- function m() {
597
- o.value && (f() || Me(() => f()));
554
+ function k() {
555
+ i.value && (y() || Me(() => y()));
598
556
  }
599
- function d(p, S) {
600
- w(), o.value = p, S && (n.value = { ...S }), m();
557
+ function g(h, z) {
558
+ p(), i.value = h, z && (s.value = { ...z }), k();
601
559
  }
602
- function w() {
603
- i == null || i(), i = null, c.value = !1;
560
+ function p() {
561
+ u == null || u(), u = null, d.value = !1;
604
562
  }
605
- function y(p) {
606
- n.value = ie(o.value, { ...n.value, ...p }), m();
563
+ function b(h) {
564
+ s.value = ie(i.value, { ...s.value, ...h }), k();
607
565
  }
608
- function x(p) {
609
- return p.name ?? p.key;
566
+ function x(h) {
567
+ return h.name ?? h.key;
610
568
  }
611
- function b(p) {
612
- return Number(n.value[p] ?? 0);
569
+ function w(h) {
570
+ return Number(s.value[h] ?? 0);
613
571
  }
614
- function E(p) {
615
- return String(n.value[p] ?? "#000000");
572
+ function L(h) {
573
+ return String(s.value[h] ?? "#000000");
616
574
  }
617
- function A(p) {
618
- const S = n.value[p];
619
- return typeof S == "number" || typeof S == "string" ? S : 0;
575
+ function A(h) {
576
+ const z = s.value[h];
577
+ return typeof z == "number" || typeof z == "string" ? z : 0;
620
578
  }
621
- function H(p) {
622
- return !!n.value[p];
579
+ function _(h) {
580
+ return !!s.value[h];
623
581
  }
624
- function M(p) {
625
- const S = Number(p ?? 0);
626
- return Number.isInteger(S) ? String(S) : S.toFixed(2).replace(/\.?0+$/, "");
582
+ function C(h) {
583
+ const z = Number(h ?? 0);
584
+ return Number.isInteger(z) ? String(z) : z.toFixed(2).replace(/\.?0+$/, "");
627
585
  }
628
- function K(p, S) {
629
- y({ [p]: S });
586
+ function K(h, z) {
587
+ b({ [h]: z });
630
588
  }
631
- function D() {
632
- const p = F(e.preset) ?? null, S = F(e.params) ?? {};
633
- if (!p) {
634
- o.value = null, n.value = {}, w();
589
+ function q() {
590
+ const h = D(e.preset) ?? null, z = D(e.params) ?? {};
591
+ if (!h) {
592
+ i.value = null, s.value = {}, p();
635
593
  return;
636
594
  }
637
- o.value = p, n.value = ot(p, S), m();
595
+ i.value = h, s.value = it(h, z), k();
638
596
  }
639
- return ae(() => ({ preset: F(e.preset), params: F(e.params) }), D, {
597
+ return ae(() => ({ preset: D(e.preset), params: D(e.params) }), q, {
640
598
  immediate: !0,
641
599
  deep: !0,
642
600
  flush: "sync"
643
- }), xe(w), {
601
+ }), xe(p), {
644
602
  internalCanvasRef: t,
645
603
  canvasRef: a,
646
- currentPreset: o,
647
- paramValues: n,
648
- paramFields: k,
649
- isRunning: c,
604
+ currentPreset: i,
605
+ paramValues: s,
606
+ paramFields: P,
607
+ isRunning: d,
650
608
  getParamLabel: x,
651
- getSliderValue: b,
652
- getColorValue: E,
609
+ getSliderValue: w,
610
+ getColorValue: L,
653
611
  getSelectValue: A,
654
- getSwitchValue: H,
655
- formatSliderValue: M,
612
+ getSwitchValue: _,
613
+ formatSliderValue: C,
656
614
  handleParamChange: K,
657
- start: d,
658
- stop: w,
659
- updateParams: y
615
+ start: g,
616
+ stop: p,
617
+ updateParams: b
660
618
  };
661
619
  }
662
- const lt = 50;
620
+ const ut = 50;
663
621
  function ct(e) {
664
- const t = e.syncIntervalMs ?? lt;
665
- let a = 0, o = !1, n = null;
666
- function c() {
667
- const d = e.getCanvas();
668
- return d ? Ye({
669
- canvas: d,
622
+ const t = e.syncIntervalMs ?? ut;
623
+ let a = 0, i = !1, s = null;
624
+ function d() {
625
+ const g = e.getCanvas();
626
+ return g ? Qe({
627
+ canvas: g,
670
628
  keyboardConfig: e.keyboardConfig,
671
629
  getKeyElements: e.getKeyElements
672
630
  }) : null;
673
631
  }
674
- async function k(d) {
675
- var w;
676
- if ((w = e.onKeysRgbChange) == null || w.call(e, d), o) {
677
- n = d;
632
+ async function P(g) {
633
+ var p;
634
+ if ((p = e.onKeysRgbChange) == null || p.call(e, g), i) {
635
+ s = g;
678
636
  return;
679
637
  }
680
- o = !0;
638
+ i = !0;
681
639
  try {
682
- const y = je(d, e.keyboardConfig);
683
- await e.device.setMusicData(y, 0, e.isUSBDevice, e.lightingVersion);
640
+ const b = Fe(g, e.keyboardConfig);
641
+ await e.device.setMusicData(b, 0, e.isUSBDevice, e.lightingVersion);
684
642
  } catch {
685
643
  } finally {
686
- if (o = !1, n) {
687
- const y = n;
688
- n = null, k(y);
644
+ if (i = !1, s) {
645
+ const b = s;
646
+ s = null, P(b);
689
647
  }
690
648
  }
691
649
  }
692
- function i() {
650
+ function u() {
693
651
  if (e.enabled && !e.enabled.value) return;
694
- const d = c();
695
- d && k(d);
652
+ const g = d();
653
+ g && P(g);
696
654
  }
697
- function f() {
698
- a || (a = Ce(i, t));
655
+ function y() {
656
+ a || (a = ke(u, t));
699
657
  }
700
- function m() {
658
+ function k() {
701
659
  a && (Ee(a), a = 0);
702
660
  }
703
661
  return e.enabled ? ae(
704
662
  e.enabled,
705
- (d) => {
706
- d ? f() : m();
663
+ (g) => {
664
+ g ? y() : k();
707
665
  },
708
666
  { immediate: !0 }
709
- ) : f(), _e(m), {
710
- syncKeyColors: i,
711
- startKeySync: f,
712
- stopKeySync: m
667
+ ) : y(), He(k), {
668
+ syncKeyColors: u,
669
+ startKeySync: y,
670
+ stopKeySync: k
713
671
  };
714
672
  }
715
- function ut(e) {
673
+ function dt(e) {
716
674
  if (!e || typeof e != "object") return !1;
717
675
  const t = e;
718
676
  return !(typeof t.id != "string" || !t.id.trim() || typeof t.name != "string" || !t.name.trim() || typeof t.initialize != "function" || typeof t.render != "function" || typeof t.shutdown != "function" || t.params !== void 0 && (!Array.isArray(t.params) || !t.params.every((a) => a && typeof a == "object" && typeof a.key == "string")));
719
677
  }
720
- function dt(e) {
678
+ function vt(e) {
721
679
  const t = new Function(`return (${e})`)();
722
- if (!ut(t))
680
+ if (!dt(t))
723
681
  throw new Error("INVALID_PRESET");
724
682
  return t;
725
683
  }
726
684
  function we(e = {}) {
727
- var y, x;
728
- const t = e.initialPresets ?? [], a = he(e.initialImported ?? []), o = he([...t, ...a.value]), n = L(((y = t[0]) == null ? void 0 : y.id) ?? ((x = a.value[0]) == null ? void 0 : x.id) ?? ""), c = () => o.value.find((b) => b.id === n.value) ?? o.value[0] ?? null;
729
- function k() {
730
- o.value = [...t, ...a.value];
685
+ var b, x;
686
+ const t = e.initialPresets ?? [], a = he(e.initialImported ?? []), i = he([...t, ...a.value]), s = M(((b = t[0]) == null ? void 0 : b.id) ?? ((x = a.value[0]) == null ? void 0 : x.id) ?? ""), d = () => i.value.find((w) => w.id === s.value) ?? i.value[0] ?? null;
687
+ function P() {
688
+ i.value = [...t, ...a.value];
731
689
  }
732
- function i() {
733
- var b;
734
- (b = e.onPresetsChange) == null || b.call(e, a.value.map((E) => Ke(E)));
690
+ function u() {
691
+ var w;
692
+ (w = e.onPresetsChange) == null || w.call(e, a.value.map((L) => Ke(L)));
735
693
  }
736
- function f(b) {
737
- o.value.some((E) => E.id === b) && (n.value = b);
694
+ function y(w) {
695
+ i.value.some((L) => L.id === w) && (s.value = w);
738
696
  }
739
- function m(b) {
740
- return t.some((E) => E.id === b);
697
+ function k(w) {
698
+ return t.some((L) => L.id === w);
741
699
  }
742
- async function d(b) {
743
- var E, A, H;
700
+ async function g(w) {
701
+ var L, A, _;
744
702
  try {
745
- const M = dt(b);
746
- return o.value.some((K) => K.id === M.id) ? ((E = e.onImportPreset) == null || E.call(e, {
703
+ const C = vt(w);
704
+ return i.value.some((K) => K.id === C.id) ? ((L = e.onImportPreset) == null || L.call(e, {
747
705
  code: 1,
748
706
  message: "Preset id already exists"
749
- }), null) : (a.value = [...a.value, M], k(), i(), n.value = M.id, (A = e.onImportPreset) == null || A.call(e, {
707
+ }), null) : (a.value = [...a.value, C], P(), u(), s.value = C.id, (A = e.onImportPreset) == null || A.call(e, {
750
708
  code: 0,
751
709
  message: "Import success"
752
- }), M);
710
+ }), C);
753
711
  } catch {
754
- return (H = e.onImportPreset) == null || H.call(e, {
712
+ return (_ = e.onImportPreset) == null || _.call(e, {
755
713
  code: 2,
756
714
  message: "Invalid preset code"
757
715
  }), null;
758
716
  }
759
717
  }
760
- async function w(b) {
761
- var E;
762
- m(b) || (a.value = a.value.filter((A) => A.id !== b), k(), i(), n.value === b && (n.value = ((E = o.value[0]) == null ? void 0 : E.id) ?? ""));
718
+ async function p(w) {
719
+ var L;
720
+ k(w) || (a.value = a.value.filter((A) => A.id !== w), P(), u(), s.value === w && (s.value = ((L = i.value[0]) == null ? void 0 : L.id) ?? ""));
763
721
  }
764
722
  return {
765
- presetList: o,
766
- selectedPresetId: n,
767
- selectedPreset: c,
768
- selectPreset: f,
769
- isInitialPreset: m,
770
- importPreset: d,
771
- deleteImportedPreset: w
723
+ presetList: i,
724
+ selectedPresetId: s,
725
+ selectedPreset: d,
726
+ selectPreset: y,
727
+ isInitialPreset: k,
728
+ importPreset: g,
729
+ deleteImportedPreset: p
772
730
  };
773
731
  }
774
- const vt = ["setMusicData", "getDeviceId", "isConnected", "getDevice"];
775
- function ft(e) {
776
- if (!e || typeof e != "object") return !1;
777
- const t = e;
778
- return vt.every((a) => typeof t[a] == "function");
779
- }
780
- async function ht(e) {
781
- if (!e)
782
- throw new Error("[keyboard-kit] init.device is required");
783
- if (!ft(e))
784
- throw new Error("[keyboard-kit] init.device must be an @hfd-sdk/keyboard-sdk HFDDevice instance");
785
- const { HFDDevice: t } = await import("@hfd-sdk/keyboard-sdk");
786
- if (!(e instanceof t))
787
- throw new Error("[keyboard-kit] init.device must be created via new HFDDevice() from @hfd-sdk/keyboard-sdk");
788
- return e;
789
- }
790
- const gt = ["width", "height"], mt = /* @__PURE__ */ be({
732
+ const ft = ["width", "height"], ht = /* @__PURE__ */ be({
791
733
  __name: "hfd-ai-lighting.ce",
792
734
  props: {
793
735
  width: { default: 800, type: Number },
@@ -795,152 +737,152 @@ const gt = ["width", "height"], mt = /* @__PURE__ */ be({
795
737
  },
796
738
  emits: ["keys-rgb-change", "preset-change", "param-change", "presets-change", "layout-change", "keyboard-ready", "import-preset"],
797
739
  setup(e, { expose: t, emit: a }) {
798
- const o = e, n = a, c = L(o.width), k = L(o.height), i = L(), f = L(), m = L(null), d = L(null), w = L(), y = L(), x = L(50), b = L(!0), E = L({}), A = L(null), H = L(null);
799
- let M = he(we());
800
- const K = Y(() => M.value.selectedPreset()), D = Y(() => ({
801
- width: `${c.value}px`,
802
- height: `${k.value}px`
803
- })), { paramValues: p, handleParamChange: S } = it({
740
+ const i = e, s = a, d = M(i.width), P = M(i.height), u = M(), y = M(), k = M(null), g = M(null), p = M(), b = M(), x = M(50), w = M(!0), L = M({}), A = M(null), _ = M(null);
741
+ let C = he(we());
742
+ const K = Y(() => C.value.selectedPreset()), q = Y(() => ({
743
+ width: `${d.value}px`,
744
+ height: `${P.value}px`
745
+ })), { paramValues: h, handleParamChange: z } = lt({
804
746
  preset: () => K.value,
805
- params: () => E.value,
747
+ params: () => L.value,
806
748
  canvasRef: () => A.value
807
749
  });
808
750
  function V() {
809
- var I, W;
810
- if (f.value) return f.value();
811
- const u = (W = (I = H.value) == null ? void 0 : I.getMountEl) == null ? void 0 : W.call(I);
812
- return u ? Te(u) : [];
751
+ var R, O;
752
+ if (y.value) return y.value();
753
+ const l = (O = (R = _.value) == null ? void 0 : R.getMountEl) == null ? void 0 : O.call(R);
754
+ return l ? Te(l) : [];
813
755
  }
814
- function B(u) {
815
- n("layout-change", { layout: u });
756
+ function F(l) {
757
+ s("layout-change", { layout: l });
816
758
  }
817
- let C = null;
818
- function O() {
819
- if (C == null || C(), C = null, !m.value || !A.value || !d.value) return;
820
- C = ct({
821
- keyboardConfig: m.value,
759
+ let m = null;
760
+ function W() {
761
+ if (m == null || m(), m = null, !k.value || !A.value || !g.value) return;
762
+ m = ct({
763
+ keyboardConfig: k.value,
822
764
  getCanvas: () => A.value,
823
765
  getKeyElements: V,
824
- device: d.value,
825
- isUSBDevice: w.value,
826
- lightingVersion: y.value,
766
+ device: g.value,
767
+ isUSBDevice: p.value,
768
+ lightingVersion: b.value,
827
769
  syncIntervalMs: x.value,
828
- enabled: b,
829
- onKeysRgbChange: (I) => {
830
- n("keys-rgb-change", { keysRgb: I });
770
+ enabled: w,
771
+ onKeysRgbChange: (R) => {
772
+ s("keys-rgb-change", { keysRgb: R });
831
773
  }
832
774
  }).stopKeySync;
833
775
  }
834
- function j(u) {
835
- n("preset-change", {
836
- presetId: u,
837
- preset: M.value.selectedPreset()
776
+ function G(l) {
777
+ s("preset-change", {
778
+ presetId: l,
779
+ preset: C.value.selectedPreset()
838
780
  });
839
781
  }
840
- async function le(u) {
841
- var W, r, s, l;
842
- const I = await ht(u.device);
843
- c.value = u.canvasWidth ?? o.width, k.value = u.canvasHeight ?? o.height, i.value = u.initialLayout, f.value = u.getKeyElements, m.value = u.keyboardConfig, d.value = I, w.value = u.isUSBDevice, y.value = u.lightingVersion, x.value = u.syncIntervalMs ?? 50, E.value = u.defaultParams ?? {}, M.value = we({
844
- initialPresets: u.presets ?? [],
845
- initialImported: u.importedPresets ?? [],
846
- onPresetsChange: (v) => n("presets-change", { importedSerialized: v }),
847
- onImportPreset: (v) => n("import-preset", v)
848
- }), u.selectedPresetId ? M.value.selectPreset(u.selectedPresetId) : (W = u.presets) != null && W[0] ? M.value.selectPreset(u.presets[0].id) : (r = u.importedPresets) != null && r[0] && M.value.selectPreset(u.importedPresets[0].id), await Me(), (l = (s = H.value) == null ? void 0 : s.applyFitScale) == null || l.call(s), O(), j(M.value.selectedPresetId.value), n("keyboard-ready");
782
+ async function le(l) {
783
+ var O, n, r, o;
784
+ const R = await De(l.device);
785
+ d.value = l.canvasWidth ?? i.width, P.value = l.canvasHeight ?? i.height, u.value = l.initialLayout, y.value = l.getKeyElements, k.value = l.keyboardConfig, g.value = R, p.value = l.isUSBDevice, b.value = l.lightingVersion, x.value = l.syncIntervalMs ?? 50, L.value = l.defaultParams ?? {}, C.value = we({
786
+ initialPresets: l.presets ?? [],
787
+ initialImported: l.importedPresets ?? [],
788
+ onPresetsChange: (c) => s("presets-change", { importedSerialized: c }),
789
+ onImportPreset: (c) => s("import-preset", c)
790
+ }), l.selectedPresetId ? C.value.selectPreset(l.selectedPresetId) : (O = l.presets) != null && O[0] ? C.value.selectPreset(l.presets[0].id) : (n = l.importedPresets) != null && n[0] && C.value.selectPreset(l.importedPresets[0].id), await Me(), (o = (r = _.value) == null ? void 0 : r.applyFitScale) == null || o.call(r), W(), G(C.value.selectedPresetId.value), s("keyboard-ready");
849
791
  }
850
- function ne(u) {
851
- M.value.selectPreset(u), j(u);
792
+ function ne(l) {
793
+ C.value.selectPreset(l), G(l);
852
794
  }
853
- async function ce(u) {
854
- await M.value.deleteImportedPreset(u), j(M.value.selectedPresetId.value);
795
+ async function ue(l) {
796
+ await C.value.deleteImportedPreset(l), G(C.value.selectedPresetId.value);
855
797
  }
856
- async function ue(u) {
857
- const I = await M.value.importPreset(u);
858
- return I && j(I.id), I;
798
+ async function ce(l) {
799
+ const R = await C.value.importPreset(l);
800
+ return R && G(R.id), R;
859
801
  }
860
- function U(u, I) {
861
- S(u, I);
862
- const W = K.value, r = {
863
- key: u,
864
- value: I,
865
- params: ie(W, p.value)
802
+ function X(l, R) {
803
+ z(l, R);
804
+ const O = K.value, n = {
805
+ key: l,
806
+ value: R,
807
+ params: ie(O, h.value)
866
808
  };
867
- n("param-change", r);
809
+ s("param-change", n);
868
810
  }
869
811
  function re() {
870
- const u = M.value;
812
+ const l = C.value;
871
813
  return {
872
- presetList: u.presetList,
873
- selectedPresetId: u.selectedPresetId,
874
- selectedPreset: u.selectedPreset,
875
- isInitialPreset: u.isInitialPreset
814
+ presetList: l.presetList,
815
+ selectedPresetId: l.selectedPresetId,
816
+ selectedPreset: l.selectedPreset,
817
+ isInitialPreset: l.isInitialPreset
876
818
  };
877
819
  }
878
820
  function Q() {
879
- return ie(K.value, p.value);
821
+ return ie(K.value, h.value);
880
822
  }
881
823
  function de() {
882
- var u, I;
883
- (I = (u = H.value) == null ? void 0 : u.resetLayout) == null || I.call(u);
824
+ var l, R;
825
+ (R = (l = _.value) == null ? void 0 : l.resetLayout) == null || R.call(l);
884
826
  }
885
827
  return ae(
886
- () => [m.value, d.value, w.value, y.value],
887
- () => O()
828
+ () => [k.value, g.value, p.value, b.value],
829
+ () => W()
888
830
  ), t({
889
831
  init: le,
890
832
  getPresetState: re,
891
833
  selectPreset: ne,
892
- deletePreset: ce,
893
- importPreset: ue,
894
- setParam: U,
834
+ deletePreset: ue,
835
+ importPreset: ce,
836
+ setParam: X,
895
837
  getParamValues: Q,
896
838
  resetKeyboardLayout: de,
897
839
  getKeyElements: V
898
- }), (u, I) => (ee(), te("div", {
840
+ }), (l, R) => (ee(), te("div", {
899
841
  class: "preview-wrap",
900
- style: oe(D.value)
842
+ style: oe(q.value)
901
843
  }, [
902
- X("canvas", {
844
+ j("canvas", {
903
845
  ref_key: "canvasEl",
904
846
  ref: A,
905
847
  class: "preview-canvas",
906
- width: c.value,
907
- height: k.value
908
- }, null, 8, gt),
909
- Ve(ze, {
848
+ width: d.value,
849
+ height: P.value
850
+ }, null, 8, ft),
851
+ Ve(Se, {
910
852
  ref_key: "overlayRef",
911
- ref: H,
912
- "canvas-width": c.value,
913
- "canvas-height": k.value,
914
- "initial-layout": i.value,
915
- "on-layout-change": B,
853
+ ref: _,
854
+ "canvas-width": d.value,
855
+ "canvas-height": P.value,
856
+ "initial-layout": u.value,
857
+ "on-layout-change": F,
916
858
  "get-key-elements": V
917
859
  }, {
918
860
  keyboard: Ne(() => [
919
- ke(u.$slots, "keyboard", {}, void 0, !0)
861
+ Ce(l.$slots, "keyboard", {}, void 0, !0)
920
862
  ]),
921
863
  _: 3
922
864
  }, 8, ["canvas-width", "canvas-height", "initial-layout"])
923
865
  ], 4));
924
866
  }
925
- }), yt = ".preview-wrap[data-v-ba92361e]{position:relative;flex-shrink:0;overflow:hidden;border-radius:8px;background:#000}.preview-canvas[data-v-ba92361e]{display:block;width:100%;height:100%}", pt = /* @__PURE__ */ Se(mt, [["styles", [yt]], ["__scopeId", "data-v-ba92361e"]]), wt = Pe(
926
- pt
927
- ), xt = Pe(
928
- ze
867
+ }), gt = ".preview-wrap[data-v-ba92361e]{position:relative;flex-shrink:0;overflow:hidden;border-radius:8px;background:#000}.preview-canvas[data-v-ba92361e]{display:block;width:100%;height:100%}", mt = /* @__PURE__ */ ze(ht, [["styles", [gt]], ["__scopeId", "data-v-ba92361e"]]), yt = Pe(
868
+ mt
869
+ ), pt = Pe(
870
+ Se
929
871
  );
930
- function bt() {
872
+ function wt() {
931
873
  const e = [
932
- ["hfd-ai-lighting", wt],
933
- ["hfd-ai-lighting-keyboard-overlay", xt]
874
+ ["hfd-ai-lighting", yt],
875
+ ["hfd-ai-lighting-keyboard-overlay", pt]
934
876
  ];
935
877
  for (const [t, a] of e)
936
878
  customElements.get(t) || customElements.define(t, a);
937
879
  }
938
- bt();
880
+ wt();
939
881
  export {
940
- wt as HfdAiLightingElement,
941
- xt as HfdAiLightingKeyboardOverlayElement,
942
- Pt as deserializePreset,
943
- bt as registerAiLightingElements,
882
+ yt as HfdAiLightingElement,
883
+ pt as HfdAiLightingKeyboardOverlayElement,
884
+ Mt as deserializePreset,
885
+ wt as registerAiLightingElements,
944
886
  Ke as serializePreset,
945
- ut as validatePreset
887
+ dt as validatePreset
946
888
  };