PluginProbe
Gutenberg / trunk
Gutenberg vtrunk
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | build/modules/block-library/playlist/view.js +774 -761 23.9.1 → trunk View file →
@@ -1,550 +1,563 @@
1 1 // packages/block-library/build-module/playlist/view.mjs
2 2 import { store, getContext, getElement } from "@wordpress/interactivity";
3 3
4 4 // node_modules/colord/index.mjs
5 -var r = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
6 -var t = function(r2) {
5 +for (r = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, t = function(r2) {
7 6 return "string" == typeof r2 ? r2.length > 0 : "number" == typeof r2;
8 -};
9 -var n = function(r2, t2, n2) {
7 +}, n = function(r2, t2, n2) {
10 8 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r2) / n2 + 0;
11 -};
12 -var e = function(r2, t2, n2) {
9 +}, u = function(r2, t2, n2) {
13 10 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r2 > n2 ? n2 : r2 > t2 ? r2 : t2;
14 -};
15 -var u = function(r2) {
16 - return (r2 = isFinite(r2) ? r2 % 360 : 0) > 0 ? r2 : r2 + 360;
17 -};
18 -var a = function(r2) {
19 - return { r: e(r2.r, 0, 255), g: e(r2.g, 0, 255), b: e(r2.b, 0, 255), a: e(r2.a) };
20 -};
21 -var o = function(r2) {
11 +}, e2 = function(r2) {
12 + return (r2 = isFinite(r2) ? r2 % 360 : 0) < 0 ? r2 + 360 : r2;
13 +}, o = function(r2, t2) {
14 + return void 0 === t2 && (t2 = 0), n(r2, t2) % 360;
15 +}, a = function(r2) {
16 + return { r: u(r2.r, 0, 255), g: u(r2.g, 0, 255), b: u(r2.b, 0, 255), a: u(r2.a) };
17 +}, i = function(r2) {
22 18 return { r: n(r2.r), g: n(r2.g), b: n(r2.b), a: n(r2.a, 3) };
19 +}, s = /^#([0-9a-f]{3,8})$/i, d = function(r2, t2) {
20 + var n2 = r2.charCodeAt(t2);
21 + return (15 & n2) + 9 * (n2 >> 6);
22 +}, h = function(r2, t2) {
23 + return d(r2, t2) << 4 | d(r2, t2 + 1);
24 +}, b = [], f = 0; f < 256; f++) b.push((f < 16 ? "0" : "") + f.toString(16));
25 +var r;
26 +var t;
27 +var n;
28 +var u;
29 +var e2;
30 +var o;
31 +var a;
32 +var i;
33 +var s;
34 +var d;
35 +var h;
36 +var b;
37 +var f;
38 +var g = function(r) {
39 + return b[u(r, 0, 255)];
23 40 };
24 -var i = /^#([0-9a-f]{3,8})$/i;
25 -var s = function(r2) {
26 - var t2 = r2.toString(16);
27 - return t2.length < 2 ? "0" + t2 : t2;
41 +var c = function(r) {
42 + var t = r.r, n = r.g, u = r.b, e2 = r.a, o = Math.max(t, n, u), a = o - Math.min(t, n, u), i = a ? o === t ? (n - u) / a : o === n ? 2 + (u - t) / a : 4 + (t - n) / a : 0;
43 + return { h: 60 * (i < 0 ? i + 6 : i), s: o ? a / o * 100 : 0, v: o / 255 * 100, a: e2 };
28 44 };
29 -var h = function(r2) {
30 - var t2 = r2.r, n2 = r2.g, e3 = r2.b, u2 = r2.a, a2 = Math.max(t2, n2, e3), o2 = a2 - Math.min(t2, n2, e3), i2 = o2 ? a2 === t2 ? (n2 - e3) / o2 : a2 === n2 ? 2 + (e3 - t2) / o2 : 4 + (t2 - n2) / o2 : 0;
31 - return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
45 +var v = function(r) {
46 + var t = r.h, n = r.s, u = r.v, e2 = r.a;
47 + t = t / 360 * 6, n /= 100, u /= 100;
48 + var o = Math.floor(t), a = u * (1 - n), i = u * (1 - (t - o) * n), s = u * (1 - (1 - t + o) * n), d = o % 6;
49 + return { r: 255 * [u, i, a, a, s, u][d], g: 255 * [s, u, u, i, a, a][d], b: 255 * [a, a, s, u, u, i][d], a: e2 };
32 50 };
33 -var b = function(r2) {
34 - var t2 = r2.h, n2 = r2.s, e3 = r2.v, u2 = r2.a;
35 - t2 = t2 / 360 * 6, n2 /= 100, e3 /= 100;
36 - var a2 = Math.floor(t2), o2 = e3 * (1 - n2), i2 = e3 * (1 - (t2 - a2) * n2), s2 = e3 * (1 - (1 - t2 + a2) * n2), h2 = a2 % 6;
37 - return { r: 255 * [e3, i2, o2, o2, s2, e3][h2], g: 255 * [s2, e3, e3, i2, o2, o2][h2], b: 255 * [o2, o2, s2, e3, e3, i2][h2], a: u2 };
51 +var l = function(r) {
52 + return { h: e2(r.h), s: u(r.s, 0, 100), l: u(r.l, 0, 100), a: u(r.a) };
38 53 };
39 -var g = function(r2) {
40 - return { h: u(r2.h), s: e(r2.s, 0, 100), l: e(r2.l, 0, 100), a: e(r2.a) };
54 +var p = function(r) {
55 + return { h: o(r.h), s: n(r.s), l: n(r.l), a: n(r.a, 3) };
41 56 };
42 -var d = function(r2) {
43 - return { h: n(r2.h), s: n(r2.s), l: n(r2.l), a: n(r2.a, 3) };
57 +var m = function(r) {
58 + return v((n = (t = r).s, { h: t.h, s: (n *= ((u = t.l) < 50 ? u : 100 - u) / 100) > 0 ? 2 * n / (u + n) * 100 : 0, v: u + n, a: t.a }));
59 + var t, n, u;
44 60 };
45 -var f = function(r2) {
46 - return b((n2 = (t2 = r2).s, { h: t2.h, s: (n2 *= ((e3 = t2.l) < 50 ? e3 : 100 - e3) / 100) > 0 ? 2 * n2 / (e3 + n2) * 100 : 0, v: e3 + n2, a: t2.a }));
47 - var t2, n2, e3;
61 +var y = function(r) {
62 + return { h: (t = c(r)).h, s: (e2 = (200 - (n = t.s)) * (u = t.v) / 100) > 0 && e2 < 200 ? n * u / 100 / (e2 <= 100 ? e2 : 200 - e2) * 100 : 0, l: e2 / 2, a: t.a };
63 + var t, n, u, e2;
48 64 };
49 -var c = function(r2) {
50 - return { h: (t2 = h(r2)).h, s: (u2 = (200 - (n2 = t2.s)) * (e3 = t2.v) / 100) > 0 && u2 < 200 ? n2 * e3 / 100 / (u2 <= 100 ? u2 : 200 - u2) * 100 : 0, l: u2 / 2, a: t2.a };
51 - var t2, n2, e3, u2;
52 -};
53 -var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
54 -var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
55 -var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
56 -var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
57 -var y = { string: [[function(r2) {
58 - var t2 = i.exec(r2);
59 - return t2 ? (r2 = t2[1]).length <= 4 ? { r: parseInt(r2[0] + r2[0], 16), g: parseInt(r2[1] + r2[1], 16), b: parseInt(r2[2] + r2[2], 16), a: 4 === r2.length ? n(parseInt(r2[3] + r2[3], 16) / 255, 2) : 1 } : 6 === r2.length || 8 === r2.length ? { r: parseInt(r2.substr(0, 2), 16), g: parseInt(r2.substr(2, 2), 16), b: parseInt(r2.substr(4, 2), 16), a: 8 === r2.length ? n(parseInt(r2.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
60 -}, "hex"], [function(r2) {
61 - var t2 = v.exec(r2) || m.exec(r2);
62 - return t2 ? t2[2] !== t2[4] || t2[4] !== t2[6] ? null : a({ r: Number(t2[1]) / (t2[2] ? 100 / 255 : 1), g: Number(t2[3]) / (t2[4] ? 100 / 255 : 1), b: Number(t2[5]) / (t2[6] ? 100 / 255 : 1), a: void 0 === t2[7] ? 1 : Number(t2[7]) / (t2[8] ? 100 : 1) }) : null;
63 -}, "rgb"], [function(t2) {
64 - var n2 = l.exec(t2) || p.exec(t2);
65 - if (!n2) return null;
66 - var e3, u2, a2 = g({ h: (e3 = n2[1], u2 = n2[2], void 0 === u2 && (u2 = "deg"), Number(e3) * (r[u2] || 1)), s: Number(n2[3]), l: Number(n2[4]), a: void 0 === n2[5] ? 1 : Number(n2[5]) / (n2[6] ? 100 : 1) });
67 - return f(a2);
68 -}, "hsl"]], object: [[function(r2) {
69 - var n2 = r2.r, e3 = r2.g, u2 = r2.b, o2 = r2.a, i2 = void 0 === o2 ? 1 : o2;
70 - return t(n2) && t(e3) && t(u2) ? a({ r: Number(n2), g: Number(e3), b: Number(u2), a: Number(i2) }) : null;
71 -}, "rgb"], [function(r2) {
72 - var n2 = r2.h, e3 = r2.s, u2 = r2.l, a2 = r2.a, o2 = void 0 === a2 ? 1 : a2;
73 - if (!t(n2) || !t(e3) || !t(u2)) return null;
74 - var i2 = g({ h: Number(n2), s: Number(e3), l: Number(u2), a: Number(o2) });
75 - return f(i2);
76 -}, "hsl"], [function(r2) {
77 - var n2 = r2.h, a2 = r2.s, o2 = r2.v, i2 = r2.a, s2 = void 0 === i2 ? 1 : i2;
78 - if (!t(n2) || !t(a2) || !t(o2)) return null;
79 - var h2 = (function(r3) {
80 - return { h: u(r3.h), s: e(r3.s, 0, 100), v: e(r3.v, 0, 100), a: e(r3.a) };
81 - })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
82 - return b(h2);
65 +var N = /^hsla?\(\s*([+-]?(?:\d*\.\d+|\d+))(deg|rad|grad|turn)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))%\s*,\s*([+-]?(?:\d*\.\d+|\d+))%\s*(?:,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i;
66 +var x = /^hsla?\(\s*([+-]?(?:\d*\.\d+|\d+))(deg|rad|grad|turn)?\s+([+-]?(?:\d*\.\d+|\d+))%\s+([+-]?(?:\d*\.\d+|\d+))%\s*(?:\/\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i;
67 +var M = /^rgba?\(\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*(?:,\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i;
68 +var H = /^rgba?\(\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s+([+-]?(?:\d*\.\d+|\d+))(%)?\s+([+-]?(?:\d*\.\d+|\d+))(%)?\s*(?:\/\s*([+-]?(?:\d*\.\d+|\d+))(%)?\s*)?\)$/i;
69 +var $ = { string: [[function(r) {
70 + if (!s.test(r)) return null;
71 + var t = r.length;
72 + return t <= 5 ? { r: 17 * d(r, 1), g: 17 * d(r, 2), b: 17 * d(r, 3), a: 5 === t ? n(17 * d(r, 4) / 255, 2) : 1 } : 7 === t || 9 === t ? { r: h(r, 1), g: h(r, 3), b: h(r, 5), a: 9 === t ? n(h(r, 7) / 255, 2) : 1 } : null;
73 +}, "hex"], [function(r) {
74 + var t = M.exec(r) || H.exec(r);
75 + return t ? t[2] !== t[4] || t[4] !== t[6] ? null : a({ r: Number(t[1]) / (t[2] ? 100 / 255 : 1), g: Number(t[3]) / (t[4] ? 100 / 255 : 1), b: Number(t[5]) / (t[6] ? 100 / 255 : 1), a: void 0 === t[7] ? 1 : Number(t[7]) / (t[8] ? 100 : 1) }) : null;
76 +}, "rgb"], [function(t) {
77 + var n = N.exec(t) || x.exec(t);
78 + if (!n) return null;
79 + var u, e2, o = l({ h: (u = n[1], e2 = n[2], void 0 === e2 && (e2 = "deg"), Number(u) * (r[e2] || 1)), s: Number(n[3]), l: Number(n[4]), a: void 0 === n[5] ? 1 : Number(n[5]) / (n[6] ? 100 : 1) });
80 + return m(o);
81 +}, "hsl"]], object: [[function(r) {
82 + var n = r.r, u = r.g, e2 = r.b, o = r.a, i = void 0 === o ? 1 : o;
83 + return t(n) && t(u) && t(e2) ? a({ r: Number(n), g: Number(u), b: Number(e2), a: Number(i) }) : null;
84 +}, "rgb"], [function(r) {
85 + var n = r.h, u = r.s, e2 = r.l, o = r.a, a = void 0 === o ? 1 : o;
86 + if (!t(n) || !t(u) || !t(e2)) return null;
87 + var i = l({ h: Number(n), s: Number(u), l: Number(e2), a: Number(a) });
88 + return m(i);
89 +}, "hsl"], [function(r) {
90 + var n = r.h, o = r.s, a = r.v, i = r.a, s = void 0 === i ? 1 : i;
91 + if (!t(n) || !t(o) || !t(a)) return null;
92 + var d = (function(r2) {
93 + return { h: e2(r2.h), s: u(r2.s, 0, 100), v: u(r2.v, 0, 100), a: u(r2.a) };
94 + })({ h: Number(n), s: Number(o), v: Number(a), a: Number(s) });
95 + return v(d);
83 96 }, "hsv"]] };
84 -var N = function(r2, t2) {
85 - for (var n2 = 0; n2 < t2.length; n2++) {
86 - var e3 = t2[n2][0](r2);
87 - if (e3) return [e3, t2[n2][1]];
97 +var j = function(r, t) {
98 + for (var n = 0; n < t.length; n++) {
99 + var u = t[n][0](r);
100 + if (u) return [u, t[n][1]];
88 101 }
89 102 return [null, void 0];
90 103 };
91 -var x = function(r2) {
92 - return "string" == typeof r2 ? N(r2.trim(), y.string) : "object" == typeof r2 && null !== r2 ? N(r2, y.object) : [null, void 0];
104 +var w = function(r) {
105 + return "string" == typeof r ? j(r.trim(), $.string) : "object" == typeof r && null !== r ? j(r, $.object) : [null, void 0];
93 106 };
94 -var M = function(r2, t2) {
95 - var n2 = c(r2);
96 - return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
107 +var k = function(r, t) {
108 + var n = y(r);
109 + return { h: n.h, s: u(n.s + 100 * t, 0, 100), l: n.l, a: n.a };
97 110 };
98 -var H = function(r2) {
99 - return (299 * r2.r + 587 * r2.g + 114 * r2.b) / 1e3 / 255;
111 +var E = function(r) {
112 + return (299 * r.r + 587 * r.g + 114 * r.b) / 1e3 / 255;
100 113 };
101 -var $ = function(r2, t2) {
102 - var n2 = c(r2);
103 - return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
114 +var R = function(r, t) {
115 + var n = y(r);
116 + return { h: n.h, s: n.s, l: u(n.l + 100 * t, 0, 100), a: n.a };
104 117 };
105 -var j = (function() {
106 - function r2(r3) {
107 - this.parsed = x(r3)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
118 +var q = (function() {
119 + function r(r2) {
120 + this.parsed = w(r2)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
108 121 }
109 - return r2.prototype.isValid = function() {
122 + return r.prototype.isValid = function() {
110 123 return null !== this.parsed;
111 - }, r2.prototype.brightness = function() {
112 - return n(H(this.rgba), 2);
113 - }, r2.prototype.isDark = function() {
114 - return H(this.rgba) < 0.5;
115 - }, r2.prototype.isLight = function() {
116 - return H(this.rgba) >= 0.5;
117 - }, r2.prototype.toHex = function() {
118 - return r3 = o(this.rgba), t2 = r3.r, e3 = r3.g, u2 = r3.b, i2 = (a2 = r3.a) < 1 ? s(n(255 * a2)) : "", "#" + s(t2) + s(e3) + s(u2) + i2;
119 - var r3, t2, e3, u2, a2, i2;
120 - }, r2.prototype.toRgb = function() {
121 - return o(this.rgba);
122 - }, r2.prototype.toRgbString = function() {
123 - return r3 = o(this.rgba), t2 = r3.r, n2 = r3.g, e3 = r3.b, (u2 = r3.a) < 1 ? "rgba(" + t2 + ", " + n2 + ", " + e3 + ", " + u2 + ")" : "rgb(" + t2 + ", " + n2 + ", " + e3 + ")";
124 - var r3, t2, n2, e3, u2;
125 - }, r2.prototype.toHsl = function() {
126 - return d(c(this.rgba));
127 - }, r2.prototype.toHslString = function() {
128 - return r3 = d(c(this.rgba)), t2 = r3.h, n2 = r3.s, e3 = r3.l, (u2 = r3.a) < 1 ? "hsla(" + t2 + ", " + n2 + "%, " + e3 + "%, " + u2 + ")" : "hsl(" + t2 + ", " + n2 + "%, " + e3 + "%)";
129 - var r3, t2, n2, e3, u2;
130 - }, r2.prototype.toHsv = function() {
131 - return r3 = h(this.rgba), { h: n(r3.h), s: n(r3.s), v: n(r3.v), a: n(r3.a, 3) };
132 - var r3;
133 - }, r2.prototype.invert = function() {
134 - return w({ r: 255 - (r3 = this.rgba).r, g: 255 - r3.g, b: 255 - r3.b, a: r3.a });
135 - var r3;
136 - }, r2.prototype.saturate = function(r3) {
137 - return void 0 === r3 && (r3 = 0.1), w(M(this.rgba, r3));
138 - }, r2.prototype.desaturate = function(r3) {
139 - return void 0 === r3 && (r3 = 0.1), w(M(this.rgba, -r3));
140 - }, r2.prototype.grayscale = function() {
141 - return w(M(this.rgba, -1));
142 - }, r2.prototype.lighten = function(r3) {
143 - return void 0 === r3 && (r3 = 0.1), w($(this.rgba, r3));
144 - }, r2.prototype.darken = function(r3) {
145 - return void 0 === r3 && (r3 = 0.1), w($(this.rgba, -r3));
146 - }, r2.prototype.rotate = function(r3) {
147 - return void 0 === r3 && (r3 = 15), this.hue(this.hue() + r3);
148 - }, r2.prototype.alpha = function(r3) {
149 - return "number" == typeof r3 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r3 }) : n(this.rgba.a, 3);
150 - var t2;
151 - }, r2.prototype.hue = function(r3) {
152 - var t2 = c(this.rgba);
153 - return "number" == typeof r3 ? w({ h: r3, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
154 - }, r2.prototype.isEqual = function(r3) {
155 - return this.toHex() === w(r3).toHex();
156 - }, r2;
124 + }, r.prototype.brightness = function() {
125 + return n(E(this.rgba), 2);
126 + }, r.prototype.isDark = function() {
127 + return E(this.rgba) < 0.5;
128 + }, r.prototype.isLight = function() {
129 + return E(this.rgba) >= 0.5;
130 + }, r.prototype.toHex = function() {
131 + return r2 = i(this.rgba), t = r2.r, u = r2.g, e2 = r2.b, a = (o = r2.a) < 1 ? g(n(255 * o)) : "", "#" + g(t) + g(u) + g(e2) + a;
132 + var r2, t, u, e2, o, a;
133 + }, r.prototype.toRgb = function() {
134 + return i(this.rgba);
135 + }, r.prototype.toRgbString = function() {
136 + return r2 = i(this.rgba), t = r2.r, n = r2.g, u = r2.b, (e2 = r2.a) < 1 ? "rgba(" + t + ", " + n + ", " + u + ", " + e2 + ")" : "rgb(" + t + ", " + n + ", " + u + ")";
137 + var r2, t, n, u, e2;
138 + }, r.prototype.toHsl = function() {
139 + return p(y(this.rgba));
140 + }, r.prototype.toHslString = function() {
141 + return r2 = p(y(this.rgba)), t = r2.h, n = r2.s, u = r2.l, (e2 = r2.a) < 1 ? "hsla(" + t + ", " + n + "%, " + u + "%, " + e2 + ")" : "hsl(" + t + ", " + n + "%, " + u + "%)";
142 + var r2, t, n, u, e2;
143 + }, r.prototype.toHsv = function() {
144 + return r2 = c(this.rgba), { h: o(r2.h), s: n(r2.s), v: n(r2.v), a: n(r2.a, 3) };
145 + var r2;
146 + }, r.prototype.invert = function() {
147 + return A({ r: 255 - (r2 = this.rgba).r, g: 255 - r2.g, b: 255 - r2.b, a: r2.a });
148 + var r2;
149 + }, r.prototype.saturate = function(r2) {
150 + return void 0 === r2 && (r2 = 0.1), A(k(this.rgba, r2));
151 + }, r.prototype.desaturate = function(r2) {
152 + return void 0 === r2 && (r2 = 0.1), A(k(this.rgba, -r2));
153 + }, r.prototype.grayscale = function() {
154 + return A(k(this.rgba, -1));
155 + }, r.prototype.lighten = function(r2) {
156 + return void 0 === r2 && (r2 = 0.1), A(R(this.rgba, r2));
157 + }, r.prototype.darken = function(r2) {
158 + return void 0 === r2 && (r2 = 0.1), A(R(this.rgba, -r2));
159 + }, r.prototype.rotate = function(r2) {
160 + return void 0 === r2 && (r2 = 15), this.hue(y(this.rgba).h + r2);
161 + }, r.prototype.alpha = function(r2) {
162 + return "number" == typeof r2 ? A({ r: (t = this.rgba).r, g: t.g, b: t.b, a: r2 }) : n(this.rgba.a, 3);
163 + var t;
164 + }, r.prototype.hue = function(r2) {
165 + var t = y(this.rgba);
166 + return "number" == typeof r2 ? A({ h: r2, s: t.s, l: t.l, a: t.a }) : o(t.h);
167 + }, r.prototype.isEqual = function(r2) {
168 + return this.toHex() === A(r2).toHex();
169 + }, r;
157 170 })();
158 -var w = function(r2) {
159 - return r2 instanceof j ? r2 : new j(r2);
171 +var A = function(r) {
172 + return r instanceof q ? r : new q(r);
160 173 };
161 174
162 175 // node_modules/@arraypress/waveform-player/dist/waveform-player.esm.js
163 -function $2(e3) {
164 - let t2 = -1 / 0;
165 - for (let i2 = 0; i2 < e3.length; i2++) e3[i2] > t2 && (t2 = e3[i2]);
166 - return t2;
176 +function $2(e2) {
177 + let t = -1 / 0;
178 + for (let i = 0; i < e2.length; i++) e2[i] > t && (t = e2[i]);
179 + return t;
167 180 }
168 -function S(e3) {
169 - return String(e3 ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
181 +function S(e2) {
182 + return String(e2 ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
170 183 }
171 -function q(e3) {
172 - return S(typeof e3 == "number" ? `${e3}px` : e3);
184 +function q2(e2) {
185 + return S(typeof e2 == "number" ? `${e2}px` : e2);
173 186 }
174 -function st(e3) {
175 - if (typeof e3 != "string" || e3 === "") return false;
187 +function st(e2) {
188 + if (typeof e2 != "string" || e2 === "") return false;
176 189 try {
177 - let t2 = new URL(e3, "http://localhost/");
178 - return t2.protocol === "http:" || t2.protocol === "https:";
190 + let t = new URL(e2, "http://localhost/");
191 + return t.protocol === "http:" || t.protocol === "https:";
179 192 } catch {
180 193 return false;
181 194 }
182 195 }
183 -function m2(e3, t2 = 0, i2 = 1) {
184 - return Math.max(t2, Math.min(e3, i2));
196 +function m2(e2, t = 0, i = 1) {
197 + return Math.max(t, Math.min(e2, i));
185 198 }
186 -function _(e3, t2 = null, i2 = {}) {
187 - let { min: s2 = -1 / 0, max: r2 = 1 / 0, integer: a2 = false } = i2, o2 = typeof e3 == "number" ? e3 : typeof e3 == "string" && e3.trim() !== "" ? Number(e3) : NaN;
188 - if (!Number.isFinite(o2)) return t2;
189 - let n2 = m2(o2, s2, r2);
190 - return a2 ? Math.round(n2) : n2;
199 +function _(e2, t = null, i = {}) {
200 + let { min: s = -1 / 0, max: r = 1 / 0, integer: a = false } = i, o = typeof e2 == "number" ? e2 : typeof e2 == "string" && e2.trim() !== "" ? Number(e2) : NaN;
201 + if (!Number.isFinite(o)) return t;
202 + let n = m2(o, s, r);
203 + return a ? Math.round(n) : n;
191 204 }
192 -function H2(e3, t2 = null) {
193 - if (Array.isArray(e3)) return e3;
194 - if (typeof e3 == "string" && e3.trim().startsWith("[")) try {
195 - let i2 = JSON.parse(e3);
196 - if (Array.isArray(i2)) return i2;
205 +function H2(e2, t = null) {
206 + if (Array.isArray(e2)) return e2;
207 + if (typeof e2 == "string" && e2.trim().startsWith("[")) try {
208 + let i = JSON.parse(e2);
209 + if (Array.isArray(i)) return i;
197 210 } catch {
198 211 }
199 - return t2;
212 + return t;
200 213 }
201 -function D(e3, t2 = {}) {
202 - let { min: i2 = -1 / 0, max: s2 = 1 / 0, fallback: r2 = null } = t2, a2 = H2(e3);
203 - if (!a2 && typeof e3 == "string" && e3.trim() !== "" && (a2 = e3.split(/[,\s]+/)), !a2) return r2;
204 - let o2 = a2.map((n2) => _(n2)).filter((n2) => n2 !== null && n2 >= i2 && n2 <= s2);
205 - return o2.length ? o2 : r2;
214 +function D(e2, t = {}) {
215 + let { min: i = -1 / 0, max: s = 1 / 0, fallback: r = null } = t, a = H2(e2);
216 + if (!a && typeof e2 == "string" && e2.trim() !== "" && (a = e2.split(/[,\s]+/)), !a) return r;
217 + let o = a.map((n) => _(n)).filter((n) => n !== null && n >= i && n <= s);
218 + return o.length ? o : r;
206 219 }
207 -function rt(e3, t2, i2 = null) {
208 - return t2.includes(e3) ? e3 : i2;
220 +function rt(e2, t, i = null) {
221 + return t.includes(e2) ? e2 : i;
209 222 }
210 -function at(e3) {
211 - if (typeof e3 == "string") {
212 - let t2 = e3.trim().toLowerCase();
213 - return t2 !== "" && t2 !== "false" && t2 !== "0";
223 +function at(e2) {
224 + if (typeof e2 == "string") {
225 + let t = e2.trim().toLowerCase();
226 + return t !== "" && t !== "false" && t !== "0";
214 227 }
215 - return !!e3;
228 + return !!e2;
216 229 }
217 -function vt(e3) {
218 - return e3 === void 0 ? void 0 : e3 === "true";
230 +function vt(e2) {
231 + return e2 === void 0 ? void 0 : e2 === "true";
219 232 }
220 -function it(e3) {
221 - if (typeof e3 == "string" && e3.trim().startsWith("[")) try {
222 - return JSON.parse(e3);
233 +function it(e2) {
234 + if (typeof e2 == "string" && e2.trim().startsWith("[")) try {
235 + return JSON.parse(e2);
223 236 } catch {
224 237 }
225 - return e3;
238 + return e2;
226 239 }
227 -function O(e3) {
228 - let t2 = {}, i2 = (o2, n2 = o2) => {
229 - let l2 = vt(e3.dataset[n2]);
230 - l2 !== void 0 && (t2[o2] = l2);
231 - }, s2 = (o2, n2 = o2, l2 = false) => {
232 - let h2 = e3.dataset[n2];
233 - h2 && (t2[o2] = l2 ? parseFloat(h2) : parseInt(h2, 10));
234 - }, r2 = (o2, n2 = o2) => {
235 - let l2 = e3.dataset[n2];
236 - l2 && (t2[o2] = /^\d+(\.\d+)?$/.test(l2.trim()) ? parseFloat(l2) : l2);
237 - }, a2 = (o2, n2 = o2) => {
238 - let l2 = e3.dataset[n2];
240 +function O(e2) {
241 + let t = {}, i = (o, n = o) => {
242 + let l2 = vt(e2.dataset[n]);
243 + l2 !== void 0 && (t[o] = l2);
244 + }, s = (o, n = o, l2 = false) => {
245 + let h = e2.dataset[n];
246 + h && (t[o] = l2 ? parseFloat(h) : parseInt(h, 10));
247 + }, r = (o, n = o) => {
248 + let l2 = e2.dataset[n];
249 + l2 && (t[o] = /^\d+(\.\d+)?$/.test(l2.trim()) ? parseFloat(l2) : l2);
250 + }, a = (o, n = o) => {
251 + let l2 = e2.dataset[n];
239 252 if (!l2) return;
240 - let h2 = H2(l2);
241 - h2 ? t2[o2] = h2 : console.warn(`[WaveformPlayer] Invalid ${n2} attribute, expected a JSON array:`, l2);
253 + let h = H2(l2);
254 + h ? t[o] = h : console.warn(`[WaveformPlayer] Invalid ${n} attribute, expected a JSON array:`, l2);
242 255 };
243 - if (e3.dataset.src && (t2.url = e3.dataset.src), e3.dataset.url && (t2.url = e3.dataset.url), s2("height"), s2("samples"), e3.dataset.preload && (t2.preload = e3.dataset.preload), e3.dataset.crossOrigin && (t2.crossOrigin = e3.dataset.crossOrigin), e3.dataset.audioMode && (t2.audioMode = e3.dataset.audioMode), e3.dataset.style && (t2.waveformStyle = e3.dataset.style), e3.dataset.waveformStyle && (t2.waveformStyle = e3.dataset.waveformStyle), e3.dataset.waveformGradient && (t2.waveformGradient = e3.dataset.waveformGradient), s2("barWidth"), s2("barSpacing"), s2("barRadius"), e3.dataset.buttonAlign && (t2.buttonAlign = e3.dataset.buttonAlign), e3.dataset.layout && (t2.layout = e3.dataset.layout), e3.dataset.buttonStyle && (t2.buttonStyle = e3.dataset.buttonStyle), r2("buttonSize"), r2("buttonRadius"), e3.dataset.colorPreset && (t2.colorPreset = e3.dataset.colorPreset), e3.dataset.waveformColor && (t2.waveformColor = it(e3.dataset.waveformColor)), e3.dataset.progressColor && (t2.progressColor = it(e3.dataset.progressColor)), e3.dataset.color && (t2.waveformColor = e3.dataset.color), e3.dataset.theme && (t2.colorPreset = e3.dataset.theme), i2("autoplay"), i2("showControls"), i2("showInfo"), i2("showTime"), i2("showHoverTime"), i2("seekHandle"), i2("showBPM", "showBpm"), s2("bpm"), i2("singlePlay"), i2("playOnSeek"), e3.dataset.title && (t2.title = e3.dataset.title), e3.dataset.artist && (t2.artist = e3.dataset.artist), e3.dataset.album && (t2.album = e3.dataset.album), e3.dataset.artwork && (t2.artwork = e3.dataset.artwork), e3.dataset.artworkPosition && (t2.artworkPosition = e3.dataset.artworkPosition), e3.dataset.waveform && (t2.waveform = e3.dataset.waveform), a2("markers"), s2("playbackRate", "playbackRate", true), i2("showPlaybackSpeed"), e3.dataset.playbackRates) {
244 - let o2 = D(e3.dataset.playbackRates);
245 - o2 ? t2.playbackRates = o2 : console.warn("[WaveformPlayer] Invalid playbackRates attribute:", e3.dataset.playbackRates);
256 + if (e2.dataset.src && (t.url = e2.dataset.src), e2.dataset.url && (t.url = e2.dataset.url), s("height"), s("samples"), e2.dataset.preload && (t.preload = e2.dataset.preload), e2.dataset.crossOrigin && (t.crossOrigin = e2.dataset.crossOrigin), e2.dataset.audioMode && (t.audioMode = e2.dataset.audioMode), e2.dataset.style && (t.waveformStyle = e2.dataset.style), e2.dataset.waveformStyle && (t.waveformStyle = e2.dataset.waveformStyle), e2.dataset.waveformGradient && (t.waveformGradient = e2.dataset.waveformGradient), s("barWidth"), s("barSpacing"), s("barRadius"), e2.dataset.buttonAlign && (t.buttonAlign = e2.dataset.buttonAlign), e2.dataset.layout && (t.layout = e2.dataset.layout), e2.dataset.buttonStyle && (t.buttonStyle = e2.dataset.buttonStyle), r("buttonSize"), r("buttonRadius"), e2.dataset.colorPreset && (t.colorPreset = e2.dataset.colorPreset), e2.dataset.waveformColor && (t.waveformColor = it(e2.dataset.waveformColor)), e2.dataset.progressColor && (t.progressColor = it(e2.dataset.progressColor)), e2.dataset.color && (t.waveformColor = e2.dataset.color), e2.dataset.theme && (t.colorPreset = e2.dataset.theme), i("autoplay"), i("showControls"), i("showInfo"), i("showTime"), i("showHoverTime"), i("seekHandle"), i("showBPM", "showBpm"), s("bpm"), i("singlePlay"), i("playOnSeek"), e2.dataset.title && (t.title = e2.dataset.title), e2.dataset.artist && (t.artist = e2.dataset.artist), e2.dataset.album && (t.album = e2.dataset.album), e2.dataset.artwork && (t.artwork = e2.dataset.artwork), e2.dataset.artworkPosition && (t.artworkPosition = e2.dataset.artworkPosition), e2.dataset.waveform && (t.waveform = e2.dataset.waveform), a("markers"), s("playbackRate", "playbackRate", true), i("showPlaybackSpeed"), e2.dataset.playbackRates) {
257 + let o = D(e2.dataset.playbackRates);
258 + o ? t.playbackRates = o : console.warn("[WaveformPlayer] Invalid playbackRates attribute:", e2.dataset.playbackRates);
246 259 }
247 - return i2("enableMediaSession"), i2("showMarkers"), i2("accessibleSeek"), e3.dataset.seekLabel && (t2.seekLabel = e3.dataset.seekLabel), e3.dataset.seekValueText && (t2.seekValueText = e3.dataset.seekValueText), e3.dataset.errorText && (t2.errorText = e3.dataset.errorText), e3.dataset.playPauseLabel && (t2.playPauseLabel = e3.dataset.playPauseLabel), e3.dataset.speedLabel && (t2.speedLabel = e3.dataset.speedLabel), e3.dataset.artworkAlt && (t2.artworkAlt = e3.dataset.artworkAlt), e3.dataset.unknownTrackText && (t2.unknownTrackText = e3.dataset.unknownTrackText), t2;
260 + return i("enableMediaSession"), i("showMarkers"), i("accessibleSeek"), e2.dataset.seekLabel && (t.seekLabel = e2.dataset.seekLabel), e2.dataset.seekValueText && (t.seekValueText = e2.dataset.seekValueText), e2.dataset.errorText && (t.errorText = e2.dataset.errorText), e2.dataset.playPauseLabel && (t.playPauseLabel = e2.dataset.playPauseLabel), e2.dataset.speedLabel && (t.speedLabel = e2.dataset.speedLabel), e2.dataset.artworkAlt && (t.artworkAlt = e2.dataset.artworkAlt), e2.dataset.unknownTrackText && (t.unknownTrackText = e2.dataset.unknownTrackText), t;
248 261 }
249 -function ot(e3, ...t2) {
250 - let i2 = 0;
251 - return e3.replace(/%(?:(\d+)\$)?s/g, (s2, r2) => {
252 - let a2 = r2 ? Number(r2) - 1 : i2++;
253 - return t2[a2] ?? s2;
262 +function ot(e2, ...t) {
263 + let i = 0;
264 + return e2.replace(/%(?:(\d+)\$)?s/g, (s, r) => {
265 + let a = r ? Number(r) - 1 : i++;
266 + return t[a] ?? s;
254 267 });
255 268 }
256 -function E(e3) {
257 - let t2 = Number(e3);
258 - if (!t2 || !Number.isFinite(t2) || t2 < 0) return "0:00";
259 - let i2 = Math.floor(t2 / 3600), s2 = Math.floor(t2 % 3600 / 60), r2 = Math.floor(t2 % 60);
260 - return i2 > 0 ? `${i2}:${s2.toString().padStart(2, "0")}:${r2.toString().padStart(2, "0")}` : `${s2}:${r2.toString().padStart(2, "0")}`;
269 +function E2(e2) {
270 + let t = Number(e2);
271 + if (!t || !Number.isFinite(t) || t < 0) return "0:00";
272 + let i = Math.floor(t / 3600), s = Math.floor(t % 3600 / 60), r = Math.floor(t % 60);
273 + return i > 0 ? `${i}:${s.toString().padStart(2, "0")}:${r.toString().padStart(2, "0")}` : `${s}:${r.toString().padStart(2, "0")}`;
261 274 }
262 275 var St = 0;
263 -function nt(e3) {
264 - let t2 = e3 || "audio", i2 = 5381;
265 - for (let s2 = 0; s2 < t2.length; s2++) i2 = (i2 << 5) + i2 + t2.charCodeAt(s2) | 0;
266 - return `wp_${(i2 >>> 0).toString(36)}_${(St++).toString(36)}`;
276 +function nt(e2) {
277 + let t = e2 || "audio", i = 5381;
278 + for (let s = 0; s < t.length; s++) i = (i << 5) + i + t.charCodeAt(s) | 0;
279 + return `wp_${(i >>> 0).toString(36)}_${(St++).toString(36)}`;
267 280 }
268 -function I(e3) {
269 - if (!e3) return "Audio";
270 - let t2 = e3.split("/");
271 - return t2[t2.length - 1].split(".")[0].replace(/[-_]/g, " ").replace(/\b\w/g, (r2) => r2.toUpperCase());
281 +function I(e2) {
282 + if (!e2) return "Audio";
283 + let t = e2.split("/");
284 + return t[t.length - 1].split(".")[0].replace(/[-_]/g, " ").replace(/\b\w/g, (r) => r.toUpperCase());
272 285 }
273 -function U(e3) {
274 - if (typeof e3 != "string") return null;
275 - let t2 = e3.match(/rgba?\(\s*([\d.]+)\s*[,\s]\s*([\d.]+)\s*[,\s]\s*([\d.]+)\s*(?:[,/]\s*([\d.]+)(%?))?/i);
276 - if (!t2) return null;
277 - let i2 = Number(t2[1]), s2 = Number(t2[2]), r2 = Number(t2[3]);
278 - if (!Number.isFinite(i2) || !Number.isFinite(s2) || !Number.isFinite(r2)) return null;
279 - let a2 = t2[4] === void 0 ? 1 : Number(t2[4]);
280 - return Number.isFinite(a2) ? (t2[5] === "%" && (a2 /= 100), { r: i2, g: s2, b: r2, a: m2(a2, 0, 1) }) : null;
286 +function U(e2) {
287 + if (typeof e2 != "string") return null;
288 + let t = e2.match(/rgba?\(\s*([\d.]+)\s*[,\s]\s*([\d.]+)\s*[,\s]\s*([\d.]+)\s*(?:[,/]\s*([\d.]+)(%?))?/i);
289 + if (!t) return null;
290 + let i = Number(t[1]), s = Number(t[2]), r = Number(t[3]);
291 + if (!Number.isFinite(i) || !Number.isFinite(s) || !Number.isFinite(r)) return null;
292 + let a = t[4] === void 0 ? 1 : Number(t[4]);
293 + return Number.isFinite(a) ? (t[5] === "%" && (a /= 100), { r: i, g: s, b: r, a: m2(a, 0, 1) }) : null;
281 294 }
282 -function lt(e3) {
283 - let t2 = U(e3);
284 - return !t2 || t2.a <= 0 ? null : (t2.r * 299 + t2.g * 587 + t2.b * 114) / 1e3;
295 +function lt(e2) {
296 + let t = U(e2);
297 + return !t || t.a <= 0 ? null : (t.r * 299 + t.g * 587 + t.b * 114) / 1e3;
285 298 }
286 -function j2(...e3) {
287 - let t2 = {};
288 - for (let i2 of e3) for (let s2 in i2) i2[s2] !== null && i2[s2] !== void 0 && (t2[s2] = i2[s2]);
289 - return t2;
299 +function j2(...e2) {
300 + let t = {};
301 + for (let i of e2) for (let s in i) i[s] !== null && i[s] !== void 0 && (t[s] = i[s]);
302 + return t;
290 303 }
291 -function ht(e3, t2) {
292 - let i2;
293 - return function(...r2) {
294 - let a2 = () => {
295 - clearTimeout(i2), e3(...r2);
304 +function ht(e2, t) {
305 + let i;
306 + return function(...r) {
307 + let a = () => {
308 + clearTimeout(i), e2(...r);
296 309 };
297 - clearTimeout(i2), i2 = setTimeout(a2, t2);
310 + clearTimeout(i), i = setTimeout(a, t);
298 311 };
299 312 }
300 -function B(e3, t2) {
301 - if (e3.length === t2) return e3;
302 - if (e3.length === 0 || t2 === 0) return [];
303 - let i2 = [];
304 - if (t2 > e3.length) {
305 - let s2 = (e3.length - 1) / (t2 - 1);
306 - for (let r2 = 0; r2 < t2; r2++) {
307 - let a2 = r2 * s2, o2 = Math.floor(a2), n2 = Math.ceil(a2), l2 = a2 - o2;
308 - if (n2 >= e3.length) i2.push(e3[e3.length - 1]);
309 - else if (o2 === n2) i2.push(e3[o2]);
313 +function B(e2, t) {
314 + if (e2.length === t) return e2;
315 + if (e2.length === 0 || t === 0) return [];
316 + let i = [];
317 + if (t > e2.length) {
318 + let s = (e2.length - 1) / (t - 1);
319 + for (let r = 0; r < t; r++) {
320 + let a = r * s, o = Math.floor(a), n = Math.ceil(a), l2 = a - o;
321 + if (n >= e2.length) i.push(e2[e2.length - 1]);
322 + else if (o === n) i.push(e2[o]);
310 323 else {
311 - let h2 = e3[o2] * (1 - l2) + e3[n2] * l2;
312 - i2.push(h2);
324 + let h = e2[o] * (1 - l2) + e2[n] * l2;
325 + i.push(h);
313 326 }
314 327 }
315 328 } else {
316 - let s2 = e3.length / t2;
317 - for (let r2 = 0; r2 < t2; r2++) {
318 - let a2 = Math.floor(r2 * s2), o2 = Math.floor((r2 + 1) * s2), n2 = 0, l2 = 0;
319 - for (let h2 = a2; h2 <= o2 && h2 < e3.length; h2++) e3[h2] > n2 && (n2 = e3[h2]), l2++;
329 + let s = e2.length / t;
330 + for (let r = 0; r < t; r++) {
331 + let a = Math.floor(r * s), o = Math.floor((r + 1) * s), n = 0, l2 = 0;
332 + for (let h = a; h <= o && h < e2.length; h++) e2[h] > n && (n = e2[h]), l2++;
320 333 if (l2 === 0) {
321 - let h2 = Math.min(Math.round(r2 * s2), e3.length - 1);
322 - n2 = e3[h2];
334 + let h = Math.min(Math.round(r * s), e2.length - 1);
335 + n = e2[h];
323 336 }
324 - i2.push(n2);
337 + i.push(n);
325 338 }
326 339 }
327 - return i2;
340 + return i;
328 341 }
329 -function P(e3, t2, i2, s2) {
330 - if (!Array.isArray(t2)) return t2;
331 - if (t2.length < 2) return t2[0];
332 - let r2 = i2.width, a2 = i2.height, o2 = s2 && s2.waveformGradient, [n2, l2, h2, c2] = o2 === "horizontal" ? [0, 0, r2, 0] : o2 === "diagonal" ? [0, 0, r2, a2] : [0, 0, 0, a2];
342 +function P(e2, t, i, s) {
343 + if (!Array.isArray(t)) return t;
344 + if (t.length < 2) return t[0];
345 + let r = i.width, a = i.height, o = s && s.waveformGradient, [n, l2, h, c2] = o === "horizontal" ? [0, 0, r, 0] : o === "diagonal" ? [0, 0, r, a] : [0, 0, 0, a];
333 346 try {
334 - let d2 = e3.createLinearGradient(n2, l2, h2, c2);
335 - return t2.forEach((b2, y2) => d2.addColorStop(y2 / (t2.length - 1), b2)), d2;
347 + let d = e2.createLinearGradient(n, l2, h, c2);
348 + return t.forEach((b, y2) => d.addColorStop(y2 / (t.length - 1), b)), d;
336 349 } catch {
337 - return t2[0];
350 + return t[0];
338 351 }
339 352 }
340 -function x2(e3, t2, i2, s2, r2, a2) {
341 - if ((Array.isArray(a2) ? a2.some((n2) => n2 > 0) : a2 > 0) && typeof e3.roundRect == "function") {
342 - let n2 = Math.min(s2 / 2, Math.abs(r2) / 2), l2 = (h2) => m2(h2, 0, n2);
343 - e3.beginPath(), e3.roundRect(t2, i2, s2, r2, Array.isArray(a2) ? a2.map(l2) : l2(a2)), e3.fill();
344 - } else e3.fillRect(t2, i2, s2, r2);
353 +function x2(e2, t, i, s, r, a) {
354 + if ((Array.isArray(a) ? a.some((n) => n > 0) : a > 0) && typeof e2.roundRect == "function") {
355 + let n = Math.min(s / 2, Math.abs(r) / 2), l2 = (h) => m2(h, 0, n);
356 + e2.beginPath(), e2.roundRect(t, i, s, r, Array.isArray(a) ? a.map(l2) : l2(a)), e2.fill();
357 + } else e2.fillRect(t, i, s, r);
345 358 }
346 -function pt(e3, t2) {
347 - return (e3.barRadius || 0) * t2;
359 +function pt(e2, t) {
360 + return (e2.barRadius || 0) * t;
348 361 }
349 -function Et(e3, t2) {
350 - let i2 = pt(e3, t2);
351 - return [i2, i2, 0, 0];
362 +function Et(e2, t) {
363 + let i = pt(e2, t);
364 + return [i, i, 0, 0];
352 365 }
353 -function ct(e3, t2, i2, s2, r2) {
354 - let a2 = r2 / 2;
355 - e3.beginPath(), e3.moveTo(t2, s2 - a2), e3.lineTo(i2 - a2, s2 - a2), e3.arc(i2 - a2, s2, a2, -Math.PI / 2, Math.PI / 2), e3.lineTo(t2, s2 + a2), e3.arc(t2, s2, a2, Math.PI / 2, -Math.PI / 2), e3.closePath();
366 +function ct(e2, t, i, s, r) {
367 + let a = r / 2;
368 + e2.beginPath(), e2.moveTo(t, s - a), e2.lineTo(i - a, s - a), e2.arc(i - a, s, a, -Math.PI / 2, Math.PI / 2), e2.lineTo(t, s + a), e2.arc(t, s, a, Math.PI / 2, -Math.PI / 2), e2.closePath();
356 369 }
357 -function V(e3, t2, i2, s2, r2) {
358 - let a2 = window.devicePixelRatio || 1, o2 = r2.barWidth * a2, n2 = r2.barSpacing * a2, l2 = Math.floor(t2.width / (o2 + n2)), h2 = B(i2, l2), c2 = t2.height, d2 = s2 * t2.width, b2 = Et(r2, a2), y2 = P(e3, r2.color, t2, r2), w2 = P(e3, r2.progressColor, t2, r2);
359 - e3.clearRect(0, 0, t2.width, t2.height), e3.fillStyle = y2;
360 - for (let f2 = 0; f2 < h2.length; f2++) {
361 - let p2 = f2 * (o2 + n2);
362 - if (p2 + o2 > t2.width) break;
363 - let g2 = h2[f2] * c2 * 0.9, u2 = c2 - g2;
364 - x2(e3, p2, u2, o2, g2, b2);
370 +function V(e2, t, i, s, r) {
371 + let a = window.devicePixelRatio || 1, o = r.barWidth * a, n = r.barSpacing * a, l2 = Math.floor(t.width / (o + n)), h = B(i, l2), c2 = t.height, d = s * t.width, b = Et(r, a), y2 = P(e2, r.color, t, r), w2 = P(e2, r.progressColor, t, r);
372 + e2.clearRect(0, 0, t.width, t.height), e2.fillStyle = y2;
373 + for (let f = 0; f < h.length; f++) {
374 + let p2 = f * (o + n);
375 + if (p2 + o > t.width) break;
376 + let g2 = h[f] * c2 * 0.9, u = c2 - g2;
377 + x2(e2, p2, u, o, g2, b);
365 378 }
366 - e3.save(), e3.beginPath(), e3.rect(0, 0, d2, c2), e3.clip(), e3.fillStyle = w2;
367 - for (let f2 = 0; f2 < h2.length; f2++) {
368 - let p2 = f2 * (o2 + n2);
369 - if (p2 > d2) break;
370 - let g2 = h2[f2] * c2 * 0.9, u2 = c2 - g2;
371 - x2(e3, p2, u2, o2, g2, b2);
379 + e2.save(), e2.beginPath(), e2.rect(0, 0, d, c2), e2.clip(), e2.fillStyle = w2;
380 + for (let f = 0; f < h.length; f++) {
381 + let p2 = f * (o + n);
382 + if (p2 > d) break;
383 + let g2 = h[f] * c2 * 0.9, u = c2 - g2;
384 + x2(e2, p2, u, o, g2, b);
372 385 }
373 - e3.restore();
386 + e2.restore();
374 387 }
375 -function Pt(e3, t2, i2, s2, r2) {
376 - let a2 = window.devicePixelRatio || 1, o2 = r2.barWidth * a2, n2 = r2.barSpacing * a2, l2 = Math.floor(t2.width / (o2 + n2)), h2 = B(i2, l2), c2 = t2.height, d2 = c2 / 2, b2 = s2 * t2.width, y2 = pt(r2, a2), w2 = [y2, y2, 0, 0], f2 = [0, 0, y2, y2], p2 = P(e3, r2.color, t2, r2), g2 = P(e3, r2.progressColor, t2, r2);
377 - e3.clearRect(0, 0, t2.width, t2.height), e3.fillStyle = p2;
378 - for (let u2 = 0; u2 < h2.length; u2++) {
379 - let k = u2 * (o2 + n2);
380 - if (k + o2 > t2.width) break;
381 - let v2 = h2[u2] * c2 * 0.45;
382 - x2(e3, k, d2 - v2, o2, v2, w2), x2(e3, k, d2, o2, v2, f2);
388 +function Pt(e2, t, i, s, r) {
389 + let a = window.devicePixelRatio || 1, o = r.barWidth * a, n = r.barSpacing * a, l2 = Math.floor(t.width / (o + n)), h = B(i, l2), c2 = t.height, d = c2 / 2, b = s * t.width, y2 = pt(r, a), w2 = [y2, y2, 0, 0], f = [0, 0, y2, y2], p2 = P(e2, r.color, t, r), g2 = P(e2, r.progressColor, t, r);
390 + e2.clearRect(0, 0, t.width, t.height), e2.fillStyle = p2;
391 + for (let u = 0; u < h.length; u++) {
392 + let k2 = u * (o + n);
393 + if (k2 + o > t.width) break;
394 + let v2 = h[u] * c2 * 0.45;
395 + x2(e2, k2, d - v2, o, v2, w2), x2(e2, k2, d, o, v2, f);
383 396 }
384 - e3.save(), e3.beginPath(), e3.rect(0, 0, b2, c2), e3.clip(), e3.fillStyle = g2;
385 - for (let u2 = 0; u2 < h2.length; u2++) {
386 - let k = u2 * (o2 + n2);
387 - if (k > b2) break;
388 - let v2 = h2[u2] * c2 * 0.45;
389 - x2(e3, k, d2 - v2, o2, v2, w2), x2(e3, k, d2, o2, v2, f2);
397 + e2.save(), e2.beginPath(), e2.rect(0, 0, b, c2), e2.clip(), e2.fillStyle = g2;
398 + for (let u = 0; u < h.length; u++) {
399 + let k2 = u * (o + n);
400 + if (k2 > b) break;
401 + let v2 = h[u] * c2 * 0.45;
402 + x2(e2, k2, d - v2, o, v2, w2), x2(e2, k2, d, o, v2, f);
390 403 }
391 - e3.restore();
404 + e2.restore();
392 405 }
393 -function Tt(e3, t2, i2, s2, r2) {
394 - let a2 = t2.width, o2 = t2.height, n2 = o2 / 2, l2 = o2 * 0.35;
395 - e3.clearRect(0, 0, a2, o2);
396 - let h2 = (c2, d2, b2 = 1, y2 = false) => {
397 - let w2 = P(e3, c2, t2, r2), f2 = Array.isArray(c2) ? c2[c2.length - 1] : c2;
398 - y2 && (e3.shadowBlur = 12, e3.shadowColor = f2), e3.strokeStyle = w2, e3.lineWidth = d2, e3.lineCap = "round", e3.lineJoin = "round", e3.beginPath(), e3.moveTo(0, n2);
399 - let p2 = [], g2 = Math.floor(i2.length * b2);
400 - for (let u2 = 0; u2 < g2; u2++) {
401 - let k = u2 / (i2.length - 1) * a2, v2 = i2[u2], A = Math.sin(u2 * 0.1) * v2, L = n2 + A * l2;
402 - p2.push({ x: k, y: L });
406 +function Tt(e2, t, i, s, r) {
407 + let a = t.width, o = t.height, n = o / 2, l2 = o * 0.35;
408 + e2.clearRect(0, 0, a, o);
409 + let h = (c2, d, b = 1, y2 = false) => {
410 + let w2 = P(e2, c2, t, r), f = Array.isArray(c2) ? c2[c2.length - 1] : c2;
411 + y2 && (e2.shadowBlur = 12, e2.shadowColor = f), e2.strokeStyle = w2, e2.lineWidth = d, e2.lineCap = "round", e2.lineJoin = "round", e2.beginPath(), e2.moveTo(0, n);
412 + let p2 = [], g2 = Math.floor(i.length * b);
413 + for (let u = 0; u < g2; u++) {
414 + let k2 = u / (i.length - 1) * a, v2 = i[u], A2 = Math.sin(u * 0.1) * v2, L = n + A2 * l2;
415 + p2.push({ x: k2, y: L });
403 416 }
404 - for (let u2 = 0; u2 < p2.length - 1; u2++) {
405 - let k = p2[u2].x + (p2[u2 + 1].x - p2[u2].x) * 0.5, v2 = p2[u2].y, A = p2[u2 + 1].x - (p2[u2 + 1].x - p2[u2].x) * 0.5, L = p2[u2 + 1].y;
406 - e3.bezierCurveTo(k, v2, A, L, p2[u2 + 1].x, p2[u2 + 1].y);
417 + for (let u = 0; u < p2.length - 1; u++) {
418 + let k2 = p2[u].x + (p2[u + 1].x - p2[u].x) * 0.5, v2 = p2[u].y, A2 = p2[u + 1].x - (p2[u + 1].x - p2[u].x) * 0.5, L = p2[u + 1].y;
419 + e2.bezierCurveTo(k2, v2, A2, L, p2[u + 1].x, p2[u + 1].y);
407 420 }
408 - e3.stroke(), y2 && (e3.shadowBlur = 0);
421 + e2.stroke(), y2 && (e2.shadowBlur = 0);
409 422 };
410 - e3.strokeStyle = "rgba(255, 255, 255, 0.03)", e3.lineWidth = 0.5, e3.beginPath(), e3.moveTo(0, n2), e3.lineTo(a2, n2), e3.stroke();
423 + e2.strokeStyle = "rgba(255, 255, 255, 0.03)", e2.lineWidth = 0.5, e2.beginPath(), e2.moveTo(0, n), e2.lineTo(a, n), e2.stroke();
411 424 for (let c2 = 0; c2 <= 10; c2++) {
412 - let d2 = a2 / 10 * c2;
413 - e3.beginPath(), e3.moveTo(d2, 0), e3.lineTo(d2, o2), e3.stroke();
425 + let d = a / 10 * c2;
426 + e2.beginPath(), e2.moveTo(d, 0), e2.lineTo(d, o), e2.stroke();
414 427 }
415 - h2(r2.color, 2, 1, false), s2 > 0 && h2(r2.progressColor, 3, s2, true);
428 + h(r.color, 2, 1, false), s > 0 && h(r.progressColor, 3, s, true);
416 429 }
417 -function ut(e3, t2, i2, s2, r2) {
418 - let a2 = window.devicePixelRatio || 1, o2 = (r2.barWidth || 3) * a2, n2 = (r2.barSpacing || 1) * a2, l2 = Math.floor(t2.width / (o2 + n2)), h2 = B(i2, l2), c2 = t2.height, d2 = 4 * a2, b2 = 2 * a2, y2 = s2 * t2.width, w2 = c2 / 2, f2 = P(e3, r2.color, t2, r2), p2 = P(e3, r2.progressColor, t2, r2);
419 - e3.clearRect(0, 0, t2.width, t2.height);
420 - for (let g2 = 0; g2 < h2.length; g2++) {
421 - let u2 = g2 * (o2 + n2);
422 - if (u2 + o2 > t2.width) break;
423 - let k = h2[g2] * c2 * 0.9, v2 = Math.floor(k / (d2 + b2));
424 - e3.fillStyle = u2 < y2 ? p2 : f2;
425 - for (let A = 0; A < v2; A++) {
426 - let L = A * (d2 + b2);
427 - e3.fillRect(u2, w2 - L - d2, o2, d2), A > 0 && e3.fillRect(u2, w2 + L, o2, d2);
430 +function ut(e2, t, i, s, r) {
431 + let a = window.devicePixelRatio || 1, o = (r.barWidth || 3) * a, n = (r.barSpacing || 1) * a, l2 = Math.floor(t.width / (o + n)), h = B(i, l2), c2 = t.height, d = 4 * a, b = 2 * a, y2 = s * t.width, w2 = c2 / 2, f = P(e2, r.color, t, r), p2 = P(e2, r.progressColor, t, r);
432 + e2.clearRect(0, 0, t.width, t.height);
433 + for (let g2 = 0; g2 < h.length; g2++) {
434 + let u = g2 * (o + n);
435 + if (u + o > t.width) break;
436 + let k2 = h[g2] * c2 * 0.9, v2 = Math.floor(k2 / (d + b));
437 + e2.fillStyle = u < y2 ? p2 : f;
438 + for (let A2 = 0; A2 < v2; A2++) {
439 + let L = A2 * (d + b);
440 + e2.fillRect(u, w2 - L - d, o, d), A2 > 0 && e2.fillRect(u, w2 + L, o, d);
428 441 }
429 442 }
430 443 }
431 -function dt(e3, t2, i2, s2, r2) {
432 - let a2 = window.devicePixelRatio || 1, o2 = (r2.barWidth || 2) * a2, n2 = (r2.barSpacing || 3) * a2, l2 = Math.floor(t2.width / (o2 + n2)), h2 = B(i2, l2), c2 = t2.height, d2 = Math.max(1.5 * a2, o2 / 2), b2 = s2 * t2.width, y2 = c2 / 2, w2 = P(e3, r2.color, t2, r2), f2 = P(e3, r2.progressColor, t2, r2);
433 - e3.clearRect(0, 0, t2.width, t2.height);
434 - for (let p2 = 0; p2 < h2.length; p2++) {
435 - let g2 = p2 * (o2 + n2) + o2 / 2;
436 - if (g2 > t2.width) break;
437 - let u2 = h2[p2] * c2 * 0.9;
438 - e3.fillStyle = g2 < b2 ? f2 : w2, e3.beginPath(), e3.arc(g2, y2 - u2 / 2, d2, 0, Math.PI * 2), e3.fill(), e3.beginPath(), e3.arc(g2, y2 + u2 / 2, d2, 0, Math.PI * 2), e3.fill();
444 +function dt(e2, t, i, s, r) {
445 + let a = window.devicePixelRatio || 1, o = (r.barWidth || 2) * a, n = (r.barSpacing || 3) * a, l2 = Math.floor(t.width / (o + n)), h = B(i, l2), c2 = t.height, d = Math.max(1.5 * a, o / 2), b = s * t.width, y2 = c2 / 2, w2 = P(e2, r.color, t, r), f = P(e2, r.progressColor, t, r);
446 + e2.clearRect(0, 0, t.width, t.height);
447 + for (let p2 = 0; p2 < h.length; p2++) {
448 + let g2 = p2 * (o + n) + o / 2;
449 + if (g2 > t.width) break;
450 + let u = h[p2] * c2 * 0.9;
451 + e2.fillStyle = g2 < b ? f : w2, e2.beginPath(), e2.arc(g2, y2 - u / 2, d, 0, Math.PI * 2), e2.fill(), e2.beginPath(), e2.arc(g2, y2 + u / 2, d, 0, Math.PI * 2), e2.fill();
439 452 }
440 453 }
441 -function At(e3, t2, i2, s2, r2) {
442 - let a2 = t2.width, o2 = t2.height, n2 = o2 / 2, l2 = 4, h2 = l2 / 2, c2 = !!r2.seekActive;
443 - if (e3.clearRect(0, 0, a2, o2), e3.fillStyle = P(e3, r2.color, t2, r2) || "rgba(255, 255, 255, 0.2)", ct(e3, h2, a2, n2, l2), e3.fill(), s2 > 0) {
444 - let d2 = Math.max(h2 * 2, s2 * a2);
445 - e3.save(), e3.globalAlpha = r2.seekHandle && !c2 ? 0.7 : 1, e3.fillStyle = P(e3, r2.progressColor, t2, r2) || "rgba(255, 255, 255, 0.9)", ct(e3, h2, d2, n2, l2), e3.fill(), e3.restore();
454 +function At(e2, t, i, s, r) {
455 + let a = t.width, o = t.height, n = o / 2, l2 = 4, h = l2 / 2, c2 = !!r.seekActive;
456 + if (e2.clearRect(0, 0, a, o), e2.fillStyle = P(e2, r.color, t, r) || "rgba(255, 255, 255, 0.2)", ct(e2, h, a, n, l2), e2.fill(), s > 0) {
457 + let d = Math.max(h * 2, s * a);
458 + e2.save(), e2.globalAlpha = r.seekHandle && !c2 ? 0.7 : 1, e2.fillStyle = P(e2, r.progressColor, t, r) || "rgba(255, 255, 255, 0.9)", ct(e2, h, d, n, l2), e2.fill(), e2.restore();
446 459 }
447 460 }
448 461 var Mt = { bars: V, bar: V, mirror: Pt, line: Tt, blocks: ut, block: ut, dots: dt, dot: dt, seekbar: At };
449 -function ft(e3, t2, i2, s2, r2) {
450 - (Mt[r2.waveformStyle] || V)(e3, t2, i2, s2, r2);
462 +function ft(e2, t, i, s, r) {
463 + (Mt[r.waveformStyle] || V)(e2, t, i, s, r);
451 464 }
452 -function mt(e3) {
465 +function mt(e2) {
453 466 try {
454 - let t2 = e3.getChannelData(0), i2 = e3.sampleRate, s2 = Ct(t2, i2);
455 - if (s2.length < 2) return 120;
456 - let r2 = [];
457 - for (let l2 = 1; l2 < s2.length; l2++) r2.push((s2[l2] - s2[l2 - 1]) / i2);
458 - let a2 = {};
459 - r2.forEach((l2) => {
460 - let h2 = 60 / l2, c2 = Math.round(h2 / 3) * 3;
461 - c2 > 60 && c2 < 200 && (a2[c2] = (a2[c2] || 0) + 1);
467 + let t = e2.getChannelData(0), i = e2.sampleRate, s = Ct(t, i);
468 + if (s.length < 2) return 120;
469 + let r = [];
470 + for (let l2 = 1; l2 < s.length; l2++) r.push((s[l2] - s[l2 - 1]) / i);
471 + let a = {};
472 + r.forEach((l2) => {
473 + let h = 60 / l2, c2 = Math.round(h / 3) * 3;
474 + c2 > 60 && c2 < 200 && (a[c2] = (a[c2] || 0) + 1);
462 475 });
463 - let o2 = 0, n2 = 120;
464 - for (let [l2, h2] of Object.entries(a2)) h2 > o2 && (o2 = h2, n2 = parseInt(l2));
465 - return n2 < 70 && a2[n2 * 2] ? n2 *= 2 : n2 > 160 && a2[Math.round(n2 / 2)] && (n2 = Math.round(n2 / 2)), n2 - 1;
466 - } catch (t2) {
467 - return console.warn("[WaveformPlayer] BPM detection failed:", t2), null;
476 + let o = 0, n = 120;
477 + for (let [l2, h] of Object.entries(a)) h > o && (o = h, n = parseInt(l2));
478 + return n < 70 && a[n * 2] ? n *= 2 : n > 160 && a[Math.round(n / 2)] && (n = Math.round(n / 2)), n - 1;
479 + } catch (t) {
480 + return console.warn("[WaveformPlayer] BPM detection failed:", t), null;
468 481 }
469 482 }
470 -function Ct(e3, t2) {
471 - let r2 = [], a2 = 0;
472 - for (let o2 = 0; o2 < e3.length - 2048; o2 += 1024) {
473 - let n2 = 0;
474 - for (let c2 = o2; c2 < o2 + 2048; c2++) n2 += e3[c2] * e3[c2];
475 - n2 = n2 / 2048;
476 - let l2 = n2 - a2, h2 = a2 * 1.8 + 0.01;
477 - if (l2 > h2 && n2 > 0.01) {
478 - let c2 = r2[r2.length - 1] || 0, d2 = t2 * 0.15;
479 - o2 - c2 > d2 && r2.push(o2);
483 +function Ct(e2, t) {
484 + let r = [], a = 0;
485 + for (let o = 0; o < e2.length - 2048; o += 1024) {
486 + let n = 0;
487 + for (let c2 = o; c2 < o + 2048; c2++) n += e2[c2] * e2[c2];
488 + n = n / 2048;
489 + let l2 = n - a, h = a * 1.8 + 0.01;
490 + if (l2 > h && n > 0.01) {
491 + let c2 = r[r.length - 1] || 0, d = t * 0.15;
492 + o - c2 > d && r.push(o);
480 493 }
481 - a2 = n2 * 0.8 + a2 * 0.2;
494 + a = n * 0.8 + a * 0.2;
482 495 }
483 - return r2;
496 + return r;
484 497 }
485 -function Lt(e3, t2 = 1800) {
486 - let i2 = e3.length / t2, s2 = e3.numberOfChannels, r2 = [];
487 - for (let o2 = 0; o2 < s2; o2++) {
488 - let n2 = e3.getChannelData(o2);
489 - for (let l2 = 0; l2 < t2; l2++) {
490 - let h2 = ~~(l2 * i2), c2 = ~~(h2 + i2), d2 = 0, b2 = 0;
491 - for (let w2 = h2; w2 < c2; w2++) {
492 - let f2 = n2[w2];
493 - f2 > b2 && (b2 = f2), f2 < d2 && (d2 = f2);
498 +function Lt(e2, t = 1800) {
499 + let i = e2.length / t, s = e2.numberOfChannels, r = [];
500 + for (let o = 0; o < s; o++) {
501 + let n = e2.getChannelData(o);
502 + for (let l2 = 0; l2 < t; l2++) {
503 + let h = ~~(l2 * i), c2 = ~~(h + i), d = 0, b = 0;
504 + for (let w2 = h; w2 < c2; w2++) {
505 + let f = n[w2];
506 + f > b && (b = f), f < d && (d = f);
494 507 }
495 - let y2 = Math.max(Math.abs(b2), Math.abs(d2));
496 - (o2 === 0 || y2 > r2[l2]) && (r2[l2] = y2);
508 + let y2 = Math.max(Math.abs(b), Math.abs(d));
509 + (o === 0 || y2 > r[l2]) && (r[l2] = y2);
497 510 }
498 511 }
499 - let a2 = $2(r2);
500 - return a2 > 0 ? r2.map((o2) => o2 / a2) : r2;
512 + let a = $2(r);
513 + return a > 0 ? r.map((o) => o / a) : r;
501 514 }
502 -async function G(e3, t2 = 1800, i2 = false) {
503 - let s2;
515 +async function G(e2, t = 1800, i = false) {
516 + let s;
504 517 try {
505 - let r2 = window.AudioContext || window.webkitAudioContext;
506 - s2 = new r2();
507 - let o2 = await (await fetch(e3)).arrayBuffer(), n2 = await s2.decodeAudioData(o2), l2 = Lt(n2, t2);
518 + let r = window.AudioContext || window.webkitAudioContext;
519 + s = new r();
520 + let o = await (await fetch(e2)).arrayBuffer(), n = await s.decodeAudioData(o), l2 = Lt(n, t);
508 521 l2 = _t(l2);
509 - let h2 = null;
510 - return i2 && (h2 = mt(n2)), { peaks: l2, bpm: h2 };
522 + let h = null;
523 + return i && (h = mt(n)), { peaks: l2, bpm: h };
511 524 } finally {
512 - s2 && s2.close();
525 + s && s.close();
513 526 }
514 527 }
515 -function yt(e3 = 1800) {
516 - let t2 = [];
517 - for (let i2 = 0; i2 < e3; i2++) {
518 - let s2 = Math.random() * 0.5 + 0.3, r2 = Math.sin(i2 / e3 * Math.PI * 4) * 0.2;
519 - t2.push(m2(s2 + r2, 0.1, 1));
528 +function yt(e2 = 1800) {
529 + let t = [];
530 + for (let i = 0; i < e2; i++) {
531 + let s = Math.random() * 0.5 + 0.3, r = Math.sin(i / e2 * Math.PI * 4) * 0.2;
532 + t.push(m2(s + r, 0.1, 1));
520 533 }
521 - return t2;
534 + return t;
522 535 }
523 -function _t(e3, t2 = 0.95) {
524 - let i2 = $2(e3);
525 - if (i2 === 0 || i2 > t2) return e3;
526 - let s2 = t2 / i2;
527 - return e3.map((r2) => r2 * s2);
536 +function _t(e2, t = 0.95) {
537 + let i = $2(e2);
538 + if (i === 0 || i > t) return e2;
539 + let s = t / i;
540 + return e2.map((r) => r * s);
528 541 }
529 542 var K = 128;
530 -function gt(e3) {
531 - let t2 = document.documentElement, i2 = document.body;
532 - return t2.classList.contains(e3) || t2.classList.contains(`${e3}-mode`) || t2.classList.contains(`theme-${e3}`) || t2.getAttribute("data-theme") === e3 || t2.getAttribute("data-color-scheme") === e3 || i2.classList.contains(e3) || i2.classList.contains(`${e3}-mode`) || i2.getAttribute("data-theme") === e3;
543 +function gt(e2) {
544 + let t = document.documentElement, i = document.body;
545 + return t.classList.contains(e2) || t.classList.contains(`${e2}-mode`) || t.classList.contains(`theme-${e2}`) || t.getAttribute("data-theme") === e2 || t.getAttribute("data-color-scheme") === e2 || i.classList.contains(e2) || i.classList.contains(`${e2}-mode`) || i.getAttribute("data-theme") === e2;
533 546 }
534 -function xt(e3) {
535 - let t2 = 0, i2 = 0;
536 - for (let s2 = e3; s2 && s2.nodeType === 1 && i2 < 0.995; s2 = s2.parentElement) {
537 - let r2 = U(getComputedStyle(s2).backgroundColor);
538 - if (!r2 || r2.a <= 0) continue;
539 - let a2 = r2.a * (1 - i2);
540 - t2 += (r2.r * 299 + r2.g * 587 + r2.b * 114) / 1e3 * a2, i2 += a2;
547 +function xt(e2) {
548 + let t = 0, i = 0;
549 + for (let s = e2; s && s.nodeType === 1 && i < 0.995; s = s.parentElement) {
550 + let r = U(getComputedStyle(s).backgroundColor);
551 + if (!r || r.a <= 0) continue;
552 + let a = r.a * (1 - i);
553 + t += (r.r * 299 + r.g * 587 + r.b * 114) / 1e3 * a, i += a;
541 554 }
542 - return { sum: t2, alpha: i2 };
555 + return { sum: t, alpha: i };
543 556 }
544 557 function Rt() {
545 - let e3 = lt(getComputedStyle(document.body).color);
546 - if (e3 !== null) return e3 > K ? "dark" : "light";
558 + let e2 = lt(getComputedStyle(document.body).color);
559 + if (e2 !== null) return e2 > K ? "dark" : "light";
547 560 if (window.matchMedia) {
548 561 if (window.matchMedia("(prefers-color-scheme: dark)").matches) return "dark";
549 562 if (window.matchMedia("(prefers-color-scheme: light)").matches) return "light";
550 563 }
@@ -549,23 +562,23 @@
549 562 if (window.matchMedia("(prefers-color-scheme: light)").matches) return "light";
550 563 }
551 564 return "dark";
552 565 }
553 -function R(e3) {
566 +function R2(e2) {
554 567 if (gt("dark")) return "dark";
555 568 if (gt("light")) return "light";
556 569 try {
557 - let t2 = e3 && e3.nodeType === 1 ? e3 : document.body, { sum: i2, alpha: s2 } = xt(t2), r2 = Rt(), a2 = i2 + (r2 === "dark" ? 0 : 255) * (1 - s2);
558 - return a2 > K ? "light" : a2 < K ? "dark" : r2;
570 + let t = e2 && e2.nodeType === 1 ? e2 : document.body, { sum: i, alpha: s } = xt(t), r = Rt(), a = i + (r === "dark" ? 0 : 255) * (1 - s);
571 + return a > K ? "light" : a < K ? "dark" : r;
559 572 } catch {
560 573 return "dark";
561 574 }
562 575 }
563 576 var C = { dark: { waveformColor: "rgba(255, 255, 255, 0.3)", progressColor: "rgba(255, 255, 255, 0.9)" }, light: { waveformColor: "rgba(0, 0, 0, 0.2)", progressColor: "rgba(0, 0, 0, 0.8)" } };
564 -function J(e3, t2) {
565 - if (e3 && C[e3]) return C[e3];
566 - let i2 = R(t2);
567 - return C[i2];
577 +function J(e2, t) {
578 + if (e2 && C[e2]) return C[e2];
579 + let i = R2(t);
580 + return C[i];
568 581 }
569 582 var W = { url: "", height: 64, samples: 1800, preload: "metadata", crossOrigin: null, audioMode: "self", playbackRate: 1, showPlaybackSpeed: false, playbackRates: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2], buttonAlign: "auto", layout: "default", buttonStyle: "circle", buttonSize: null, buttonRadius: null, waveformStyle: "mirror", barWidth: 2, barSpacing: 0, barRadius: 1, waveformGradient: "vertical", colorPreset: null, waveformColor: null, progressColor: null, autoplay: false, showControls: true, showInfo: true, showTime: true, showHoverTime: false, seekHandle: false, showBPM: false, bpm: null, singlePlay: true, playOnSeek: true, enableMediaSession: true, markers: [], showMarkers: true, accessibleSeek: true, seekLabel: null, seekValueText: null, title: null, artist: null, artwork: null, artworkPosition: "info", album: "", errorText: "Unable to load audio", playPauseLabel: "Play/Pause", speedLabel: "Playback speed", artworkAlt: "Album artwork", unknownTrackText: "Unknown Track", playIcon: '<svg viewBox="0 0 24 24" width="16" height="16"><path d="M8 5v14l11-7z"/></svg>', pauseIcon: '<svg viewBox="0 0 24 24" width="16" height="16"><path d="M6 4h4v16H6zM14 4h4v16h-4z"/></svg>', onLoad: null, onPlay: null, onPause: null, onEnd: null, onError: null, onTimeUpdate: null, onNextTrack: null, onPreviousTrack: null };
570 583 var X = { bars: { barWidth: 3, barSpacing: 1 }, mirror: { barWidth: 2, barSpacing: 2 }, line: { barWidth: 2, barSpacing: 0 }, blocks: { barWidth: 4, barSpacing: 2 }, dots: { barWidth: 3, barSpacing: 3 }, seekbar: { barWidth: 1, barSpacing: 0 } };
571 584 var Q = ["auto", "top", "center", "bottom"];
@@ -574,78 +587,78 @@
574 587 var Dt = { buttonAlign: Q, layout: ["default", "preview"], buttonStyle: ["circle", "minimal"], artworkPosition: ["info", "button"], waveformStyle: Object.keys(X), waveformGradient: ["vertical", "horizontal", "diagonal"], audioMode: ["self", "external"], preload: ["none", "metadata", "auto"], colorPreset: Object.keys(C), crossOrigin: ["anonymous", "use-credentials"] };
575 588 var Bt = { height: { min: 1, integer: true }, samples: { min: 1, integer: true }, barWidth: { min: 0 }, barSpacing: { min: 0 }, barRadius: { min: 0 }, bpm: { min: 1 }, playbackRate: { min: N2, max: F } };
576 589 var Ht = ["autoplay", "showControls", "showInfo", "showTime", "showHoverTime", "seekHandle", "showBPM", "singlePlay", "playOnSeek", "enableMediaSession", "showMarkers", "accessibleSeek", "showPlaybackSpeed"];
577 590 var Ot = ["onLoad", "onPlay", "onPause", "onEnd", "onError", "onTimeUpdate", "onNextTrack", "onPreviousTrack"];
578 -function Y(e3, t2) {
579 - console.warn(`[WaveformPlayer] Invalid ${e3} option, using default:`, t2);
591 +function Y(e2, t) {
592 + console.warn(`[WaveformPlayer] Invalid ${e2} option, using default:`, t);
580 593 }
581 -function z(e3) {
582 - let t2 = H2(e3);
583 - return t2 ? t2.reduce((i2, s2) => {
584 - let r2 = s2 && typeof s2 == "object" ? _(s2.time, null, { min: 0 }) : null;
585 - return r2 === null ? (Y("marker", s2), i2) : (i2.push({ ...s2, time: r2, label: s2.label == null ? "" : s2.label }), i2);
586 - }, []) : (e3 != null && Y("markers", e3), []);
594 +function z(e2) {
595 + let t = H2(e2);
596 + return t ? t.reduce((i, s) => {
597 + let r = s && typeof s == "object" ? _(s.time, null, { min: 0 }) : null;
598 + return r === null ? (Y("marker", s), i) : (i.push({ ...s, time: r, label: s.label == null ? "" : s.label }), i);
599 + }, []) : (e2 != null && Y("markers", e2), []);
587 600 }
588 -function Z(e3) {
589 - let t2 = (s2) => e3[s2] != null, i2 = (s2) => {
590 - Y(s2, e3[s2]), e3[s2] = W[s2];
601 +function Z(e2) {
602 + let t = (s) => e2[s] != null, i = (s) => {
603 + Y(s, e2[s]), e2[s] = W[s];
591 604 };
592 - for (let [s2, r2] of Object.entries(Bt)) {
593 - if (!t2(s2)) continue;
594 - let a2 = _(e3[s2], null, r2);
595 - a2 === null ? i2(s2) : e3[s2] = a2;
605 + for (let [s, r] of Object.entries(Bt)) {
606 + if (!t(s)) continue;
607 + let a = _(e2[s], null, r);
608 + a === null ? i(s) : e2[s] = a;
596 609 }
597 - for (let [s2, r2] of Object.entries(Dt)) t2(s2) && rt(e3[s2], r2) === null && i2(s2);
598 - for (let s2 of Ht) e3[s2] = at(e3[s2]);
599 - for (let s2 of Ot) t2(s2) && typeof e3[s2] != "function" && i2(s2);
600 - if (t2("playbackRates")) {
601 - let s2 = D(e3.playbackRates, { min: N2, max: F, fallback: null });
602 - s2 === null ? i2("playbackRates") : e3.playbackRates = s2;
610 + for (let [s, r] of Object.entries(Dt)) t(s) && rt(e2[s], r) === null && i(s);
611 + for (let s of Ht) e2[s] = at(e2[s]);
612 + for (let s of Ot) t(s) && typeof e2[s] != "function" && i(s);
613 + if (t("playbackRates")) {
614 + let s = D(e2.playbackRates, { min: N2, max: F, fallback: null });
615 + s === null ? i("playbackRates") : e2.playbackRates = s;
603 616 }
604 - e3.markers = z(e3.markers);
605 - for (let s2 of ["buttonSize", "buttonRadius"]) {
606 - if (!t2(s2)) continue;
607 - let r2 = e3[s2];
608 - (typeof r2 == "number" ? Number.isFinite(r2) : typeof r2 == "string" && r2.trim() !== "") || i2(s2);
617 + e2.markers = z(e2.markers);
618 + for (let s of ["buttonSize", "buttonRadius"]) {
619 + if (!t(s)) continue;
620 + let r = e2[s];
621 + (typeof r == "number" ? Number.isFinite(r) : typeof r == "string" && r.trim() !== "") || i(s);
609 622 }
610 - for (let s2 of ["waveformColor", "progressColor"]) {
611 - if (!t2(s2)) continue;
612 - let r2 = e3[s2];
613 - !(typeof r2 == "string" && r2.trim() !== "") && !Array.isArray(r2) && i2(s2);
623 + for (let s of ["waveformColor", "progressColor"]) {
624 + if (!t(s)) continue;
625 + let r = e2[s];
626 + !(typeof r == "string" && r.trim() !== "") && !Array.isArray(r) && i(s);
614 627 }
615 - return e3;
628 + return e2;
616 629 }
617 630 var It = "data:image/svg+xml," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect width="24" height="24" rx="4" fill="#71717a" fill-opacity="0.15"/><g fill="none" stroke="#a1a1aa" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="17" r="2.2"/><circle cx="17" cy="15" r="2.2"/><path d="M10.2 17V7l9-1.6v9"/></g></svg>');
618 631 var bt = 5;
619 632 var wt = 10;
620 633 var Wt = 'button, a[href], input, [role="slider"]';
621 -var T = class e2 {
634 +var T = class e {
622 635 static instances = /* @__PURE__ */ new Map();
623 636 static currentlyPlaying = null;
624 - constructor(t2, i2 = {}) {
625 - if (this.container = typeof t2 == "string" ? document.querySelector(t2) : t2, !this.container) throw new Error("[WaveformPlayer] Container element not found");
626 - let s2 = O(this.container), r2 = { ...i2 };
627 - r2.style && !r2.waveformStyle && (r2.waveformStyle = r2.style), r2.src && !r2.url && (r2.url = r2.src), this.options = Z(j2(W, s2, r2));
628 - let a2 = J(this.options.colorPreset, this.container);
629 - this._autoTheme = this.options.colorPreset == null || !C[this.options.colorPreset], this._presetKeys = [], this._scheme = this.options.colorPreset && C[this.options.colorPreset] ? this.options.colorPreset : R(this.container);
630 - for (let [n2, l2] of Object.entries(a2)) (this.options[n2] === null || this.options[n2] === void 0) && (this.options[n2] = l2, this._presetKeys.push(n2));
631 - let o2 = X[this.options.waveformStyle];
632 - o2 && (s2.barWidth === void 0 && i2.barWidth === void 0 && (this.options.barWidth = o2.barWidth), s2.barSpacing === void 0 && i2.barSpacing === void 0 && (this.options.barSpacing = o2.barSpacing)), this.audio = null, this.canvas = null, this.ctx = null, this.waveformData = [], this.progress = 0, this._activeMarkerIndex = -1, this._markerLabelTimer = null, this.isPlaying = false, this.isLoading = false, this.hasError = false, this.updateTimer = null, this.resizeObserver = null, this._ac = new AbortController(), this.id = this.container.id || nt(this.options.url), e2.instances.set(this.id, this), e2._watchTheme();
637 + constructor(t, i = {}) {
638 + if (this.container = typeof t == "string" ? document.querySelector(t) : t, !this.container) throw new Error("[WaveformPlayer] Container element not found");
639 + let s = O(this.container), r = { ...i };
640 + r.style && !r.waveformStyle && (r.waveformStyle = r.style), r.src && !r.url && (r.url = r.src), this.options = Z(j2(W, s, r));
641 + let a = J(this.options.colorPreset, this.container);
642 + this._autoTheme = this.options.colorPreset == null || !C[this.options.colorPreset], this._presetKeys = [], this._scheme = this.options.colorPreset && C[this.options.colorPreset] ? this.options.colorPreset : R2(this.container);
643 + for (let [n, l2] of Object.entries(a)) (this.options[n] === null || this.options[n] === void 0) && (this.options[n] = l2, this._presetKeys.push(n));
644 + let o = X[this.options.waveformStyle];
645 + o && (s.barWidth === void 0 && i.barWidth === void 0 && (this.options.barWidth = o.barWidth), s.barSpacing === void 0 && i.barSpacing === void 0 && (this.options.barSpacing = o.barSpacing)), this.audio = null, this.canvas = null, this.ctx = null, this.waveformData = [], this.progress = 0, this._activeMarkerIndex = -1, this._markerLabelTimer = null, this.isPlaying = false, this.isLoading = false, this.hasError = false, this.updateTimer = null, this.resizeObserver = null, this._ac = new AbortController(), this.id = this.container.id || nt(this.options.url), e.instances.set(this.id, this), e._watchTheme();
633 646 try {
634 647 this.init();
635 - } catch (n2) {
636 - throw e2.instances.delete(this.id), this._ac.abort(), n2;
648 + } catch (n) {
649 + throw e.instances.delete(this.id), this._ac.abort(), n;
637 650 }
638 651 setTimeout(() => {
639 652 this._emit("waveformplayer:ready", { player: this, url: this.options.url });
640 653 }, 100);
641 654 }
642 - _emit(t2, i2, s2 = false) {
643 - let r2 = new CustomEvent(t2, { bubbles: true, cancelable: s2, detail: i2 });
644 - return this.container.dispatchEvent(r2), r2;
655 + _emit(t, i, s = false) {
656 + let r = new CustomEvent(t, { bubbles: true, cancelable: s, detail: i });
657 + return this.container.dispatchEvent(r), r;
645 658 }
646 - _requestSeek(t2) {
647 - this._emit("waveformplayer:request-seek", { ...this._buildTrackDetail(), percent: t2 }, true).defaultPrevented || (this.progress = t2, this.drawWaveform?.());
659 + _requestSeek(t) {
660 + this._emit("waveformplayer:request-seek", { ...this._buildTrackDetail(), percent: t }, true).defaultPrevented || (this.progress = t, this.drawWaveform?.());
648 661 }
649 662 init() {
650 663 this.createDOM(), this.createAudio(), this.initPlaybackSpeed(), this.initKeyboardControls(), this.initSeekControl(), this.bindEvents(), this.setupResizeObserver(), requestAnimationFrame(() => {
651 664 this.resizeCanvas(), this.options.url && this.load(this.options.url).then(() => {
@@ -650,22 +663,22 @@
650 663 this.createDOM(), this.createAudio(), this.initPlaybackSpeed(), this.initKeyboardControls(), this.initSeekControl(), this.bindEvents(), this.setupResizeObserver(), requestAnimationFrame(() => {
651 664 this.resizeCanvas(), this.options.url && this.load(this.options.url).then(() => {
652 665 this.options.autoplay && this.play()?.catch(() => {
653 666 });
654 - }).catch((t2) => {
655 - console.error("[WaveformPlayer] Failed to load audio:", t2);
667 + }).catch((t) => {
668 + console.error("[WaveformPlayer] Failed to load audio:", t);
656 669 });
657 670 });
658 671 }
659 672 createDOM() {
660 673 this.container.innerHTML = "", this.container.className = "waveform-player";
661 - let t2 = Q.includes(this.options.buttonAlign) ? this.options.buttonAlign : "auto";
662 - t2 === "auto" && (this.options.waveformStyle === "bars" ? t2 = "bottom" : t2 = "center"), this.options.layout === "preview" && this.container.classList.add("waveform-layout-preview"), this.container.classList.toggle("waveform-theme-light", this._scheme === "light");
663 - let s2 = [];
664 - this.options.buttonSize != null && s2.push(`--wfp-btn-size: ${q(this.options.buttonSize)}`), this.options.buttonRadius != null && s2.push(`--wfp-btn-radius: ${q(this.options.buttonRadius)}`);
665 - let r2 = s2.length ? ` style="${s2.join("; ")};"` : "", a2 = this.options.artworkPosition === "button" && this.options.artwork, o2 = a2 ? `<img class="waveform-btn-artwork" src="${S(this.options.artwork)}" alt="" aria-hidden="true">` : "", n2 = this.options.showControls ? `
666 - <button class="waveform-btn${this.options.buttonStyle === "minimal" ? " waveform-btn-minimal" : ""}${a2 ? " waveform-btn-has-artwork" : ""}" aria-label="${S(this.options.playPauseLabel)}"${r2}>
667 - ${o2}
674 + let t = Q.includes(this.options.buttonAlign) ? this.options.buttonAlign : "auto";
675 + t === "auto" && (this.options.waveformStyle === "bars" ? t = "bottom" : t = "center"), this.options.layout === "preview" && this.container.classList.add("waveform-layout-preview"), this.container.classList.toggle("waveform-theme-light", this._scheme === "light");
676 + let s = [];
677 + this.options.buttonSize != null && s.push(`--wfp-btn-size: ${q2(this.options.buttonSize)}`), this.options.buttonRadius != null && s.push(`--wfp-btn-radius: ${q2(this.options.buttonRadius)}`);
678 + let r = s.length ? ` style="${s.join("; ")};"` : "", a = this.options.artworkPosition === "button" && this.options.artwork, o = a ? `<img class="waveform-btn-artwork" src="${S(this.options.artwork)}" alt="" aria-hidden="true">` : "", n = this.options.showControls ? `
679 + <button class="waveform-btn${this.options.buttonStyle === "minimal" ? " waveform-btn-minimal" : ""}${a ? " waveform-btn-has-artwork" : ""}" aria-label="${S(this.options.playPauseLabel)}"${r}>
680 + ${o}
668 681 <span class="waveform-icon-play">${this.options.playIcon}</span>
669 682 <span class="waveform-icon-pause" style="display:none;">${this.options.pauseIcon}</span>
670 683 </button>
671 684 ` : "", l2 = this.options.showInfo ? `
@@ -694,9 +707,9 @@
694 707 <button class="speed-btn" aria-label="${S(this.options.speedLabel)}" aria-haspopup="menu" aria-expanded="false">
695 708 <span class="speed-value">1x</span>
696 709 </button>
697 710 <div class="speed-menu" role="menu" aria-label="${S(this.options.speedLabel)}" style="display: none;">
698 - ${this.options.playbackRates.map((h2) => `<button class="speed-option" role="menuitemradio" tabindex="-1" aria-checked="false" data-rate="${h2}">${h2}x</button>`).join("")}
711 + ${this.options.playbackRates.map((h) => `<button class="speed-option" role="menuitemradio" tabindex="-1" aria-checked="false" data-rate="${h}">${h}x</button>`).join("")}
699 712 </div>
700 713 </div>
701 714 ` : ""}
702 715 ${this.options.showTime ? `
@@ -709,10 +722,10 @@
709 722 ` : "";
710 723 this.container.innerHTML = `
711 724 <div class="waveform-player-inner">
712 725 <div class="waveform-body">
713 - <div class="waveform-track waveform-align-${t2}">
714 - ${n2}
726 + <div class="waveform-track waveform-align-${t}">
727 + ${n}
715 728
716 729 <div class="waveform-container">
717 730 <canvas></canvas>
718 731 <div class="waveform-markers"></div>
@@ -727,64 +740,64 @@
727 740 </div>
728 741 </div>
729 742 `, this.playBtn = this.container.querySelector(".waveform-btn"), this.canvas = this.container.querySelector("canvas"), this.ctx = this.canvas.getContext("2d"), this.titleEl = this.container.querySelector(".waveform-title"), this.artistEl = this.container.querySelector(".waveform-artist"), this.artworkEl = this.container.querySelector(".waveform-artwork, .waveform-btn-artwork"), this.bindArtworkFallback(this.artworkEl), this.currentTimeEl = this.container.querySelector(".time-current"), this.totalTimeEl = this.container.querySelector(".time-total"), this.bpmEl = this.container.querySelector(".waveform-bpm"), this.bpmValueEl = this.container.querySelector(".bpm-value"), this.loadingEl = this.container.querySelector(".waveform-loading"), this.errorEl = this.container.querySelector(".waveform-error"), this.markersContainer = this.container.querySelector(".waveform-markers"), this.speedBtn = this.container.querySelector(".speed-btn"), this.speedMenu = this.container.querySelector(".speed-menu"), this.resizeCanvas(), this.updateBPMDisplay();
730 743 }
731 - bindArtworkFallback(t2) {
732 - t2 && t2.addEventListener("error", () => {
733 - t2.src.startsWith("data:") || (t2.src = It);
744 + bindArtworkFallback(t) {
745 + t && t.addEventListener("error", () => {
746 + t.src.startsWith("data:") || (t.src = It);
734 747 }, { signal: this._ac.signal });
735 748 }
736 749 createArtworkElement() {
737 - let t2 = document.createElement("img");
738 - return t2.className = "waveform-artwork", t2.style.width = "40px", t2.style.height = "40px", t2.style.borderRadius = "4px", t2.style.objectFit = "cover", t2.style.flexShrink = "0", this.bindArtworkFallback(t2), t2;
750 + let t = document.createElement("img");
751 + return t.className = "waveform-artwork", t.style.width = "40px", t.style.height = "40px", t.style.borderRadius = "4px", t.style.objectFit = "cover", t.style.flexShrink = "0", this.bindArtworkFallback(t), t;
739 752 }
740 753 createButtonArtworkElement() {
741 - let t2 = document.createElement("img");
742 - return t2.className = "waveform-btn-artwork", t2.alt = "", t2.setAttribute("aria-hidden", "true"), this.bindArtworkFallback(t2), t2;
754 + let t = document.createElement("img");
755 + return t.className = "waveform-btn-artwork", t.alt = "", t.setAttribute("aria-hidden", "true"), this.bindArtworkFallback(t), t;
743 756 }
744 757 createArtistElement() {
745 - let t2 = document.createElement("span");
746 - return t2.className = "waveform-artist", t2;
758 + let t = document.createElement("span");
759 + return t.className = "waveform-artist", t;
747 760 }
748 - syncArtist(t2) {
749 - if (this.options.artist = t2 || null, !!this.options.showInfo) {
750 - if (!t2) {
761 + syncArtist(t) {
762 + if (this.options.artist = t || null, !!this.options.showInfo) {
763 + if (!t) {
751 764 this.artistEl?.remove(), this.artistEl = null;
752 765 return;
753 766 }
754 767 if (!this.artistEl) {
755 - let i2 = this.container.querySelector(".waveform-title");
756 - if (!i2) return;
757 - this.artistEl = this.createArtistElement(), i2.after(this.artistEl);
768 + let i = this.container.querySelector(".waveform-title");
769 + if (!i) return;
770 + this.artistEl = this.createArtistElement(), i.after(this.artistEl);
758 771 }
759 - this.artistEl.textContent = t2, this.artistEl.style.display = "";
772 + this.artistEl.textContent = t, this.artistEl.style.display = "";
760 773 }
761 774 }
762 - syncButtonArtwork(t2) {
775 + syncButtonArtwork(t) {
763 776 if (this.playBtn) {
764 - if (!t2) {
777 + if (!t) {
765 778 this.artworkEl?.remove(), this.artworkEl = null, this.playBtn.classList.remove("waveform-btn-has-artwork");
766 779 return;
767 780 }
768 - this.artworkEl || (this.artworkEl = this.createButtonArtworkElement(), this.playBtn.prepend(this.artworkEl)), this.artworkEl.src = t2, this.playBtn.classList.add("waveform-btn-has-artwork");
781 + this.artworkEl || (this.artworkEl = this.createButtonArtworkElement(), this.playBtn.prepend(this.artworkEl)), this.artworkEl.src = t, this.playBtn.classList.add("waveform-btn-has-artwork");
769 782 }
770 783 }
771 - syncArtwork(t2, i2 = "") {
772 - if (this.options.artwork = t2 || null, this.options.artworkAlt = i2 || "", this.options.artworkPosition === "button") {
784 + syncArtwork(t, i = "") {
785 + if (this.options.artwork = t || null, this.options.artworkAlt = i || "", this.options.artworkPosition === "button") {
773 786 this.syncButtonArtwork(this.options.artwork);
774 787 return;
775 788 }
776 789 if (this.options.showInfo) {
777 - if (!t2) {
790 + if (!t) {
778 791 this.artworkEl?.remove(), this.artworkEl = null;
779 792 return;
780 793 }
781 794 if (!this.artworkEl) {
782 - let s2 = this.container.querySelector(".waveform-text");
783 - if (!s2) return;
784 - this.artworkEl = this.createArtworkElement(), s2.before(this.artworkEl);
795 + let s = this.container.querySelector(".waveform-text");
796 + if (!s) return;
797 + this.artworkEl = this.createArtworkElement(), s.before(this.artworkEl);
785 798 }
786 - this.artworkEl.src = t2, this.artworkEl.alt = i2 || "";
799 + this.artworkEl.src = t, this.artworkEl.alt = i || "";
787 800 }
788 801 }
789 802 createAudio() {
790 803 if (this.options.audioMode === "external") {
@@ -796,105 +809,105 @@
796 809 initPlaybackSpeed() {
797 810 this.audio && this.options.playbackRate && this.options.playbackRate !== 1 && (this.audio.playbackRate = this.options.playbackRate), this.options.showPlaybackSpeed && this.initSpeedControls();
798 811 }
799 812 initSpeedControls() {
800 - let t2 = this.container.querySelector(".speed-btn"), i2 = this.container.querySelector(".speed-menu");
801 - if (!t2 || !i2) return;
802 - let s2 = () => Array.from(i2.querySelectorAll(".speed-option")), r2 = () => i2.style.display !== "none", a2 = (l2) => {
803 - if (i2.style.display = l2 ? "block" : "none", t2.setAttribute("aria-expanded", l2 ? "true" : "false"), l2) {
804 - let h2 = s2();
805 - (h2.find((c2) => c2.getAttribute("aria-checked") === "true") || h2[0])?.focus();
813 + let t = this.container.querySelector(".speed-btn"), i = this.container.querySelector(".speed-menu");
814 + if (!t || !i) return;
815 + let s = () => Array.from(i.querySelectorAll(".speed-option")), r = () => i.style.display !== "none", a = (l2) => {
816 + if (i.style.display = l2 ? "block" : "none", t.setAttribute("aria-expanded", l2 ? "true" : "false"), l2) {
817 + let h = s();
818 + (h.find((c2) => c2.getAttribute("aria-checked") === "true") || h[0])?.focus();
806 819 }
807 - }, o2 = (l2) => {
808 - let h2 = s2();
809 - h2.length && h2[(l2 + h2.length) % h2.length].focus();
810 - }, n2 = (l2) => {
811 - this.setPlaybackRate(parseFloat(l2.dataset.rate)), a2(false), t2.focus();
820 + }, o = (l2) => {
821 + let h = s();
822 + h.length && h[(l2 + h.length) % h.length].focus();
823 + }, n = (l2) => {
824 + this.setPlaybackRate(parseFloat(l2.dataset.rate)), a(false), t.focus();
812 825 };
813 - t2.addEventListener("click", (l2) => {
814 - l2.stopPropagation(), a2(!r2());
815 - }, { signal: this._ac.signal }), document.addEventListener("click", () => a2(false), { signal: this._ac.signal }), i2.addEventListener("click", (l2) => {
826 + t.addEventListener("click", (l2) => {
827 + l2.stopPropagation(), a(!r());
828 + }, { signal: this._ac.signal }), document.addEventListener("click", () => a(false), { signal: this._ac.signal }), i.addEventListener("click", (l2) => {
816 829 l2.stopPropagation();
817 - let h2 = l2.target.closest(".speed-option");
818 - h2 && n2(h2);
819 - }, { signal: this._ac.signal }), t2.closest(".waveform-speed")?.addEventListener("keydown", (l2) => {
820 - let h2 = s2(), c2 = h2.indexOf(document.activeElement);
821 - if (!r2()) {
822 - (l2.key === "ArrowDown" || l2.key === "ArrowUp") && document.activeElement === t2 && (l2.preventDefault(), a2(true));
830 + let h = l2.target.closest(".speed-option");
831 + h && n(h);
832 + }, { signal: this._ac.signal }), t.closest(".waveform-speed")?.addEventListener("keydown", (l2) => {
833 + let h = s(), c2 = h.indexOf(document.activeElement);
834 + if (!r()) {
835 + (l2.key === "ArrowDown" || l2.key === "ArrowUp") && document.activeElement === t && (l2.preventDefault(), a(true));
823 836 return;
824 837 }
825 838 switch (l2.key) {
826 839 case "ArrowDown":
827 - l2.preventDefault(), o2(c2 < 0 ? 0 : c2 + 1);
840 + l2.preventDefault(), o(c2 < 0 ? 0 : c2 + 1);
828 841 break;
829 842 case "ArrowUp":
830 - l2.preventDefault(), o2(c2 < 0 ? h2.length - 1 : c2 - 1);
843 + l2.preventDefault(), o(c2 < 0 ? h.length - 1 : c2 - 1);
831 844 break;
832 845 case "Home":
833 - l2.preventDefault(), o2(0);
846 + l2.preventDefault(), o(0);
834 847 break;
835 848 case "End":
836 - l2.preventDefault(), o2(h2.length - 1);
849 + l2.preventDefault(), o(h.length - 1);
837 850 break;
838 851 case "Escape":
839 - l2.preventDefault(), a2(false), t2.focus();
852 + l2.preventDefault(), a(false), t.focus();
840 853 break;
841 854 case "Tab":
842 - a2(false);
855 + a(false);
843 856 break;
844 857 }
845 858 }, { signal: this._ac.signal }), this.updateSpeedUI();
846 859 }
847 860 initKeyboardControls() {
848 - this.container.setAttribute("tabindex", "-1"), this.container.addEventListener("click", (t2) => {
849 - t2.target.closest(Wt) || (e2.getAllInstances().forEach((i2) => {
850 - i2 !== this && i2.container.setAttribute("tabindex", "-1");
861 + this.container.setAttribute("tabindex", "-1"), this.container.addEventListener("click", (t) => {
862 + t.target.closest(Wt) || (e.getAllInstances().forEach((i) => {
863 + i !== this && i.container.setAttribute("tabindex", "-1");
851 864 }), this.container.setAttribute("tabindex", "0"), this.container.focus());
852 - }, { signal: this._ac.signal }), this.container.addEventListener("keydown", (t2) => {
865 + }, { signal: this._ac.signal }), this.container.addEventListener("keydown", (t) => {
853 866 if (document.activeElement !== this.container) return;
854 - let i2 = t2.key, s2 = !!this.audio, r2 = s2 ? this.audio.currentTime : 0;
855 - if (s2 && i2 >= "0" && i2 <= "9") {
856 - t2.preventDefault(), this.seekToPercent(parseInt(i2) / 10);
867 + let i = t.key, s = !!this.audio, r = s ? this.audio.currentTime : 0;
868 + if (s && i >= "0" && i <= "9") {
869 + t.preventDefault(), this.seekToPercent(parseInt(i) / 10);
857 870 return;
858 871 }
859 - let a2 = { " ": () => this.togglePlay() };
860 - s2 && (a2.ArrowLeft = () => this.seekTo(m2(r2 - 5, 0, this.audio.duration)), a2.ArrowRight = () => this.seekTo(m2(r2 + 5, 0, this.audio.duration)), a2.ArrowUp = () => this.setVolume(m2(this.audio.volume + 0.1)), a2.ArrowDown = () => this.setVolume(m2(this.audio.volume - 0.1)), a2.m = a2.M = () => this.audio.muted = !this.audio.muted), a2[i2] && (t2.preventDefault(), a2[i2]());
872 + let a = { " ": () => this.togglePlay() };
873 + s && (a.ArrowLeft = () => this.seekTo(m2(r - 5, 0, this.audio.duration)), a.ArrowRight = () => this.seekTo(m2(r + 5, 0, this.audio.duration)), a.ArrowUp = () => this.setVolume(m2(this.audio.volume + 0.1)), a.ArrowDown = () => this.setVolume(m2(this.audio.volume - 0.1)), a.m = a.M = () => this.audio.muted = !this.audio.muted), a[i] && (t.preventDefault(), a[i]());
861 874 }, { signal: this._ac.signal });
862 875 }
863 876 initSeekControl() {
864 - this.options.accessibleSeek && (this.seekEl = this.container.querySelector(".waveform-container"), this.seekEl && (this.seekEl.setAttribute("role", "slider"), this.seekEl.setAttribute("tabindex", "0"), this.seekEl.setAttribute("aria-valuemin", "0"), this.applySeekLabel(), this.updateSeekAccessibility(), this.seekEl.addEventListener("keydown", (t2) => {
865 - if (t2.key === " " || t2.key === "Spacebar") {
866 - t2.preventDefault(), t2.stopPropagation(), this.togglePlay();
877 + this.options.accessibleSeek && (this.seekEl = this.container.querySelector(".waveform-container"), this.seekEl && (this.seekEl.setAttribute("role", "slider"), this.seekEl.setAttribute("tabindex", "0"), this.seekEl.setAttribute("aria-valuemin", "0"), this.applySeekLabel(), this.updateSeekAccessibility(), this.seekEl.addEventListener("keydown", (t) => {
878 + if (t.key === " " || t.key === "Spacebar") {
879 + t.preventDefault(), t.stopPropagation(), this.togglePlay();
867 880 return;
868 881 }
869 - let i2 = this.getSeekDuration();
870 - if (!i2) return;
871 - let s2 = this.getSeekCurrentTime(), r2;
872 - switch (t2.key) {
882 + let i = this.getSeekDuration();
883 + if (!i) return;
884 + let s = this.getSeekCurrentTime(), r;
885 + switch (t.key) {
873 886 case "ArrowLeft":
874 887 case "ArrowDown":
875 - r2 = s2 - bt;
888 + r = s - bt;
876 889 break;
877 890 case "ArrowRight":
878 891 case "ArrowUp":
879 - r2 = s2 + bt;
892 + r = s + bt;
880 893 break;
881 894 case "PageDown":
882 - r2 = s2 - wt;
895 + r = s - wt;
883 896 break;
884 897 case "PageUp":
885 - r2 = s2 + wt;
898 + r = s + wt;
886 899 break;
887 900 case "Home":
888 - r2 = 0;
901 + r = 0;
889 902 break;
890 903 case "End":
891 - r2 = i2;
904 + r = i;
892 905 break;
893 906 default:
894 907 return;
895 908 }
896 - t2.preventDefault(), t2.stopPropagation(), this.seekToSeconds(r2);
909 + t.preventDefault(), t.stopPropagation(), this.seekToSeconds(r);
897 910 }, { signal: this._ac.signal })));
898 911 }
899 912 getSeekDuration() {
900 913 return this.options.audioMode === "external" ? this._extDuration || 0 : this.audio && Number.isFinite(this.audio.duration) ? this.audio.duration : 0;
@@ -901,27 +914,27 @@
901 914 }
902 915 getSeekCurrentTime() {
903 916 return this.options.audioMode === "external" ? this.progress * (this._extDuration || 0) : this.audio && Number.isFinite(this.audio.currentTime) ? this.audio.currentTime : 0;
904 917 }
905 - seekToSeconds(t2) {
906 - let i2 = this.getSeekDuration();
907 - if (!i2) return;
908 - let s2 = m2(t2, 0, i2);
918 + seekToSeconds(t) {
919 + let i = this.getSeekDuration();
920 + if (!i) return;
921 + let s = m2(t, 0, i);
909 922 if (this.options.audioMode === "external") {
910 - this._requestSeek(s2 / i2), this.updateSeekAccessibility();
923 + this._requestSeek(s / i), this.updateSeekAccessibility();
911 924 return;
912 925 }
913 - this.seekTo(s2);
926 + this.seekTo(s);
914 927 }
915 - applySeekLabel(t2 = this.options.title) {
928 + applySeekLabel(t = this.options.title) {
916 929 if (!this.seekEl) return;
917 - let i2 = this.options.seekLabel || t2 || "Seek";
918 - this.seekEl.setAttribute("aria-label", i2);
930 + let i = this.options.seekLabel || t || "Seek";
931 + this.seekEl.setAttribute("aria-label", i);
919 932 }
920 933 updateSeekAccessibility() {
921 934 if (!this.seekEl) return;
922 - let t2 = this.getSeekDuration(), i2 = Math.min(this.getSeekCurrentTime(), t2);
923 - this.seekEl.setAttribute("aria-valuemax", String(Math.round(t2))), this.seekEl.setAttribute("aria-valuenow", String(Math.round(i2))), this.seekEl.setAttribute("aria-valuetext", ot(this.options.seekValueText || "%1$s of %2$s", E(i2), E(t2)));
935 + let t = this.getSeekDuration(), i = Math.min(this.getSeekCurrentTime(), t);
936 + this.seekEl.setAttribute("aria-valuemax", String(Math.round(t))), this.seekEl.setAttribute("aria-valuenow", String(Math.round(i))), this.seekEl.setAttribute("aria-valuetext", ot(this.options.seekValueText || "%1$s of %2$s", E2(i), E2(t)));
924 937 }
925 938 initMediaSession() {
926 939 if (!("mediaSession" in navigator) || !this.options.enableMediaSession || !this.audio) return;
927 940 this._applyMediaMetadata(), navigator.mediaSession.setActionHandler("play", () => this.play()), navigator.mediaSession.setActionHandler("pause", () => this.pause()), navigator.mediaSession.setActionHandler("seekbackward", () => {
@@ -927,18 +940,18 @@
927 940 this._applyMediaMetadata(), navigator.mediaSession.setActionHandler("play", () => this.play()), navigator.mediaSession.setActionHandler("pause", () => this.pause()), navigator.mediaSession.setActionHandler("seekbackward", () => {
928 941 this.seekTo(m2(this.audio.currentTime - 10, 0, this.audio.duration));
929 942 }), navigator.mediaSession.setActionHandler("seekforward", () => {
930 943 this.seekTo(m2(this.audio.currentTime + 10, 0, this.audio.duration));
931 - }), navigator.mediaSession.setActionHandler("seekto", (s2) => {
932 - s2.seekTime !== null && this.seekTo(s2.seekTime);
944 + }), navigator.mediaSession.setActionHandler("seekto", (s) => {
945 + s.seekTime !== null && this.seekTo(s.seekTime);
933 946 });
934 - let t2 = this.options.onNextTrack, i2 = this.options.onPreviousTrack;
947 + let t = this.options.onNextTrack, i = this.options.onPreviousTrack;
935 948 try {
936 - navigator.mediaSession.setActionHandler("nexttrack", typeof t2 == "function" ? () => t2(this) : null);
949 + navigator.mediaSession.setActionHandler("nexttrack", typeof t == "function" ? () => t(this) : null);
937 950 } catch {
938 951 }
939 952 try {
940 - navigator.mediaSession.setActionHandler("previoustrack", typeof i2 == "function" ? () => i2(this) : null);
953 + navigator.mediaSession.setActionHandler("previoustrack", typeof i == "function" ? () => i(this) : null);
941 954 } catch {
942 955 }
943 956 }
944 957 _applyMediaMetadata() {
@@ -943,49 +956,49 @@
943 956 }
944 957 _applyMediaMetadata() {
945 958 !("mediaSession" in navigator) || !this.options.enableMediaSession || (navigator.mediaSession.metadata = new MediaMetadata({ title: this.options.title || this.options.unknownTrackText, artist: this.options.artist || "", album: this.options.album || "", artwork: this.options.artwork ? [{ src: this.options.artwork, sizes: "512x512", type: "image/jpeg" }] : [] }));
946 959 }
947 - _updateMediaSession(t2) {
960 + _updateMediaSession(t) {
948 961 if (!(!("mediaSession" in navigator) || !this.options.enableMediaSession || !this.audio)) try {
949 - t2 === "playing" && this.initMediaSession(), navigator.mediaSession.playbackState = t2;
950 - let i2 = this.audio.duration;
951 - navigator.mediaSession.setPositionState && i2 && isFinite(i2) && navigator.mediaSession.setPositionState({ duration: i2, playbackRate: this.audio.playbackRate || 1, position: m2(this.audio.currentTime, 0, i2) });
962 + t === "playing" && this.initMediaSession(), navigator.mediaSession.playbackState = t;
963 + let i = this.audio.duration;
964 + navigator.mediaSession.setPositionState && i && isFinite(i) && navigator.mediaSession.setPositionState({ duration: i, playbackRate: this.audio.playbackRate || 1, position: m2(this.audio.currentTime, 0, i) });
952 965 } catch {
953 966 }
954 967 }
955 968 bindEvents() {
956 - this.playBtn && this.playBtn.addEventListener("click", () => this.togglePlay()), this.audio && (this.audio.addEventListener("loadstart", () => this.setLoading(true)), this.audio.addEventListener("loadedmetadata", () => this.onMetadataLoaded()), this.audio.addEventListener("canplay", () => this.setLoading(false)), this.audio.addEventListener("play", () => this.onPlay()), this.audio.addEventListener("pause", () => this.onPause()), this.audio.addEventListener("ended", () => this.onEnded()), this.audio.addEventListener("error", (i2) => this.onError(i2))), this.canvas.addEventListener("click", (i2) => this.handleCanvasClick(i2)), this._dragging = false, this._seekHover = false, this._handleNear = false, this.canvas.addEventListener("pointerenter", () => {
969 + this.playBtn && this.playBtn.addEventListener("click", () => this.togglePlay()), this.audio && (this.audio.addEventListener("loadstart", () => this.setLoading(true)), this.audio.addEventListener("loadedmetadata", () => this.onMetadataLoaded()), this.audio.addEventListener("canplay", () => this.setLoading(false)), this.audio.addEventListener("play", () => this.onPlay()), this.audio.addEventListener("pause", () => this.onPause()), this.audio.addEventListener("ended", () => this.onEnded()), this.audio.addEventListener("error", (i) => this.onError(i))), this.canvas.addEventListener("click", (i) => this.handleCanvasClick(i)), this._dragging = false, this._seekHover = false, this._handleNear = false, this.canvas.addEventListener("pointerenter", () => {
957 970 this._seekHover = true, this.drawWaveform(), this._updateSeekHandle();
958 971 }), this.canvas.addEventListener("pointerleave", () => {
959 972 this._seekHover = false, this._handleNear = false, this._dragging || this._hideHoverTip(), this.drawWaveform(), this._updateSeekHandle();
960 - }), this.canvas.addEventListener("pointerdown", (i2) => {
961 - if (!(i2.pointerType === "mouse" && i2.button !== 0)) {
973 + }), this.canvas.addEventListener("pointerdown", (i) => {
974 + if (!(i.pointerType === "mouse" && i.button !== 0)) {
962 975 this._dragging = true;
963 976 try {
964 - this.canvas.setPointerCapture(i2.pointerId);
977 + this.canvas.setPointerCapture(i.pointerId);
965 978 } catch {
966 979 }
967 - this._scrubTo(i2.clientX);
980 + this._scrubTo(i.clientX);
968 981 }
969 - }), this.canvas.addEventListener("pointermove", (i2) => {
982 + }), this.canvas.addEventListener("pointermove", (i) => {
970 983 if (this._dragging) {
971 - this._scrubTo(i2.clientX);
984 + this._scrubTo(i.clientX);
972 985 return;
973 986 }
974 - let s2 = this.canvas.getBoundingClientRect();
975 - s2.width && (this._handleNear = Math.abs(i2.clientX - s2.left - this.progress * s2.width) <= 10, this._updateSeekHandle());
987 + let s = this.canvas.getBoundingClientRect();
988 + s.width && (this._handleNear = Math.abs(i.clientX - s.left - this.progress * s.width) <= 10, this._updateSeekHandle());
976 989 });
977 - let t2 = (i2) => {
990 + let t = (i) => {
978 991 if (this._dragging) {
979 992 this._dragging = false, this._suppressClick = true;
980 993 try {
981 - this.canvas.releasePointerCapture(i2.pointerId);
994 + this.canvas.releasePointerCapture(i.pointerId);
982 995 } catch {
983 996 }
984 - this._seekFromPointer(i2.clientX), !this._seekHover && !this.options.showHoverTime && this._hideHoverTip(), this._updateSeekHandle();
997 + this._seekFromPointer(i.clientX), !this._seekHover && !this.options.showHoverTime && this._hideHoverTip(), this._updateSeekHandle();
985 998 }
986 999 };
987 - this.canvas.addEventListener("pointerup", t2), this.canvas.addEventListener("pointercancel", t2), this.setupHoverTime(), this.setupSeekHandle(), this.resizeHandler = ht(() => this.resizeCanvas(), 100), window.addEventListener("resize", this.resizeHandler);
1000 + this.canvas.addEventListener("pointerup", t), this.canvas.addEventListener("pointercancel", t), this.setupHoverTime(), this.setupSeekHandle(), this.resizeHandler = ht(() => this.resizeCanvas(), 100), window.addEventListener("resize", this.resizeHandler);
988 1001 }
989 1002 setupResizeObserver() {
990 1003 "ResizeObserver" in window && (this.resizeObserver = new ResizeObserver(() => {
991 1004 this.resizeCanvas();
@@ -990,48 +1003,48 @@
990 1003 "ResizeObserver" in window && (this.resizeObserver = new ResizeObserver(() => {
991 1004 this.resizeCanvas();
992 1005 }), this.canvas?.parentElement && this.resizeObserver.observe(this.canvas.parentElement));
993 1006 }
994 - async load(t2) {
1007 + async load(t) {
995 1008 try {
996 1009 this.setLoading(true), this.progress = 0, this.hasError = false, this.container.classList.remove("waveform-is-placeholder");
997 - let i2 = !!this.options.waveform;
998 - i2 && this.setWaveformData(this.options.waveform);
999 - let s2 = this.options.title || I(t2);
1000 - if (this.titleEl && (this.titleEl.textContent = s2), this.applySeekLabel(s2), this.audio && (this.audio.src = t2, this.audio.preload !== "none" && await new Promise((r2, a2) => {
1001 - let o2 = () => {
1002 - this.audio.removeEventListener("loadedmetadata", o2), this.audio.removeEventListener("error", n2), r2();
1003 - }, n2 = (l2) => {
1004 - this.audio.removeEventListener("loadedmetadata", o2), this.audio.removeEventListener("error", n2), a2(l2);
1010 + let i = !!this.options.waveform;
1011 + i && this.setWaveformData(this.options.waveform);
1012 + let s = this.options.title || I(t);
1013 + if (this.titleEl && (this.titleEl.textContent = s), this.applySeekLabel(s), this.audio && (this.audio.src = t, this.audio.preload !== "none" && await new Promise((r, a) => {
1014 + let o = () => {
1015 + this.audio.removeEventListener("loadedmetadata", o), this.audio.removeEventListener("error", n), r();
1016 + }, n = (l2) => {
1017 + this.audio.removeEventListener("loadedmetadata", o), this.audio.removeEventListener("error", n), a(l2);
1005 1018 };
1006 - this.audio.addEventListener("loadedmetadata", o2), this.audio.addEventListener("error", n2);
1007 - })), !i2) try {
1008 - let r2 = await G(t2, this.options.samples, this.options.showBPM);
1009 - this.waveformData = r2.peaks, r2.bpm && (this.detectedBPM = r2.bpm, this.updateBPMDisplay());
1010 - } catch (r2) {
1011 - console.warn("[WaveformPlayer] Using placeholder waveform:", r2), this.waveformData = yt(this.options.samples), this.container.classList.add("waveform-is-placeholder");
1019 + this.audio.addEventListener("loadedmetadata", o), this.audio.addEventListener("error", n);
1020 + })), !i) try {
1021 + let r = await G(t, this.options.samples, this.options.showBPM);
1022 + this.waveformData = r.peaks, r.bpm && (this.detectedBPM = r.bpm, this.updateBPMDisplay());
1023 + } catch (r) {
1024 + console.warn("[WaveformPlayer] Using placeholder waveform:", r), this.waveformData = yt(this.options.samples), this.container.classList.add("waveform-is-placeholder");
1012 1025 }
1013 1026 this.drawWaveform(), this.renderMarkers(), this.options.onLoad && this.options.onLoad(this);
1014 - } catch (i2) {
1015 - this.onError(i2);
1027 + } catch (i) {
1028 + this.onError(i);
1016 1029 } finally {
1017 1030 this.setLoading(false);
1018 1031 }
1019 1032 }
1020 - async loadTrack(t2, i2 = null, s2 = null, r2 = {}) {
1021 - let a2 = Object.prototype.hasOwnProperty.call(r2, "artwork"), o2 = Object.prototype.hasOwnProperty.call(r2, "artworkAlt");
1022 - this.isPlaying && this.pause(), this.audio && (this.audio.src = "", this.audio.load()), this.hasError = false, this.errorEl && (this.errorEl.style.display = "none"), this.canvas && (this.canvas.style.opacity = "1"), this.playBtn && (this.playBtn.disabled = false), this.progress = 0, this.waveformData = [], this.options = Z(j2(this.options, { url: t2, title: i2 === null ? this.options.title : i2, artist: s2 === null ? this.options.artist : s2, ...r2 })), a2 && (this.options.artwork = r2.artwork || null), o2 ? this.options.artworkAlt = r2.artworkAlt || "" : a2 && (this.options.artworkAlt = this.options.artwork ? W.artworkAlt : ""), r2.preload && this.audio && (this.audio.preload = this.options.preload), r2.crossOrigin && this.audio && (this.audio.crossOrigin = this.options.crossOrigin), s2 !== null && this.syncArtist(s2), (a2 || o2) && this.syncArtwork(a2 ? r2.artwork : this.options.artwork, o2 ? r2.artworkAlt : this.options.artworkAlt), this.options.markers = r2.markers ? z(r2.markers) : [], this.options.waveform = r2.waveform || null, await this.load(t2), r2.autoplay !== false && this.play()?.catch(() => {
1033 + async loadTrack(t, i = null, s = null, r = {}) {
1034 + let a = Object.prototype.hasOwnProperty.call(r, "artwork"), o = Object.prototype.hasOwnProperty.call(r, "artworkAlt");
1035 + this.isPlaying && this.pause(), this.audio && (this.audio.src = "", this.audio.load()), this.hasError = false, this.errorEl && (this.errorEl.style.display = "none"), this.canvas && (this.canvas.style.opacity = "1"), this.playBtn && (this.playBtn.disabled = false), this.progress = 0, this.waveformData = [], this.options = Z(j2(this.options, { url: t, title: i === null ? this.options.title : i, artist: s === null ? this.options.artist : s, ...r })), a && (this.options.artwork = r.artwork || null), o ? this.options.artworkAlt = r.artworkAlt || "" : a && (this.options.artworkAlt = this.options.artwork ? W.artworkAlt : ""), r.preload && this.audio && (this.audio.preload = this.options.preload), r.crossOrigin && this.audio && (this.audio.crossOrigin = this.options.crossOrigin), s !== null && this.syncArtist(s), (a || o) && this.syncArtwork(a ? r.artwork : this.options.artwork, o ? r.artworkAlt : this.options.artworkAlt), this.options.markers = r.markers ? z(r.markers) : [], this.options.waveform = r.waveform || null, await this.load(t), r.autoplay !== false && this.play()?.catch(() => {
1023 1036 });
1024 1037 }
1025 - setWaveformData(t2) {
1026 - if (typeof t2 == "string" && t2.trim().endsWith(".json")) {
1027 - fetch(t2.trim()).then((i2) => i2.json()).then((i2) => {
1028 - this.waveformData = Array.isArray(i2) ? i2 : i2.peaks || [], i2.markers && !this.options.markers?.length && (this.options.markers = z(i2.markers), this.renderMarkers()), this.drawWaveform();
1038 + setWaveformData(t) {
1039 + if (typeof t == "string" && t.trim().endsWith(".json")) {
1040 + fetch(t.trim()).then((i) => i.json()).then((i) => {
1041 + this.waveformData = Array.isArray(i) ? i : i.peaks || [], i.markers && !this.options.markers?.length && (this.options.markers = z(i.markers), this.renderMarkers()), this.drawWaveform();
1029 1042 }).catch(() => {
1030 1043 });
1031 1044 return;
1032 1045 }
1033 - this.waveformData = D(t2, { fallback: [] }), this.drawWaveform();
1046 + this.waveformData = D(t, { fallback: [] }), this.drawWaveform();
1034 1047 }
1035 1048 drawWaveform() {
1036 1049 !this.ctx || this.waveformData.length === 0 || ft(this.ctx, this.canvas, this.waveformData, this.progress, { ...this.options, waveformStyle: this.options.waveformStyle || "bars", color: this.options.waveformColor, progressColor: this.options.progressColor, seekActive: this._seekHover || this._dragging });
1037 1050 }
@@ -1036,114 +1049,114 @@
1036 1049 !this.ctx || this.waveformData.length === 0 || ft(this.ctx, this.canvas, this.waveformData, this.progress, { ...this.options, waveformStyle: this.options.waveformStyle || "bars", color: this.options.waveformColor, progressColor: this.options.progressColor, seekActive: this._seekHover || this._dragging });
1037 1050 }
1038 1051 resizeCanvas() {
1039 1052 if (!this.canvas || this.isDestroying) return;
1040 - let t2 = window.devicePixelRatio || 1, i2 = this.canvas.parentElement.getBoundingClientRect();
1041 - this.canvas.width = i2.width * t2, this.canvas.height = this.options.height * t2, this.canvas.parentElement.style.height = this.options.height + "px", this.drawWaveform();
1053 + let t = window.devicePixelRatio || 1, i = this.canvas.parentElement.getBoundingClientRect();
1054 + this.canvas.width = i.width * t, this.canvas.height = this.options.height * t, this.canvas.parentElement.style.height = this.options.height + "px", this.drawWaveform();
1042 1055 }
1043 1056 renderMarkers() {
1044 1057 if (!this.markersContainer || (this.markersContainer.innerHTML = "", this._activeMarkerIndex = -1, clearTimeout(this._markerLabelTimer), !this.options.showMarkers || !this.options.markers?.length)) return;
1045 - let t2 = this.getSeekDuration();
1046 - t2 && this.options.markers.forEach((i2, s2) => {
1047 - if (i2.time > t2) {
1048 - console.warn(`[WaveformPlayer] Marker "${i2.label}" at ${i2.time}s exceeds audio duration of ${t2}s`);
1058 + let t = this.getSeekDuration();
1059 + t && this.options.markers.forEach((i, s) => {
1060 + if (i.time > t) {
1061 + console.warn(`[WaveformPlayer] Marker "${i.label}" at ${i.time}s exceeds audio duration of ${t}s`);
1049 1062 return;
1050 1063 }
1051 - let r2 = i2.time / t2 * 100, a2 = document.createElement("button");
1052 - a2.className = "waveform-marker", a2.style.left = `${r2}%`, a2.style.backgroundColor = i2.color || "rgba(255, 255, 255, 0.5)", a2.setAttribute("aria-label", i2.label), a2.setAttribute("data-time", i2.time);
1053 - let o2 = document.createElement("span");
1054 - o2.className = "waveform-marker-tooltip", o2.textContent = i2.label, a2.appendChild(o2), a2.addEventListener("click", (n2) => {
1055 - n2.stopPropagation(), this.seekTo(i2.time), this.options.playOnSeek && !this.isPlaying && this.play();
1056 - }), this.markersContainer.appendChild(a2);
1064 + let r = i.time / t * 100, a = document.createElement("button");
1065 + a.className = "waveform-marker", a.style.left = `${r}%`, a.style.backgroundColor = i.color || "rgba(255, 255, 255, 0.5)", a.setAttribute("aria-label", i.label), a.setAttribute("data-time", i.time);
1066 + let o = document.createElement("span");
1067 + o.className = "waveform-marker-tooltip", o.textContent = i.label, a.appendChild(o), a.addEventListener("click", (n) => {
1068 + n.stopPropagation(), this.seekTo(i.time), this.options.playOnSeek && !this.isPlaying && this.play();
1069 + }), this.markersContainer.appendChild(a);
1057 1070 });
1058 1071 }
1059 - setActiveMarker(t2) {
1072 + setActiveMarker(t) {
1060 1073 if (!this.markersContainer) return;
1061 - this.markersContainer.querySelectorAll(".waveform-marker").forEach((s2, r2) => s2.classList.toggle("active", r2 === t2));
1074 + this.markersContainer.querySelectorAll(".waveform-marker").forEach((s, r) => s.classList.toggle("active", r === t));
1062 1075 }
1063 1076 updateActiveMarker() {
1064 1077 if (!this.markersContainer) return;
1065 - let t2 = this.markersContainer.querySelectorAll(".waveform-marker");
1066 - if (!t2.length) return;
1067 - let i2 = this.getSeekDuration(), s2 = i2 ? this.progress * i2 : 0, r2 = -1, a2 = -1 / 0;
1068 - t2.forEach((o2, n2) => {
1069 - let l2 = parseFloat(o2.getAttribute("data-time"));
1070 - Number.isFinite(l2) && l2 <= s2 + 0.05 && l2 > a2 && (a2 = l2, r2 = n2);
1071 - }), r2 !== this._activeMarkerIndex && (this._activeMarkerIndex = r2, this.setActiveMarker(r2), clearTimeout(this._markerLabelTimer), t2.forEach((o2, n2) => o2.classList.toggle("show-label", n2 === r2)), r2 >= 0 && (this._markerLabelTimer = setTimeout(() => {
1072 - this.markersContainer?.querySelectorAll(".waveform-marker").forEach((o2) => o2.classList.remove("show-label"));
1078 + let t = this.markersContainer.querySelectorAll(".waveform-marker");
1079 + if (!t.length) return;
1080 + let i = this.getSeekDuration(), s = i ? this.progress * i : 0, r = -1, a = -1 / 0;
1081 + t.forEach((o, n) => {
1082 + let l2 = parseFloat(o.getAttribute("data-time"));
1083 + Number.isFinite(l2) && l2 <= s + 0.05 && l2 > a && (a = l2, r = n);
1084 + }), r !== this._activeMarkerIndex && (this._activeMarkerIndex = r, this.setActiveMarker(r), clearTimeout(this._markerLabelTimer), t.forEach((o, n) => o.classList.toggle("show-label", n === r)), r >= 0 && (this._markerLabelTimer = setTimeout(() => {
1085 + this.markersContainer?.querySelectorAll(".waveform-marker").forEach((o) => o.classList.remove("show-label"));
1073 1086 }, 2500)));
1074 1087 }
1075 1088 setupHoverTime() {
1076 1089 if (!this.seekEl) return;
1077 - let t2 = document.createElement("div");
1078 - t2.className = "waveform-hover-time", t2.setAttribute("aria-hidden", "true"), this.seekEl.appendChild(t2), this.hoverTimeEl = t2, this.options.showHoverTime && (this.seekEl.addEventListener("pointermove", (i2) => {
1079 - this._dragging || this._updateHoverTip(i2.clientX);
1090 + let t = document.createElement("div");
1091 + t.className = "waveform-hover-time", t.setAttribute("aria-hidden", "true"), this.seekEl.appendChild(t), this.hoverTimeEl = t, this.options.showHoverTime && (this.seekEl.addEventListener("pointermove", (i) => {
1092 + this._dragging || this._updateHoverTip(i.clientX);
1080 1093 }), this.seekEl.addEventListener("pointerleave", () => {
1081 1094 this._dragging || this._hideHoverTip();
1082 1095 }));
1083 1096 }
1084 - _updateHoverTip(t2) {
1085 - let i2 = this.hoverTimeEl;
1086 - if (!i2) return;
1087 - let s2 = this.getSeekDuration();
1088 - if (!s2) {
1089 - i2.style.opacity = "0";
1097 + _updateHoverTip(t) {
1098 + let i = this.hoverTimeEl;
1099 + if (!i) return;
1100 + let s = this.getSeekDuration();
1101 + if (!s) {
1102 + i.style.opacity = "0";
1090 1103 return;
1091 1104 }
1092 - let r2 = this.canvas.getBoundingClientRect(), a2 = m2((t2 - r2.left) / r2.width);
1093 - i2.textContent = E(a2 * s2), i2.style.left = a2 * 100 + "%", i2.style.opacity = "1";
1105 + let r = this.canvas.getBoundingClientRect(), a = m2((t - r.left) / r.width);
1106 + i.textContent = E2(a * s), i.style.left = a * 100 + "%", i.style.opacity = "1";
1094 1107 }
1095 1108 _hideHoverTip() {
1096 1109 this.hoverTimeEl && (this.hoverTimeEl.style.opacity = "0");
1097 1110 }
1098 - _scrubTo(t2) {
1099 - let i2 = this.canvas.getBoundingClientRect();
1100 - if (!i2.width) return;
1101 - this.progress = m2((t2 - i2.left) / i2.width), this.drawWaveform(), this._updateSeekHandle();
1102 - let s2 = this.getSeekDuration();
1103 - s2 && this.currentTimeEl ? (this.currentTimeEl.textContent = E(this.progress * s2), this._hideHoverTip()) : this._updateHoverTip(t2);
1111 + _scrubTo(t) {
1112 + let i = this.canvas.getBoundingClientRect();
1113 + if (!i.width) return;
1114 + this.progress = m2((t - i.left) / i.width), this.drawWaveform(), this._updateSeekHandle();
1115 + let s = this.getSeekDuration();
1116 + s && this.currentTimeEl ? (this.currentTimeEl.textContent = E2(this.progress * s), this._hideHoverTip()) : this._updateHoverTip(t);
1104 1117 }
1105 1118 setupSeekHandle() {
1106 1119 if (!this.options.seekHandle || this.options.waveformStyle !== "seekbar" || !this.seekEl) return;
1107 - let t2 = document.createElement("div");
1108 - t2.className = "waveform-seek-handle", t2.setAttribute("aria-hidden", "true"), this.seekEl.appendChild(t2), this.seekHandleEl = t2;
1120 + let t = document.createElement("div");
1121 + t.className = "waveform-seek-handle", t.setAttribute("aria-hidden", "true"), this.seekEl.appendChild(t), this.seekHandleEl = t;
1109 1122 }
1110 1123 _updateSeekHandle() {
1111 - let t2 = this.seekHandleEl;
1112 - t2 && (t2.style.left = this.progress * 100 + "%", t2.classList.toggle("is-visible", this._seekHover || this._dragging), t2.classList.toggle("is-active", this._dragging || this._handleNear));
1124 + let t = this.seekHandleEl;
1125 + t && (t.style.left = this.progress * 100 + "%", t.classList.toggle("is-visible", this._seekHover || this._dragging), t.classList.toggle("is-active", this._dragging || this._handleNear));
1113 1126 }
1114 - handleCanvasClick(t2) {
1127 + handleCanvasClick(t) {
1115 1128 if (this._suppressClick) {
1116 1129 this._suppressClick = false;
1117 1130 return;
1118 1131 }
1119 - this._seekFromPointer(t2.clientX);
1132 + this._seekFromPointer(t.clientX);
1120 1133 }
1121 - _seekFromPointer(t2) {
1122 - let i2 = this.canvas.getBoundingClientRect();
1123 - if (!i2.width) return;
1124 - let s2 = m2((t2 - i2.left) / i2.width);
1134 + _seekFromPointer(t) {
1135 + let i = this.canvas.getBoundingClientRect();
1136 + if (!i.width) return;
1137 + let s = m2((t - i.left) / i.width);
1125 1138 if (this.options.audioMode === "external") {
1126 - this._requestSeek(s2);
1139 + this._requestSeek(s);
1127 1140 return;
1128 1141 }
1129 - !this.audio || !this.audio.duration || this.seekToPercent(s2);
1142 + !this.audio || !this.audio.duration || this.seekToPercent(s);
1130 1143 }
1131 - setLoading(t2) {
1132 - if (this.isLoading = t2, this.loadingEl) {
1133 - let i2 = t2 && this.waveformData.length === 0;
1134 - this.loadingEl.style.display = i2 ? "block" : "none";
1144 + setLoading(t) {
1145 + if (this.isLoading = t, this.loadingEl) {
1146 + let i = t && this.waveformData.length === 0;
1147 + this.loadingEl.style.display = i ? "block" : "none";
1135 1148 }
1136 - this.seekEl && this.seekEl.setAttribute("aria-busy", t2 ? "true" : "false");
1149 + this.seekEl && this.seekEl.setAttribute("aria-busy", t ? "true" : "false");
1137 1150 }
1138 1151 onMetadataLoaded() {
1139 - this.isDestroying || (this.totalTimeEl && (this.totalTimeEl.textContent = E(this.audio.duration)), this.renderMarkers(), this.updateSeekAccessibility());
1152 + this.isDestroying || (this.totalTimeEl && (this.totalTimeEl.textContent = E2(this.audio.duration)), this.renderMarkers(), this.updateSeekAccessibility());
1140 1153 }
1141 - setPlayButtonState(t2) {
1154 + setPlayButtonState(t) {
1142 1155 if (!this.playBtn) return;
1143 - this.playBtn.classList.toggle("playing", t2);
1144 - let i2 = this.playBtn.querySelector(".waveform-icon-play"), s2 = this.playBtn.querySelector(".waveform-icon-pause");
1145 - i2 && (i2.style.display = t2 ? "none" : "flex"), s2 && (s2.style.display = t2 ? "flex" : "none");
1156 + this.playBtn.classList.toggle("playing", t);
1157 + let i = this.playBtn.querySelector(".waveform-icon-play"), s = this.playBtn.querySelector(".waveform-icon-pause");
1158 + i && (i.style.display = t ? "none" : "flex"), s && (s.style.display = t ? "flex" : "none");
1146 1159 }
1147 1160 onPlay() {
1148 1161 this.isDestroying || (this.isPlaying = true, this.setPlayButtonState(true), this.startSmoothUpdate(), this._updateMediaSession("playing"), this._emit("waveformplayer:play", { player: this, url: this.options.url }), this.options.onPlay && this.options.onPlay(this));
1149 1162 }
@@ -1151,20 +1164,20 @@
1151 1164 this.isDestroying || (this.isPlaying = false, this.setPlayButtonState(false), this.stopSmoothUpdate(), this._updateMediaSession("paused"), this._emit("waveformplayer:pause", { player: this, url: this.options.url }), this.options.onPause && this.options.onPause(this));
1152 1165 }
1153 1166 onEnded() {
1154 1167 if (this.isDestroying) return;
1155 - let t2 = this.audio.duration;
1156 - this.progress = 0, this.audio.currentTime = 0, this.drawWaveform(), this.currentTimeEl && (this.currentTimeEl.textContent = "0:00"), this._emit("waveformplayer:ended", { player: this, url: this.options.url, currentTime: t2, duration: t2 }), this.onPause(), this.options.onEnd && this.options.onEnd(this);
1168 + let t = this.audio.duration;
1169 + this.progress = 0, this.audio.currentTime = 0, this.drawWaveform(), this.currentTimeEl && (this.currentTimeEl.textContent = "0:00"), this._emit("waveformplayer:ended", { player: this, url: this.options.url, currentTime: t, duration: t }), this.onPause(), this.options.onEnd && this.options.onEnd(this);
1157 1170 }
1158 - onError(t2) {
1159 - this.isDestroying || (console.error("[WaveformPlayer] Audio error:", t2), this.hasError = true, this.setLoading(false), this.errorEl && (this.errorEl.style.display = "flex"), this.canvas && (this.canvas.style.opacity = "0.2"), this.playBtn && (this.playBtn.disabled = true), this.options.onError && this.options.onError(t2, this));
1171 + onError(t) {
1172 + this.isDestroying || (console.error("[WaveformPlayer] Audio error:", t), this.hasError = true, this.setLoading(false), this.errorEl && (this.errorEl.style.display = "flex"), this.canvas && (this.canvas.style.opacity = "0.2"), this.playBtn && (this.playBtn.disabled = true), this.options.onError && this.options.onError(t, this));
1160 1173 }
1161 1174 startSmoothUpdate() {
1162 1175 this.stopSmoothUpdate();
1163 - let t2 = () => {
1164 - this.isPlaying && this.audio && this.audio.duration && (this.updateProgress(), this.updateTimer = requestAnimationFrame(t2));
1176 + let t = () => {
1177 + this.isPlaying && this.audio && this.audio.duration && (this.updateProgress(), this.updateTimer = requestAnimationFrame(t));
1165 1178 };
1166 - this.updateTimer = requestAnimationFrame(t2);
1179 + this.updateTimer = requestAnimationFrame(t);
1167 1180 }
1168 1181 stopSmoothUpdate() {
1169 1182 this.updateTimer && (cancelAnimationFrame(this.updateTimer), this.updateTimer = null);
1170 1183 }
@@ -1169,20 +1182,20 @@
1169 1182 this.updateTimer && (cancelAnimationFrame(this.updateTimer), this.updateTimer = null);
1170 1183 }
1171 1184 updateProgress() {
1172 1185 if (!this.audio || !this.audio.duration || this._dragging) return;
1173 - let t2 = this.audio.currentTime / this.audio.duration;
1174 - Math.abs(t2 - this.progress) > 1e-3 && (this.progress = t2, this.drawWaveform(), this._updateSeekHandle()), this.currentTimeEl && (this.currentTimeEl.textContent = E(this.audio.currentTime)), this._emit("waveformplayer:timeupdate", { player: this, currentTime: this.audio.currentTime, duration: this.audio.duration, progress: this.progress, url: this.options.url }), this.options.onTimeUpdate && this.options.onTimeUpdate(this.audio.currentTime, this.audio.duration, this), this.updateActiveMarker(), this.updateSeekAccessibility();
1186 + let t = this.audio.currentTime / this.audio.duration;
1187 + Math.abs(t - this.progress) > 1e-3 && (this.progress = t, this.drawWaveform(), this._updateSeekHandle()), this.currentTimeEl && (this.currentTimeEl.textContent = E2(this.audio.currentTime)), this._emit("waveformplayer:timeupdate", { player: this, currentTime: this.audio.currentTime, duration: this.audio.duration, progress: this.progress, url: this.options.url }), this.options.onTimeUpdate && this.options.onTimeUpdate(this.audio.currentTime, this.audio.duration, this), this.updateActiveMarker(), this.updateSeekAccessibility();
1175 1188 }
1176 1189 updateBPMDisplay() {
1177 - let t2 = this.options.bpm || this.detectedBPM;
1178 - this.bpmEl && this.bpmValueEl && t2 && (this.bpmValueEl.textContent = Math.round(t2), this.bpmEl.style.display = "inline-flex");
1190 + let t = this.options.bpm || this.detectedBPM;
1191 + this.bpmEl && this.bpmValueEl && t && (this.bpmValueEl.textContent = Math.round(t), this.bpmEl.style.display = "inline-flex");
1179 1192 }
1180 1193 refreshTheme() {
1181 1194 if (!this._autoTheme) return;
1182 - this._scheme = R(this.container);
1183 - let t2 = J(this.options.colorPreset, this.container);
1184 - for (let i2 of this._presetKeys || []) i2 in t2 && (this.options[i2] = t2[i2]);
1195 + this._scheme = R2(this.container);
1196 + let t = J(this.options.colorPreset, this.container);
1197 + for (let i of this._presetKeys || []) i in t && (this.options[i] = t[i]);
1185 1198 this._applyThemeColors();
1186 1199 }
1187 1200 _applyThemeColors() {
1188 1201 this.container.classList.toggle("waveform-theme-light", this._scheme === "light"), this.canvas && this.drawWaveform();
@@ -1187,46 +1200,46 @@
1187 1200 _applyThemeColors() {
1188 1201 this.container.classList.toggle("waveform-theme-light", this._scheme === "light"), this.canvas && this.drawWaveform();
1189 1202 }
1190 1203 static _watchTheme() {
1191 - if (e2._themeWatch || typeof document > "u") return;
1192 - let t2 = () => requestAnimationFrame(() => {
1193 - e2.instances.forEach((a2) => {
1204 + if (e._themeWatch || typeof document > "u") return;
1205 + let t = () => requestAnimationFrame(() => {
1206 + e.instances.forEach((a) => {
1194 1207 try {
1195 - a2.refreshTheme();
1208 + a.refreshTheme();
1196 1209 } catch {
1197 1210 }
1198 1211 });
1199 - }), i2 = { attributes: true, attributeFilter: ["class", "data-theme", "data-color-scheme", "style"] }, s2 = new MutationObserver(t2);
1200 - s2.observe(document.documentElement, i2), document.body && s2.observe(document.body, i2);
1201 - let r2 = null;
1212 + }), i = { attributes: true, attributeFilter: ["class", "data-theme", "data-color-scheme", "style"] }, s = new MutationObserver(t);
1213 + s.observe(document.documentElement, i), document.body && s.observe(document.body, i);
1214 + let r = null;
1202 1215 try {
1203 - r2 = window.matchMedia("(prefers-color-scheme: dark)"), r2.addEventListener("change", t2);
1216 + r = window.matchMedia("(prefers-color-scheme: dark)"), r.addEventListener("change", t);
1204 1217 } catch {
1205 1218 }
1206 - e2._themeWatch = { obs: s2, mq: r2, refresh: t2 };
1219 + e._themeWatch = { obs: s, mq: r, refresh: t };
1207 1220 }
1208 1221 updateSpeedUI() {
1209 1222 if (!this.audio) return;
1210 - let t2 = this.container.querySelector(".speed-value");
1211 - if (t2) {
1212 - let i2 = this.audio.playbackRate;
1213 - t2.textContent = i2 === 1 ? "1x" : `${i2}x`;
1223 + let t = this.container.querySelector(".speed-value");
1224 + if (t) {
1225 + let i = this.audio.playbackRate;
1226 + t.textContent = i === 1 ? "1x" : `${i}x`;
1214 1227 }
1215 - this.container.querySelectorAll(".speed-option").forEach((i2) => {
1216 - let s2 = parseFloat(i2.dataset.rate) === this.audio.playbackRate;
1217 - i2.classList.toggle("active", s2), i2.setAttribute("aria-checked", s2 ? "true" : "false");
1228 + this.container.querySelectorAll(".speed-option").forEach((i) => {
1229 + let s = parseFloat(i.dataset.rate) === this.audio.playbackRate;
1230 + i.classList.toggle("active", s), i.setAttribute("aria-checked", s ? "true" : "false");
1218 1231 });
1219 1232 }
1220 1233 play() {
1221 - if (this.options.singlePlay && e2.currentlyPlaying && e2.currentlyPlaying !== this && e2.currentlyPlaying.pause(), this.options.audioMode === "external") {
1222 - this._emit("waveformplayer:request-play", this._buildTrackDetail(), true).defaultPrevented || (e2.currentlyPlaying = this);
1234 + if (this.options.singlePlay && e.currentlyPlaying && e.currentlyPlaying !== this && e.currentlyPlaying.pause(), this.options.audioMode === "external") {
1235 + this._emit("waveformplayer:request-play", this._buildTrackDetail(), true).defaultPrevented || (e.currentlyPlaying = this);
1223 1236 return;
1224 1237 }
1225 - return e2.currentlyPlaying = this, this.audio.play();
1238 + return e.currentlyPlaying = this, this.audio.play();
1226 1239 }
1227 1240 pause() {
1228 - if (e2.currentlyPlaying === this && (e2.currentlyPlaying = null), this.options.audioMode === "external") {
1241 + if (e.currentlyPlaying === this && (e.currentlyPlaying = null), this.options.audioMode === "external") {
1229 1242 this._emit("waveformplayer:request-pause", this._buildTrackDetail(), true);
1230 1243 return;
1231 1244 }
1232 1245 this.audio.pause();
@@ -1233,78 +1246,78 @@
1233 1246 }
1234 1247 _buildTrackDetail() {
1235 1248 return { url: this.options.url, title: this.options.title, artist: this.options.artist, artwork: this.options.artwork, markers: this.options.markers, waveform: this.options.waveform, id: this.id, player: this };
1236 1249 }
1237 - setPlayingState(t2) {
1238 - let i2 = this.isPlaying;
1239 - this.isPlaying = !!t2, this.setPlayButtonState(this.isPlaying), this.isPlaying && !i2 ? (this.startSmoothUpdate?.(), this._emit("waveformplayer:play", { player: this, url: this.options.url }), this.options.onPlay && this.options.onPlay(this)) : !this.isPlaying && i2 && (this.stopSmoothUpdate?.(), this._emit("waveformplayer:pause", { player: this, url: this.options.url }), this.options.onPause && this.options.onPause(this));
1250 + setPlayingState(t) {
1251 + let i = this.isPlaying;
1252 + this.isPlaying = !!t, this.setPlayButtonState(this.isPlaying), this.isPlaying && !i ? (this.startSmoothUpdate?.(), this._emit("waveformplayer:play", { player: this, url: this.options.url }), this.options.onPlay && this.options.onPlay(this)) : !this.isPlaying && i && (this.stopSmoothUpdate?.(), this._emit("waveformplayer:pause", { player: this, url: this.options.url }), this.options.onPause && this.options.onPause(this));
1240 1253 }
1241 - setProgress(t2, i2) {
1242 - !i2 || i2 <= 0 || (this.progress = m2(t2 / i2), this.currentTimeEl && (this.currentTimeEl.textContent = E(t2)), this._extDuration = i2, this.totalTimeEl && (!this.totalTimeEl.dataset._extSet || this.totalTimeEl.dataset._extDur !== String(i2)) && (this.totalTimeEl.textContent = E(i2), this.totalTimeEl.dataset._extSet = "1", this.totalTimeEl.dataset._extDur = String(i2)), this.drawWaveform?.(), this.updateActiveMarker(), this._emit("waveformplayer:timeupdate", { player: this, currentTime: t2, duration: i2, progress: this.progress, url: this.options.url }), this.options.onTimeUpdate && this.options.onTimeUpdate(t2, i2, this), this.progress >= 1 ? this._extEnded || (this._extEnded = true, this._emit("waveformplayer:ended", { player: this, url: this.options.url, currentTime: i2, duration: i2 }), this.options.onEnd && this.options.onEnd(this)) : this._extEnded = false, this.updateSeekAccessibility());
1254 + setProgress(t, i) {
1255 + !i || i <= 0 || (this.progress = m2(t / i), this.currentTimeEl && (this.currentTimeEl.textContent = E2(t)), this._extDuration = i, this.totalTimeEl && (!this.totalTimeEl.dataset._extSet || this.totalTimeEl.dataset._extDur !== String(i)) && (this.totalTimeEl.textContent = E2(i), this.totalTimeEl.dataset._extSet = "1", this.totalTimeEl.dataset._extDur = String(i)), this.drawWaveform?.(), this.updateActiveMarker(), this._emit("waveformplayer:timeupdate", { player: this, currentTime: t, duration: i, progress: this.progress, url: this.options.url }), this.options.onTimeUpdate && this.options.onTimeUpdate(t, i, this), this.progress >= 1 ? this._extEnded || (this._extEnded = true, this._emit("waveformplayer:ended", { player: this, url: this.options.url, currentTime: i, duration: i }), this.options.onEnd && this.options.onEnd(this)) : this._extEnded = false, this.updateSeekAccessibility());
1243 1256 }
1244 1257 togglePlay() {
1245 1258 this.isPlaying ? this.pause() : this.play();
1246 1259 }
1247 - seekTo(t2) {
1248 - this.audio && this.audio.duration && (this.audio.currentTime = m2(t2, 0, this.audio.duration), this.updateProgress());
1260 + seekTo(t) {
1261 + this.audio && this.audio.duration && (this.audio.currentTime = m2(t, 0, this.audio.duration), this.updateProgress());
1249 1262 }
1250 - seekToPercent(t2) {
1251 - this.audio && this.audio.duration && (this.audio.currentTime = this.audio.duration * m2(t2), this.updateProgress());
1263 + seekToPercent(t) {
1264 + this.audio && this.audio.duration && (this.audio.currentTime = this.audio.duration * m2(t), this.updateProgress());
1252 1265 }
1253 - setVolume(t2) {
1254 - let i2 = Number(t2);
1255 - this.audio && Number.isFinite(i2) && (this.audio.volume = m2(i2));
1266 + setVolume(t) {
1267 + let i = Number(t);
1268 + this.audio && Number.isFinite(i) && (this.audio.volume = m2(i));
1256 1269 }
1257 - setPlaybackRate(t2) {
1270 + setPlaybackRate(t) {
1258 1271 if (!this.audio) return;
1259 - let i2 = _(t2, null, { min: N2, max: F });
1260 - i2 !== null && (this.audio.playbackRate = i2, this.options.playbackRate = i2, this.updateSpeedUI());
1272 + let i = _(t, null, { min: N2, max: F });
1273 + i !== null && (this.audio.playbackRate = i, this.options.playbackRate = i, this.updateSpeedUI());
1261 1274 }
1262 1275 destroy() {
1263 - this.isDestroying = true, this._emit("waveformplayer:destroy", { player: this, url: this.options.url }), this.pause(), this.stopSmoothUpdate(), clearTimeout(this._markerLabelTimer), this._ac?.abort(), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), this.resizeHandler && (window.removeEventListener("resize", this.resizeHandler), this.resizeHandler = null), e2.instances.delete(this.id), e2.currentlyPlaying === this && (e2.currentlyPlaying = null), this.audio && (this.audio.pause(), this.audio.src = "", this.audio.load(), this.audio = null), this.container.innerHTML = "", delete this.container.dataset.waveformInitialized, this.canvas = null, this.ctx = null, this.playBtn = null, this.waveformData = [];
1276 + this.isDestroying = true, this._emit("waveformplayer:destroy", { player: this, url: this.options.url }), this.pause(), this.stopSmoothUpdate(), clearTimeout(this._markerLabelTimer), this._ac?.abort(), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), this.resizeHandler && (window.removeEventListener("resize", this.resizeHandler), this.resizeHandler = null), e.instances.delete(this.id), e.currentlyPlaying === this && (e.currentlyPlaying = null), this.audio && (this.audio.pause(), this.audio.src = "", this.audio.load(), this.audio = null), this.container.innerHTML = "", delete this.container.dataset.waveformInitialized, this.canvas = null, this.ctx = null, this.playBtn = null, this.waveformData = [];
1264 1277 }
1265 - static getInstance(t2) {
1266 - if (typeof t2 == "string") {
1267 - let i2 = this.instances.get(t2);
1268 - if (i2) return i2;
1269 - let s2 = document.getElementById(t2);
1270 - if (s2) return Array.from(this.instances.values()).find((r2) => r2.container === s2);
1278 + static getInstance(t) {
1279 + if (typeof t == "string") {
1280 + let i = this.instances.get(t);
1281 + if (i) return i;
1282 + let s = document.getElementById(t);
1283 + if (s) return Array.from(this.instances.values()).find((r) => r.container === s);
1271 1284 }
1272 - if (t2 instanceof HTMLElement) return Array.from(this.instances.values()).find((i2) => i2.container === t2);
1285 + if (t instanceof HTMLElement) return Array.from(this.instances.values()).find((i) => i.container === t);
1273 1286 }
1274 1287 static getAllInstances() {
1275 1288 return Array.from(this.instances.values());
1276 1289 }
1277 1290 static destroyAll() {
1278 - this.instances.forEach((t2) => t2.destroy()), this.instances.clear();
1291 + this.instances.forEach((t) => t.destroy()), this.instances.clear();
1279 1292 }
1280 - static async generateWaveformData(t2, i2 = 1800) {
1293 + static async generateWaveformData(t, i = 1800) {
1281 1294 try {
1282 - return (await G(t2, i2)).peaks;
1283 - } catch (s2) {
1284 - throw console.error("[WaveformPlayer] Failed to generate waveform:", s2), s2;
1295 + return (await G(t, i)).peaks;
1296 + } catch (s) {
1297 + throw console.error("[WaveformPlayer] Failed to generate waveform:", s), s;
1285 1298 }
1286 1299 }
1287 - static getPeaksUrl(t2) {
1288 - if (!t2) return;
1289 - let i2 = t2.replace(/\.(mp3|wav|ogg|flac|m4a|aac)(\?[^#]*)?(#.*)?$/i, ".json$2$3");
1290 - return i2 === t2 ? void 0 : i2;
1300 + static getPeaksUrl(t) {
1301 + if (!t) return;
1302 + let i = t.replace(/\.(mp3|wav|ogg|flac|m4a|aac)(\?[^#]*)?(#.*)?$/i, ".json$2$3");
1303 + return i === t ? void 0 : i;
1291 1304 }
1292 1305 };
1293 -T.utils = { formatTime: E, extractTitleFromUrl: I, escapeHtml: S, isSafeHref: st, parseDataAttributes: O, detectColorScheme: R };
1306 +T.utils = { formatTime: E2, extractTitleFromUrl: I, escapeHtml: S, isSafeHref: st, parseDataAttributes: O, detectColorScheme: R2 };
1294 1307 var et = () => typeof window < "u" && typeof document < "u";
1295 1308 var Nt = () => true;
1296 -function kt(e3) {
1297 - if (!(e3.dataset.waveformInitialized === "true" || T.getInstance(e3))) try {
1298 - new T(e3), e3.dataset.waveformInitialized = "true";
1299 - } catch (t2) {
1300 - console.error("[WaveformPlayer] Failed to initialize:", t2, e3);
1309 +function kt(e2) {
1310 + if (!(e2.dataset.waveformInitialized === "true" || T.getInstance(e2))) try {
1311 + new T(e2), e2.dataset.waveformInitialized = "true";
1312 + } catch (t) {
1313 + console.error("[WaveformPlayer] Failed to initialize:", t, e2);
1301 1314 }
1302 1315 }
1303 -function tt(e3 = document) {
1316 +function tt(e2 = document) {
1304 1317 if (!et()) return;
1305 - let t2 = e3 || document;
1306 - t2.matches?.("[data-waveform-player]") && kt(t2), t2.querySelectorAll("[data-waveform-player]").forEach(kt);
1318 + let t = e2 || document;
1319 + t.matches?.("[data-waveform-player]") && kt(t), t.querySelectorAll("[data-waveform-player]").forEach(kt);
1307 1320 }
1308 1321 et() && !Nt() && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => tt()) : tt());
1309 1322 T.init = tt;
1310 1323 et() && (window.WaveformPlayer = T);
@@ -1384,9 +1397,9 @@
1384 1397 if (colorFunction) {
1385 1398 return colorFunction;
1386 1399 }
1387 1400 const [possibleColor] = gradientPart.split(/\s+/);
1388 - if (w(possibleColor).isValid()) {
1401 + if (A(possibleColor).isValid()) {
1389 1402 return possibleColor;
1390 1403 }
1391 1404 }
1392 1405 function getWaveformGradientDirection(gradientValue) {
@@ -1419,9 +1432,9 @@
1419 1432 return "vertical";
1420 1433 }
1421 1434 }
1422 1435 function resolveColorValue(element, colorValue) {
1423 - if (!colorValue || w(colorValue).isValid()) {
1436 + if (!colorValue || A(colorValue).isValid()) {
1424 1437 return colorValue;
1425 1438 }
1426 1439 const colorResolver = element.ownerDocument.createElement("span");
1427 1440 colorResolver.style.color = colorValue;
@@ -1430,21 +1443,21 @@
1430 1443 }
1431 1444 element.appendChild(colorResolver);
1432 1445 const resolvedColor = getComputedStyle2(colorResolver).color;
1433 1446 colorResolver.remove();
1434 - return resolvedColor && w(resolvedColor).isValid() ? resolvedColor : colorValue;
1447 + return resolvedColor && A(resolvedColor).isValid() ? resolvedColor : colorValue;
1435 1448 }
1436 1449 function getResolvedGradientStops(element, gradientValue) {
1437 - const stops = getWaveformGradientStops(gradientValue)?.map((colorValue) => resolveColorValue(element, colorValue)).filter((colorValue) => w(colorValue).isValid());
1450 + const stops = getWaveformGradientStops(gradientValue)?.map((colorValue) => resolveColorValue(element, colorValue)).filter((colorValue) => A(colorValue).isValid());
1438 1451 return stops?.length > 1 ? stops : void 0;
1439 1452 }
1440 1453 function applyAlpha(colorValue, alpha) {
1441 1454 if (Array.isArray(colorValue)) {
1442 1455 return colorValue.map(
1443 - (color) => w(color).alpha(alpha).toRgbString()
1456 + (color) => A(color).alpha(alpha).toRgbString()
1444 1457 );
1445 1458 }
1446 - return w(colorValue).alpha(alpha).toRgbString();
1459 + return A(colorValue).alpha(alpha).toRgbString();
1447 1460 }
1448 1461 function getRepresentativeColor(colorValue) {
1449 1462 if (Array.isArray(colorValue)) {
1450 1463 return colorValue[colorValue.length - 1];
@@ -1572,9 +1585,9 @@
1572 1585 }
1573 1586 }
1574 1587 }
1575 1588 function styleSvgIcons(container, buttonColor) {
1576 - const isButtonDark = w(buttonColor).isDark();
1589 + const isButtonDark = A(buttonColor).isDark();
1577 1590 const iconColor = isButtonDark ? "#ffffff" : "#000000";
1578 1591 const svgPaths = container.querySelectorAll("svg path");
1579 1592 svgPaths.forEach((path) => {
1580 1593 path.style.fill = iconColor;