@braccato/core 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +451 -406
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { property as
|
|
3
|
-
function
|
|
1
|
+
import { LitElement as lt, unsafeCSS as X, html as dt } from "lit";
|
|
2
|
+
import { property as I } from "lit/decorators.js";
|
|
3
|
+
function q(t) {
|
|
4
4
|
if (!t) return 0;
|
|
5
5
|
if (typeof t == "number") return t;
|
|
6
6
|
const e = t.match(/^([\d.]+)(h|m|s|ms)$/);
|
|
7
7
|
if (e) {
|
|
8
|
-
const
|
|
9
|
-
if (o === "h") return Math.round(
|
|
10
|
-
if (o === "m") return Math.round(
|
|
11
|
-
if (o === "s") return Math.round(
|
|
12
|
-
if (o === "ms") return Math.round(
|
|
8
|
+
const n = Number.parseFloat(e[1]), o = e[2];
|
|
9
|
+
if (o === "h") return Math.round(n * 36e5);
|
|
10
|
+
if (o === "m") return Math.round(n * 6e4);
|
|
11
|
+
if (o === "s") return Math.round(n * 1e3);
|
|
12
|
+
if (o === "ms") return Math.round(n);
|
|
13
13
|
}
|
|
14
|
-
const a = t.split(":").map((
|
|
14
|
+
const a = t.split(":").map((n) => n.replace(/[^0-9.]/g, ""));
|
|
15
15
|
let r = 0;
|
|
16
16
|
try {
|
|
17
17
|
return a.length === 1 ? r = Number.parseFloat(a[0]) * 1e3 : a.length === 2 ? r = Number.parseInt(a[0], 10) * 6e4 + Number.parseFloat(a[1]) * 1e3 : a.length === 3 && (r = Number.parseInt(a[0], 10) * 36e5 + Number.parseInt(a[1], 10) * 6e4 + Number.parseFloat(a[2]) * 1e3), Math.round(r);
|
|
@@ -26,11 +26,11 @@ function k(t, e) {
|
|
|
26
26
|
if (r.localName === e) return r.value;
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function j(t) {
|
|
30
30
|
const e = {
|
|
31
31
|
text: "",
|
|
32
|
-
begin: k(t, "begin") ?
|
|
33
|
-
end: k(t, "end") ?
|
|
32
|
+
begin: k(t, "begin") ? q(k(t, "begin")) : void 0,
|
|
33
|
+
end: k(t, "end") ? q(k(t, "end")) : void 0,
|
|
34
34
|
role: k(t, "role") ?? void 0,
|
|
35
35
|
children: []
|
|
36
36
|
};
|
|
@@ -38,142 +38,142 @@ function G(t) {
|
|
|
38
38
|
if (a.nodeType === 3) {
|
|
39
39
|
const r = a.textContent ?? "";
|
|
40
40
|
e.text += r, e.children.push({ text: r, children: [] });
|
|
41
|
-
} else a.nodeType === 1 && e.children.push(
|
|
41
|
+
} else a.nodeType === 1 && e.children.push(j(a));
|
|
42
42
|
return e;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function Y(t, e, a = !1) {
|
|
45
45
|
let r = "";
|
|
46
|
-
const
|
|
46
|
+
const n = [];
|
|
47
47
|
let o = !1;
|
|
48
|
-
for (const
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
if (
|
|
52
|
-
const c =
|
|
53
|
-
r += c.text,
|
|
54
|
-
} else if (
|
|
55
|
-
const c =
|
|
56
|
-
|
|
57
|
-
startTimeMs:
|
|
58
|
-
durationMs:
|
|
48
|
+
for (const s of t) {
|
|
49
|
+
const i = a || s.role === "x-bg";
|
|
50
|
+
if (s.children.length > 0)
|
|
51
|
+
if (i && !a) {
|
|
52
|
+
const c = Y(s.children, e, !0);
|
|
53
|
+
r += c.text, n.push(...c.parts), c.isWordSynced && (o = !0);
|
|
54
|
+
} else if (s.begin !== void 0 && s.end !== void 0) {
|
|
55
|
+
const c = s.children.map((l) => l.text).join("") || s.text;
|
|
56
|
+
n.push({
|
|
57
|
+
startTimeMs: s.begin,
|
|
58
|
+
durationMs: s.end - s.begin,
|
|
59
59
|
words: c,
|
|
60
|
-
isBackground:
|
|
60
|
+
isBackground: i || void 0
|
|
61
61
|
}), r += c, o = !0;
|
|
62
62
|
} else {
|
|
63
|
-
const c =
|
|
64
|
-
r += c.text,
|
|
63
|
+
const c = Y(s.children, e, i);
|
|
64
|
+
r += c.text, n.push(...c.parts), c.isWordSynced && (o = !0);
|
|
65
65
|
}
|
|
66
|
-
else if (
|
|
67
|
-
if (r +=
|
|
68
|
-
|
|
69
|
-
startTimeMs:
|
|
70
|
-
durationMs:
|
|
71
|
-
words:
|
|
72
|
-
isBackground:
|
|
66
|
+
else if (s.text)
|
|
67
|
+
if (r += s.text, s.begin !== void 0 && s.end !== void 0)
|
|
68
|
+
n.push({
|
|
69
|
+
startTimeMs: s.begin,
|
|
70
|
+
durationMs: s.end - s.begin,
|
|
71
|
+
words: s.text,
|
|
72
|
+
isBackground: i || void 0
|
|
73
73
|
}), o = !0;
|
|
74
74
|
else {
|
|
75
|
-
const c =
|
|
76
|
-
|
|
75
|
+
const c = n[n.length - 1];
|
|
76
|
+
n.push({
|
|
77
77
|
startTimeMs: c ? c.startTimeMs + c.durationMs : e,
|
|
78
78
|
durationMs: 0,
|
|
79
|
-
words:
|
|
80
|
-
isBackground:
|
|
79
|
+
words: s.text,
|
|
80
|
+
isBackground: i || void 0
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
return o ? { parts:
|
|
84
|
+
return o ? { parts: n, text: r, isWordSynced: o } : { parts: [], text: r, isWordSynced: !1 };
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function ut(t, e, a) {
|
|
87
87
|
if (t.length === 0) return t;
|
|
88
|
-
const r = [],
|
|
89
|
-
startTimeMs:
|
|
88
|
+
const r = [], n = (i, c) => ({
|
|
89
|
+
startTimeMs: i,
|
|
90
90
|
durationMs: c,
|
|
91
91
|
words: "",
|
|
92
92
|
parts: [],
|
|
93
93
|
isInstrumental: !0
|
|
94
94
|
});
|
|
95
|
-
t[0].startTimeMs > a && r.push(
|
|
96
|
-
for (let
|
|
97
|
-
if (r.push(t[
|
|
98
|
-
const c = t[
|
|
99
|
-
|
|
95
|
+
t[0].startTimeMs > a && r.push(n(0, t[0].startTimeMs));
|
|
96
|
+
for (let i = 0; i < t.length; i++)
|
|
97
|
+
if (r.push(t[i]), i < t.length - 1) {
|
|
98
|
+
const c = t[i].startTimeMs + t[i].durationMs, l = t[i + 1].startTimeMs - c;
|
|
99
|
+
l > a && r.push(n(c, l));
|
|
100
100
|
}
|
|
101
|
-
const o = t[t.length - 1],
|
|
102
|
-
return e -
|
|
101
|
+
const o = t[t.length - 1], s = o.startTimeMs + o.durationMs;
|
|
102
|
+
return e - s > a && r.push(n(s, e - s)), r;
|
|
103
103
|
}
|
|
104
|
-
function
|
|
105
|
-
const a = t.replace(/\\"/g, '"'), r = new DOMParser().parseFromString(a, "text/xml"),
|
|
106
|
-
if (!
|
|
107
|
-
const
|
|
104
|
+
function mt(t, e = {}) {
|
|
105
|
+
const a = t.replace(/\\"/g, '"'), r = new DOMParser().parseFromString(a, "text/xml"), n = r.querySelector("tt"), o = (n ? k(n, "lang") : null) ?? void 0, s = r.querySelector("body");
|
|
106
|
+
if (!s) return { lyrics: [], isWordSynced: !1, language: o };
|
|
107
|
+
const i = s.getAttribute("dur"), c = i ? q(i) : 0, l = s.querySelectorAll("p"), u = /* @__PURE__ */ new Map();
|
|
108
108
|
let f = !1;
|
|
109
|
-
const m = /* @__PURE__ */ new Map(),
|
|
109
|
+
const m = /* @__PURE__ */ new Map(), p = [
|
|
110
110
|
...r.querySelectorAll("agent"),
|
|
111
111
|
...r.getElementsByTagNameNS("http://www.w3.org/ns/ttml#metadata", "agent")
|
|
112
112
|
];
|
|
113
|
-
let
|
|
114
|
-
for (const
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
for (const
|
|
119
|
-
const
|
|
120
|
-
(
|
|
121
|
-
),
|
|
122
|
-
|
|
113
|
+
let T = 0;
|
|
114
|
+
for (const A of p) {
|
|
115
|
+
const h = k(A, "id"), _ = k(A, "type");
|
|
116
|
+
h && (m.has(h) || (_ === "person" || _ === "character" ? (T++, m.set(h, `v${T}`)) : m.set(h, "v1000")));
|
|
117
|
+
}
|
|
118
|
+
for (const A of l) {
|
|
119
|
+
const h = q(k(A, "begin") ?? void 0), _ = q(k(A, "end") ?? void 0), L = k(A, "key") ?? String(u.size), x = k(A, "agent") ?? void 0, y = x ? m.get(x) ?? x : void 0, S = Array.from(A.childNodes).filter((g) => g.nodeType === 1 || g.nodeType === 3).map(
|
|
120
|
+
(g) => g.nodeType === 1 ? j(g) : { text: g.textContent ?? "", children: [] }
|
|
121
|
+
), d = Y(S, h);
|
|
122
|
+
d.isWordSynced && (f = !0), u.set(L, {
|
|
123
123
|
agent: y,
|
|
124
|
-
durationMs: _ -
|
|
125
|
-
parts:
|
|
126
|
-
startTimeMs:
|
|
127
|
-
words:
|
|
128
|
-
key:
|
|
124
|
+
durationMs: _ - h,
|
|
125
|
+
parts: d.parts,
|
|
126
|
+
startTimeMs: h,
|
|
127
|
+
words: d.text,
|
|
128
|
+
key: L
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
const
|
|
132
|
-
for (const
|
|
133
|
-
const
|
|
134
|
-
if (!
|
|
135
|
-
const _ =
|
|
136
|
-
for (const
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
139
|
-
const
|
|
140
|
-
|
|
131
|
+
const b = r.querySelectorAll("translations");
|
|
132
|
+
for (const A of b) {
|
|
133
|
+
const h = A.getAttribute("lang");
|
|
134
|
+
if (!h) continue;
|
|
135
|
+
const _ = A.querySelectorAll("translation");
|
|
136
|
+
for (const L of _) {
|
|
137
|
+
const x = L.getAttribute("for"), y = L.querySelector("text"), S = y == null ? void 0 : y.textContent;
|
|
138
|
+
if (x && S) {
|
|
139
|
+
const d = u.get(x);
|
|
140
|
+
d && (d.translation = { text: S, lang: h });
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
const v = r.querySelectorAll("transliterations");
|
|
145
|
-
for (const
|
|
146
|
-
const
|
|
147
|
-
for (const _ of
|
|
148
|
-
const
|
|
149
|
-
if (!
|
|
150
|
-
const
|
|
151
|
-
if (!
|
|
145
|
+
for (const A of v) {
|
|
146
|
+
const h = A.querySelectorAll("transliteration");
|
|
147
|
+
for (const _ of h) {
|
|
148
|
+
const L = _.getAttribute("for");
|
|
149
|
+
if (!L) continue;
|
|
150
|
+
const x = u.get(L);
|
|
151
|
+
if (!x) continue;
|
|
152
152
|
const y = _.querySelectorAll("text");
|
|
153
153
|
let S = "";
|
|
154
|
-
const
|
|
155
|
-
for (const
|
|
156
|
-
const
|
|
157
|
-
(
|
|
158
|
-
),
|
|
159
|
-
S +=
|
|
154
|
+
const d = [];
|
|
155
|
+
for (const g of y) {
|
|
156
|
+
const P = Array.from(g.childNodes).filter((w) => w.nodeType === 1 || w.nodeType === 3).map(
|
|
157
|
+
(w) => w.nodeType === 1 ? j(w) : { text: w.textContent ?? "", children: [] }
|
|
158
|
+
), C = Y(P, x.startTimeMs);
|
|
159
|
+
S += C.text, d.push(...C.parts);
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
x.romanization = S, d.length > 0 && (x.timedRomanization = d);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
let
|
|
165
|
-
const
|
|
166
|
-
return c > 0 && (
|
|
164
|
+
let R = Array.from(u.values());
|
|
165
|
+
const M = e.instrumentalGapMs ?? 5e3;
|
|
166
|
+
return c > 0 && (R = ut(R, c, M)), { lyrics: R, isWordSynced: f, language: o };
|
|
167
167
|
}
|
|
168
|
-
const
|
|
168
|
+
const ft = {
|
|
169
169
|
detect(t) {
|
|
170
170
|
return t.includes("<tt") && t.includes("</tt>");
|
|
171
171
|
},
|
|
172
172
|
parse(t, e = 0) {
|
|
173
|
-
return
|
|
173
|
+
return mt(t).lyrics;
|
|
174
174
|
}
|
|
175
|
-
},
|
|
176
|
-
function
|
|
175
|
+
}, pt = ["ti", "ar", "al", "au", "lr", "length", "by", "offset", "re", "tool", "ve", "#"];
|
|
176
|
+
function tt(t) {
|
|
177
177
|
if (!t) return 0;
|
|
178
178
|
if (typeof t == "number") return t;
|
|
179
179
|
const e = t.split(":");
|
|
@@ -182,146 +182,146 @@ function K(t) {
|
|
|
182
182
|
if (e.length === 1)
|
|
183
183
|
a = Number.parseFloat(e[0]) * 1e3;
|
|
184
184
|
else if (e.length === 2) {
|
|
185
|
-
const r = Number.parseInt(e[0], 10),
|
|
186
|
-
a = r * 60 * 1e3 +
|
|
185
|
+
const r = Number.parseInt(e[0], 10), n = Number.parseFloat(e[1]);
|
|
186
|
+
a = r * 60 * 1e3 + n * 1e3;
|
|
187
187
|
} else if (e.length === 3) {
|
|
188
|
-
const r = Number.parseInt(e[0], 10),
|
|
189
|
-
a = r * 3600 * 1e3 +
|
|
188
|
+
const r = Number.parseInt(e[0], 10), n = Number.parseInt(e[1], 10), o = Number.parseFloat(e[2]);
|
|
189
|
+
a = r * 3600 * 1e3 + n * 60 * 1e3 + o * 1e3;
|
|
190
190
|
}
|
|
191
191
|
return Math.round(a);
|
|
192
192
|
} catch {
|
|
193
193
|
return 0;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function ht(t, e) {
|
|
197
197
|
var a;
|
|
198
198
|
const r = t.split(`
|
|
199
|
-
`),
|
|
200
|
-
for (const
|
|
201
|
-
const
|
|
202
|
-
if (c &&
|
|
199
|
+
`), n = [], o = {};
|
|
200
|
+
for (const s of r) {
|
|
201
|
+
const i = s.trim(), c = i.match(/^\[(\w+):(.*)\]$/);
|
|
202
|
+
if (c && pt.includes(c[1])) {
|
|
203
203
|
o[c[1]] = c[2];
|
|
204
204
|
continue;
|
|
205
205
|
}
|
|
206
|
-
const
|
|
207
|
-
for (const
|
|
208
|
-
f.push(
|
|
206
|
+
const l = /\[(\d+:\d+\.\d+)\]/g, u = /<(\d+:\d+\.\d+)>/g, f = [];
|
|
207
|
+
for (const M of i.matchAll(l))
|
|
208
|
+
f.push(tt(M[1]));
|
|
209
209
|
if (f.length === 0) continue;
|
|
210
|
-
const m =
|
|
211
|
-
let
|
|
212
|
-
m.split(
|
|
213
|
-
if (
|
|
214
|
-
let
|
|
215
|
-
|
|
210
|
+
const m = i.replace(l, "").trim(), p = [];
|
|
211
|
+
let T = null, b = "";
|
|
212
|
+
m.split(u).forEach((M, A) => {
|
|
213
|
+
if (A % 2 === 0) {
|
|
214
|
+
let h = M;
|
|
215
|
+
h.length > 0 && h[0] === " " && (h = h.substring(1)), h.length > 0 && h[h.length - 1] === " " && (h = h.substring(0, h.length - 1)), b += h, p.length > 0 && p[p.length - 1].startTimeMs && (p[p.length - 1].words += h);
|
|
216
216
|
} else {
|
|
217
|
-
const
|
|
218
|
-
|
|
217
|
+
const h = tt(M);
|
|
218
|
+
T !== null && p.length > 0 && (p[p.length - 1].durationMs = h - T), p.push({ startTimeMs: h, words: "", durationMs: 0 }), T = h;
|
|
219
219
|
}
|
|
220
220
|
});
|
|
221
|
-
const v = Math.min(...f),
|
|
222
|
-
|
|
221
|
+
const v = Math.min(...f), R = Math.max(...f) - v;
|
|
222
|
+
n.push({
|
|
223
223
|
startTimeMs: v,
|
|
224
|
-
words:
|
|
225
|
-
durationMs:
|
|
226
|
-
parts:
|
|
224
|
+
words: b.trim(),
|
|
225
|
+
durationMs: R,
|
|
226
|
+
parts: p.length > 0 ? p : void 0
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
|
-
for (let
|
|
230
|
-
const
|
|
231
|
-
if (
|
|
232
|
-
const c =
|
|
233
|
-
if (
|
|
234
|
-
let
|
|
235
|
-
for (const f of
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
|
|
229
|
+
for (let s = 0; s < n.length; s++) {
|
|
230
|
+
const i = n[s];
|
|
231
|
+
if (s + 1 < n.length) {
|
|
232
|
+
const c = n[s + 1];
|
|
233
|
+
if (i.durationMs === 0 && (i.durationMs = Math.max(c.startTimeMs - i.startTimeMs, 0)), i.parts && i.parts.length > 0) {
|
|
234
|
+
let l = c.startTimeMs;
|
|
235
|
+
for (const f of i.parts)
|
|
236
|
+
l = Math.max(l, f.startTimeMs);
|
|
237
|
+
const u = i.parts[i.parts.length - 1];
|
|
238
|
+
u.durationMs = Math.max(c.startTimeMs - u.startTimeMs, 0), i.durationMs = Math.max(l - i.startTimeMs, 0);
|
|
239
239
|
}
|
|
240
|
-
} else if (
|
|
241
|
-
const c =
|
|
240
|
+
} else if (i.durationMs === 0 && (i.durationMs = e - i.startTimeMs), i.parts && i.parts.length > 0) {
|
|
241
|
+
const c = i.parts[i.parts.length - 1];
|
|
242
242
|
c.durationMs = e - c.startTimeMs;
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
if (o.offset) {
|
|
246
|
-
let
|
|
247
|
-
Number.isNaN(
|
|
248
|
-
for (const
|
|
249
|
-
|
|
250
|
-
c.startTimeMs -=
|
|
246
|
+
let s = Number(o.offset);
|
|
247
|
+
Number.isNaN(s) && (s = 0), s = s * 1e3;
|
|
248
|
+
for (const i of n)
|
|
249
|
+
i.startTimeMs -= s, (a = i.parts) == null || a.forEach((c) => {
|
|
250
|
+
c.startTimeMs -= s;
|
|
251
251
|
});
|
|
252
252
|
}
|
|
253
|
-
return
|
|
253
|
+
return n;
|
|
254
254
|
}
|
|
255
|
-
function
|
|
255
|
+
function bt(t) {
|
|
256
256
|
for (const r of t)
|
|
257
257
|
if (r.parts)
|
|
258
|
-
for (let
|
|
259
|
-
const o = r.parts[
|
|
260
|
-
if (o.words === " " &&
|
|
261
|
-
const
|
|
262
|
-
if (Math.abs(
|
|
258
|
+
for (let n = 1; n < r.parts.length; n++) {
|
|
259
|
+
const o = r.parts[n], s = r.parts[n - 1];
|
|
260
|
+
if (o.words === " " && s.words !== " ") {
|
|
261
|
+
const i = o.durationMs - s.durationMs;
|
|
262
|
+
if (Math.abs(i) <= 15 || o.durationMs <= 100) {
|
|
263
263
|
const c = o.durationMs;
|
|
264
|
-
|
|
264
|
+
s.durationMs += c, o.durationMs -= c, o.startTimeMs += c;
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
let e = 0, a = 0;
|
|
269
269
|
for (const r of t)
|
|
270
270
|
if (!(!r.parts || r.parts.length === 0))
|
|
271
|
-
for (let
|
|
272
|
-
const o = r.parts[
|
|
271
|
+
for (let n = 0; n < r.parts.length - 2; n++) {
|
|
272
|
+
const o = r.parts[n];
|
|
273
273
|
o.words !== " " && (o.durationMs <= 100 && e++, a++);
|
|
274
274
|
}
|
|
275
275
|
if (a > 0 && e / a > 0.5)
|
|
276
276
|
for (let r = 0; r < t.length; r++) {
|
|
277
|
-
const
|
|
278
|
-
if (!(!
|
|
279
|
-
for (let o = 0; o <
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
282
|
-
let
|
|
283
|
-
o + 1 <
|
|
277
|
+
const n = t[r];
|
|
278
|
+
if (!(!n.parts || n.parts.length === 0))
|
|
279
|
+
for (let o = 0; o < n.parts.length; o++) {
|
|
280
|
+
const s = n.parts[o];
|
|
281
|
+
if (s.words !== " " && s.durationMs <= 400) {
|
|
282
|
+
let i = null;
|
|
283
|
+
o + 1 < n.parts.length ? i = n.parts[o + 1] : r + 1 < t.length && t[r + 1].parts && t[r + 1].parts.length > 0 && (i = t[r + 1].parts[0]), i === null ? s.durationMs = 300 : i.words === " " ? (s.durationMs += i.durationMs, i.startTimeMs += i.durationMs, i.durationMs = 0) : s.durationMs = i.startTimeMs - s.startTimeMs;
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
|
-
const
|
|
288
|
+
const gt = {
|
|
289
289
|
detect(t) {
|
|
290
290
|
return /\[\d+:\d+\.\d+\]/.test(t);
|
|
291
291
|
},
|
|
292
292
|
parse(t, e = 0) {
|
|
293
|
-
const a =
|
|
294
|
-
return
|
|
293
|
+
const a = ht(t, e);
|
|
294
|
+
return bt(a), a;
|
|
295
295
|
}
|
|
296
296
|
};
|
|
297
|
-
function
|
|
297
|
+
function et(t) {
|
|
298
298
|
const e = t.trim().match(/^(\d+):(\d+):(\d+)[,.](\d+)$/);
|
|
299
299
|
if (!e) return 0;
|
|
300
|
-
const a = Number.parseInt(e[1], 10), r = Number.parseInt(e[2], 10),
|
|
301
|
-
return a * 36e5 + r * 6e4 +
|
|
300
|
+
const a = Number.parseInt(e[1], 10), r = Number.parseInt(e[2], 10), n = Number.parseInt(e[3], 10), o = Number.parseInt(e[4].padEnd(3, "0").slice(0, 3), 10);
|
|
301
|
+
return a * 36e5 + r * 6e4 + n * 1e3 + o;
|
|
302
302
|
}
|
|
303
|
-
const
|
|
303
|
+
const yt = {
|
|
304
304
|
detect(t) {
|
|
305
305
|
return /\d+\r?\n\d{2}:\d{2}:\d{2}[,.]\d+ --> \d{2}:\d{2}:\d{2}[,.]\d+/.test(t);
|
|
306
306
|
},
|
|
307
307
|
parse(t, e = 0) {
|
|
308
308
|
const a = t.trim().split(/\r?\n\r?\n/), r = [];
|
|
309
|
-
for (const
|
|
310
|
-
const o =
|
|
309
|
+
for (const n of a) {
|
|
310
|
+
const o = n.split(/\r?\n/);
|
|
311
311
|
if (o.length < 2) continue;
|
|
312
|
-
const
|
|
313
|
-
if (!
|
|
314
|
-
const [
|
|
312
|
+
const s = o.find((p) => p.includes("-->"));
|
|
313
|
+
if (!s) continue;
|
|
314
|
+
const [i, c] = s.split("-->").map((p) => p.trim()), l = et(i), u = et(c), f = o.indexOf(s), m = o.slice(f + 1).join(`
|
|
315
315
|
`).replace(/<[^>]+>/g, "").trim();
|
|
316
316
|
m && r.push({
|
|
317
|
-
startTimeMs:
|
|
317
|
+
startTimeMs: l,
|
|
318
318
|
words: m,
|
|
319
|
-
durationMs:
|
|
319
|
+
durationMs: u - l
|
|
320
320
|
});
|
|
321
321
|
}
|
|
322
322
|
return r;
|
|
323
323
|
}
|
|
324
|
-
},
|
|
324
|
+
}, ct = {
|
|
325
325
|
detect(t) {
|
|
326
326
|
return !0;
|
|
327
327
|
},
|
|
@@ -333,40 +333,40 @@ const ht = {
|
|
|
333
333
|
durationMs: 0
|
|
334
334
|
}));
|
|
335
335
|
}
|
|
336
|
-
},
|
|
336
|
+
}, St = {
|
|
337
337
|
detect(t) {
|
|
338
338
|
return /\[\d+,\d+\]/.test(t) && /\(\d+,\d+\)/.test(t);
|
|
339
339
|
},
|
|
340
340
|
parse(t, e = 0) {
|
|
341
341
|
const a = t.split(`
|
|
342
342
|
`), r = [];
|
|
343
|
-
for (const
|
|
344
|
-
const o =
|
|
343
|
+
for (const n of a) {
|
|
344
|
+
const o = n.trim().match(/^\[(\d+),(\d+)\](.*)$/);
|
|
345
345
|
if (!o) continue;
|
|
346
|
-
const
|
|
347
|
-
let
|
|
346
|
+
const s = Number.parseInt(o[1], 10), i = Number.parseInt(o[2], 10), c = o[3], l = [];
|
|
347
|
+
let u = "";
|
|
348
348
|
const f = /([^(]*)\((\d+),(\d+)\)/g;
|
|
349
349
|
for (const m of c.matchAll(f)) {
|
|
350
|
-
const
|
|
351
|
-
|
|
350
|
+
const p = m[1], T = Number.parseInt(m[2], 10), b = Number.parseInt(m[3], 10);
|
|
351
|
+
u += p, l.push({ startTimeMs: T, words: p, durationMs: b });
|
|
352
352
|
}
|
|
353
353
|
r.push({
|
|
354
|
-
startTimeMs:
|
|
355
|
-
words:
|
|
356
|
-
durationMs:
|
|
357
|
-
parts:
|
|
354
|
+
startTimeMs: s,
|
|
355
|
+
words: u,
|
|
356
|
+
durationMs: i,
|
|
357
|
+
parts: l.length > 0 ? l : void 0
|
|
358
358
|
});
|
|
359
359
|
}
|
|
360
360
|
return r;
|
|
361
361
|
}
|
|
362
|
-
},
|
|
363
|
-
function
|
|
364
|
-
for (const e of
|
|
362
|
+
}, vt = [ft, gt, yt, St, ct];
|
|
363
|
+
function wt(t) {
|
|
364
|
+
for (const e of vt)
|
|
365
365
|
if (e.detect(t)) return e;
|
|
366
|
-
return
|
|
366
|
+
return ct;
|
|
367
367
|
}
|
|
368
|
-
const
|
|
369
|
-
function
|
|
368
|
+
const Tt = 25e3;
|
|
369
|
+
function _t() {
|
|
370
370
|
return {
|
|
371
371
|
skipScrolls: 0,
|
|
372
372
|
skipScrollsDecayTimes: [],
|
|
@@ -378,38 +378,38 @@ function vt() {
|
|
|
378
378
|
queuedScroll: !1
|
|
379
379
|
};
|
|
380
380
|
}
|
|
381
|
-
function
|
|
381
|
+
function Mt(t) {
|
|
382
382
|
t.skipScrollsDecayTimes = [], t.doneFirstInstantScroll = !1, t.queuedScroll = !1;
|
|
383
383
|
}
|
|
384
|
-
function
|
|
385
|
-
t.wasUserScrolling = !0, t.scrollResumeTime = Date.now() +
|
|
384
|
+
function at(t) {
|
|
385
|
+
t.wasUserScrolling = !0, t.scrollResumeTime = Date.now() + Tt;
|
|
386
386
|
}
|
|
387
|
-
function
|
|
387
|
+
function rt(t) {
|
|
388
388
|
t.scrollResumeTime = 0;
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function At(t) {
|
|
391
391
|
return t.scrollResumeTime > Date.now();
|
|
392
392
|
}
|
|
393
|
-
function
|
|
393
|
+
function Ct(t, e) {
|
|
394
394
|
let a = 0;
|
|
395
395
|
for (; a < t.skipScrollsDecayTimes.length && !(t.skipScrollsDecayTimes[a] > e); a++)
|
|
396
396
|
;
|
|
397
397
|
t.skipScrollsDecayTimes = t.skipScrollsDecayTimes.slice(a), t.skipScrolls -= a, t.skipScrolls < 1 && (t.skipScrolls = 1);
|
|
398
398
|
}
|
|
399
|
-
const
|
|
400
|
-
function
|
|
399
|
+
const B = "braccato--animating", G = "braccato--pre-animating", U = "braccato--paused", nt = "braccato--active", Et = "braccato--user-scrolling", Lt = 0.5, xt = 0.5, Nt = 0.62, kt = 0.37, It = 150, H = /* @__PURE__ */ new Map();
|
|
400
|
+
function Dt(t) {
|
|
401
401
|
return t ? t.endsWith("ms") ? Number.parseFloat(t.slice(0, -2)) : t.endsWith("s") ? Number.parseFloat(t.slice(0, -1)) * 1e3 : 0 : 0;
|
|
402
402
|
}
|
|
403
403
|
function W(t, e) {
|
|
404
|
-
let a =
|
|
405
|
-
return a === void 0 && (a =
|
|
404
|
+
let a = H.get(e);
|
|
405
|
+
return a === void 0 && (a = Dt(getComputedStyle(t).getPropertyValue(e)), H.set(e, a)), a;
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function it(t) {
|
|
408
408
|
t.offsetHeight;
|
|
409
409
|
}
|
|
410
|
-
function
|
|
410
|
+
function Rt() {
|
|
411
411
|
return {
|
|
412
|
-
scroll:
|
|
412
|
+
scroll: _t(),
|
|
413
413
|
selectedElementIndex: 0,
|
|
414
414
|
lastTime: 0,
|
|
415
415
|
lastPlayState: !1,
|
|
@@ -417,149 +417,192 @@ function Dt() {
|
|
|
417
417
|
lastActiveElements: []
|
|
418
418
|
};
|
|
419
419
|
}
|
|
420
|
-
function
|
|
421
|
-
|
|
420
|
+
function Pt(t) {
|
|
421
|
+
Mt(t.scroll), t.lastActiveElements = [], H.clear();
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function zt(t, e) {
|
|
424
424
|
const a = Date.now();
|
|
425
|
-
let { currentTime: r, isPlaying:
|
|
425
|
+
let { currentTime: r, isPlaying: n, smoothScroll: o } = e;
|
|
426
426
|
const {
|
|
427
|
-
eventCreationTime:
|
|
428
|
-
lyricsData:
|
|
427
|
+
eventCreationTime: s,
|
|
428
|
+
lyricsData: i,
|
|
429
429
|
scrollContainer: c,
|
|
430
|
-
scrollPosRatio:
|
|
431
|
-
endingThreshold:
|
|
432
|
-
earlyScrollConsider: f =
|
|
433
|
-
queueScrollMs: m =
|
|
430
|
+
scrollPosRatio: l = kt,
|
|
431
|
+
endingThreshold: u = xt,
|
|
432
|
+
earlyScrollConsider: f = Nt,
|
|
433
|
+
queueScrollMs: m = It
|
|
434
434
|
} = e;
|
|
435
|
-
if (r === 0 && !
|
|
436
|
-
const
|
|
437
|
-
t.lastTime = r, t.lastPlayState =
|
|
438
|
-
const
|
|
439
|
-
r +=
|
|
440
|
-
const { lines:
|
|
441
|
-
|
|
442
|
-
const
|
|
443
|
-
let
|
|
444
|
-
const _ = [],
|
|
445
|
-
let
|
|
446
|
-
for (let S = 0; S <
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
const
|
|
450
|
-
if (r +
|
|
451
|
-
|
|
452
|
-
const
|
|
453
|
-
if (
|
|
454
|
-
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
457
|
-
for (const
|
|
458
|
-
|
|
459
|
-
|
|
435
|
+
if (r === 0 && !n) return;
|
|
436
|
+
const p = Math.abs(r - t.lastTime - (s - t.lastEventCreationTime) / 1e3) > Lt;
|
|
437
|
+
t.lastTime = r, t.lastPlayState = n, t.lastEventCreationTime = s;
|
|
438
|
+
const T = n ? a - s : 0;
|
|
439
|
+
r += T / 1e3;
|
|
440
|
+
const { lines: b, container: v, syncType: R } = i;
|
|
441
|
+
R === "richsync" ? r += W(v, "--braccato-richsync-timing-offset") / 1e3 : r += W(v, "--braccato-timing-offset") / 1e3;
|
|
442
|
+
const M = r + W(v, "--braccato-scroll-timing-offset") / 1e3, A = c.getBoundingClientRect().height;
|
|
443
|
+
let h = c.scrollTop;
|
|
444
|
+
const _ = [], L = [];
|
|
445
|
+
let x = p;
|
|
446
|
+
for (let S = 0; S < b.length; S++) {
|
|
447
|
+
const d = b[S], g = d.time, P = S + 1 < b.length ? b[S + 1].time : Number.POSITIVE_INFINITY;
|
|
448
|
+
M >= g - f && (M < P || M < g + d.duration) ? (_.push(d), !t.lastActiveElements.includes(d) && M >= g && (x = !0), t.selectedElementIndex = S, d.isScrolled || (d.element.classList.add(nt), d.isScrolled = !0)) : d.isScrolled && (d.element.classList.remove(nt), d.isScrolled = !1);
|
|
449
|
+
const C = n ? 2 : 0, w = Math.max(P, g + d.duration + 0.05);
|
|
450
|
+
if (r + C >= g && r < w) {
|
|
451
|
+
d.isSelected = !0;
|
|
452
|
+
const O = r - g, z = (a - d.animationStartTimeMs) / 1e3 - O;
|
|
453
|
+
if (d.accumulatedOffsetMs = d.accumulatedOffsetMs / 1.08, d.accumulatedOffsetMs += z * 1e3 * 0.4, d.isAnimating && Math.abs(d.accumulatedOffsetMs) > 100 && n && (d.isAnimating = !1), n !== d.isAnimationPlayStatePlaying) {
|
|
454
|
+
d.isAnimationPlayStatePlaying = n;
|
|
455
|
+
const K = [d, ...d.parts];
|
|
456
|
+
if (n) {
|
|
457
|
+
for (const F of K)
|
|
458
|
+
F.element.classList.remove(U);
|
|
459
|
+
d.isAnimating = !1;
|
|
460
460
|
} else
|
|
461
|
-
for (const
|
|
462
|
-
|
|
461
|
+
for (const F of K)
|
|
462
|
+
F.animationStartTimeMs > a ? (F.element.classList.remove(B), F.element.classList.remove(G)) : F.element.classList.add(U);
|
|
463
463
|
}
|
|
464
|
-
|
|
465
|
-
} else if (
|
|
466
|
-
const
|
|
467
|
-
for (const
|
|
468
|
-
|
|
469
|
-
|
|
464
|
+
d.isAnimating || L.push(d);
|
|
465
|
+
} else if (d.isSelected) {
|
|
466
|
+
const O = [d, ...d.parts];
|
|
467
|
+
for (const z of O)
|
|
468
|
+
z.element.style.setProperty("--braccato-swipe-delay", ""), z.element.style.setProperty("--braccato-anim-delay", ""), z.element.classList.remove(B), z.element.classList.remove(G), z.element.classList.remove(U), z.animationStartTimeMs = Number.POSITIVE_INFINITY;
|
|
469
|
+
d.isSelected = !1, d.isAnimating = !1;
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
|
-
if (
|
|
473
|
-
for (const S of
|
|
474
|
-
const
|
|
475
|
-
for (const
|
|
476
|
-
const
|
|
477
|
-
|
|
472
|
+
if (L.length > 0) {
|
|
473
|
+
for (const S of L) {
|
|
474
|
+
const d = [S, ...S.parts];
|
|
475
|
+
for (const g of d) {
|
|
476
|
+
const P = r - g.time;
|
|
477
|
+
g.element.classList.remove(B), g.element.classList.remove(U), g.element.style.setProperty("--braccato-swipe-delay", `${-P - g.duration * 0.1}s`), g.element.style.setProperty("--braccato-anim-delay", `${-P}s`), g.element.classList.add(G);
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
|
-
|
|
481
|
-
for (const S of
|
|
482
|
-
const
|
|
483
|
-
for (const
|
|
484
|
-
const
|
|
485
|
-
|
|
480
|
+
it(L[0].element);
|
|
481
|
+
for (const S of L) {
|
|
482
|
+
const d = [S, ...S.parts];
|
|
483
|
+
for (const g of d) {
|
|
484
|
+
const P = r - g.time;
|
|
485
|
+
g.element.classList.add(B), g.animationStartTimeMs = a - P * 1e3;
|
|
486
486
|
}
|
|
487
487
|
S.isAnimating = !0, S.lastAnimSetupAt = a, S.isAnimationPlayStatePlaying = !0, S.accumulatedOffsetMs = 0;
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
490
|
const y = t.scroll;
|
|
491
491
|
if (y.scrollResumeTime < a || y.scrollPos === -1) {
|
|
492
|
-
_.length === 0 && _.push(
|
|
493
|
-
const S =
|
|
494
|
-
let
|
|
495
|
-
if (
|
|
492
|
+
_.length === 0 && _.push(b[0]), t.lastActiveElements = _.filter((w) => M >= w.time);
|
|
493
|
+
const S = A * l, d = _[_.length - 1], g = _.filter((w, O) => M < w.time + w.duration - u || O === _.length - 1).map((w) => w.position + w.height / 2);
|
|
494
|
+
let C = g.reduce((w, O) => w + O, 0) / g.length - S;
|
|
495
|
+
if (C = Math.min(C, _[0].position), C = Math.max(C, d.position - A + d.height), C = Math.min(C, d.position), C = Math.max(0, C), h === 0 && !y.doneFirstInstantScroll && (o = !1, y.doneFirstInstantScroll = !0, y.nextScrollAllowedTime = 0), y.wasUserScrolling || x || y.queuedScroll)
|
|
496
496
|
if (a > y.nextScrollAllowedTime) {
|
|
497
|
-
if (y.queuedScroll = !1, o && Math.abs(
|
|
497
|
+
if (y.queuedScroll = !1, o && Math.abs(h - C) > 2) {
|
|
498
498
|
v.style.transitionTimingFunction = "", v.style.transitionProperty = "", v.style.transitionDuration = "";
|
|
499
|
-
const
|
|
500
|
-
v.style.transition = "none", v.style.transform = `translate(0px, ${-(
|
|
499
|
+
const w = W(v, "transition-duration");
|
|
500
|
+
v.style.transition = "none", v.style.transform = `translate(0px, ${-(h - C)}px)`, it(v), v.style.transition = "", v.style.transform = "translate(0px, 0px)", y.nextScrollAllowedTime = w + a + 20;
|
|
501
501
|
}
|
|
502
|
-
|
|
503
|
-
} else (y.nextScrollAllowedTime - a < m ||
|
|
502
|
+
h = C, y.scrollPos = h, c.scrollTop = h, y.skipScrolls += 1, y.skipScrollsDecayTimes.push(a + 2e3);
|
|
503
|
+
} else (y.nextScrollAllowedTime - a < m || p) && (y.queuedScroll = !0);
|
|
504
504
|
}
|
|
505
|
-
y.wasUserScrolling && y.scrollResumeTime < a && (v.classList.remove(
|
|
505
|
+
y.wasUserScrolling && y.scrollResumeTime < a && (v.classList.remove(Et), y.wasUserScrolling = !1), Ct(y, a);
|
|
506
506
|
}
|
|
507
|
-
const
|
|
508
|
-
function
|
|
509
|
-
|
|
507
|
+
const N = "http://www.w3.org/2000/svg", Ot = "braccato--instrumental", Ft = "braccato--instrumental-icon", qt = "braccato--instrumental-bg", Bt = "braccato--instrumental-fill", Ut = "braccato--wave-clip", Wt = "braccato--wave-rect", $t = "braccato--wave-path", st = "M10 21q-1.65 0-2.825-1.175T6 17t1.175-2.825T10 13q.575 0 1.063.138t.937.412V4q0-.425.288-.712T13 3h4q.425 0 .713.288T18 4v2q0 .425-.288.713T17 7h-3v10q0 1.65-1.175 2.825T10 21";
|
|
508
|
+
function Yt(t, e) {
|
|
509
|
+
const a = document.createElement("div");
|
|
510
|
+
a.classList.add(Ot), a.style.setProperty("--braccato-duration", `${t}ms`);
|
|
511
|
+
const r = document.createElementNS(N, "svg");
|
|
512
|
+
r.classList.add(Ft), r.setAttribute("viewBox", "0 0 24 24");
|
|
513
|
+
const n = document.createElementNS(N, "defs"), o = `braccato-glow-${e}`, s = `braccato-wave-clip-${e}`, i = document.createElementNS(N, "filter");
|
|
514
|
+
i.setAttribute("id", o), i.setAttribute("x", "-100%"), i.setAttribute("y", "-100%"), i.setAttribute("width", "300%"), i.setAttribute("height", "300%");
|
|
515
|
+
const c = document.createElementNS(N, "feGaussianBlur");
|
|
516
|
+
c.setAttribute("in", "SourceGraphic"), c.setAttribute("stdDeviation", "5"), c.setAttribute("result", "blur"), i.appendChild(c);
|
|
517
|
+
const l = document.createElementNS(N, "feColorMatrix");
|
|
518
|
+
l.setAttribute("in", "blur"), l.setAttribute("type", "matrix"), l.setAttribute("values", "1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.6 0"), l.setAttribute("result", "fadedBlur"), i.appendChild(l);
|
|
519
|
+
const u = document.createElementNS(N, "feMerge"), f = document.createElementNS(N, "feMergeNode");
|
|
520
|
+
f.setAttribute("in", "fadedBlur"), u.appendChild(f);
|
|
521
|
+
const m = document.createElementNS(N, "feMergeNode");
|
|
522
|
+
m.setAttribute("in", "SourceGraphic"), u.appendChild(m), i.appendChild(u), n.appendChild(i);
|
|
523
|
+
const p = document.createElementNS(N, "clipPath");
|
|
524
|
+
p.setAttribute("id", s), p.classList.add(Ut);
|
|
525
|
+
const T = document.createElementNS(N, "path");
|
|
526
|
+
T.classList.add(Wt), T.setAttribute("d", "M -4 3.9 L 30 3.9 L 30 30 L -4 30 Z"), p.appendChild(T);
|
|
527
|
+
const b = document.createElementNS(N, "path");
|
|
528
|
+
b.classList.add($t), b.setAttribute("d", "M -4 3 Q 1 2 5 3 Q 10 4 14 3 Q 18 2 22 3 Q 26 4 30 3 L 30 4 L -4 4 Z"), p.appendChild(b), n.appendChild(p), r.appendChild(n);
|
|
529
|
+
const v = document.createElementNS(N, "path");
|
|
530
|
+
v.classList.add(qt), v.setAttribute("d", st), r.appendChild(v);
|
|
531
|
+
const R = document.createElementNS(N, "g");
|
|
532
|
+
R.setAttribute("filter", `url(#${o})`);
|
|
533
|
+
const M = document.createElementNS(N, "path");
|
|
534
|
+
return M.classList.add(Bt), M.setAttribute("clip-path", `url(#${s})`), M.setAttribute("d", st), R.appendChild(M), r.appendChild(R), a.appendChild(r), a;
|
|
510
535
|
}
|
|
511
|
-
const
|
|
512
|
-
function
|
|
536
|
+
const Gt = /[\p{Script=Arabic}\p{Script=Hebrew}\p{Script=Syriac}\p{Script=Thaana}]/u;
|
|
537
|
+
function V(t) {
|
|
538
|
+
return Gt.test(t);
|
|
539
|
+
}
|
|
540
|
+
const Qt = "braccato--line", jt = "braccato--word", Ht = "braccato--break", $ = "braccato-background-lyric", Z = "braccato-rtl", Vt = "braccato-zero-dur-animate", Zt = "braccato--romanized", Jt = "braccato--translated";
|
|
541
|
+
function Kt(t, e) {
|
|
542
|
+
for (let a = e - 1; a >= 0; a--)
|
|
543
|
+
if (!t[a].isInstrumental && t[a].agent) return t[a].agent;
|
|
544
|
+
for (let a = e + 1; a < t.length; a++)
|
|
545
|
+
if (!t[a].isInstrumental && t[a].agent) return t[a].agent;
|
|
546
|
+
}
|
|
547
|
+
function Xt(t, e) {
|
|
548
|
+
var a, r;
|
|
549
|
+
for (let n = e - 1; n >= 0; n--)
|
|
550
|
+
if (!t[n].isInstrumental && ((a = t[n].words) != null && a.trim())) return V(t[n].words);
|
|
551
|
+
for (let n = e + 1; n < t.length; n++)
|
|
552
|
+
if (!t[n].isInstrumental && ((r = t[n].words) != null && r.trim())) return V(t[n].words);
|
|
553
|
+
return !1;
|
|
554
|
+
}
|
|
555
|
+
function Q(t, e) {
|
|
513
556
|
const a = document.createElement("span");
|
|
514
|
-
a.classList.add(
|
|
557
|
+
a.classList.add(Ht), a.style.order = String(e), t.appendChild(a);
|
|
515
558
|
}
|
|
516
|
-
function
|
|
559
|
+
function te(t, e) {
|
|
517
560
|
const a = /([\s\u200B\u00AD\p{Dash_Punctuation}])/gu;
|
|
518
|
-
let r = [],
|
|
561
|
+
let r = [], n = !1;
|
|
519
562
|
const o = () => {
|
|
520
563
|
if (r.length > 0) {
|
|
521
|
-
const
|
|
522
|
-
for (const
|
|
523
|
-
|
|
564
|
+
const s = document.createElement("span");
|
|
565
|
+
for (const i of r) s.appendChild(i);
|
|
566
|
+
n && s.classList.add($), t.appendChild(s), r = [];
|
|
524
567
|
}
|
|
525
568
|
};
|
|
526
|
-
for (const
|
|
527
|
-
const
|
|
528
|
-
|
|
569
|
+
for (const s of e) {
|
|
570
|
+
const i = n !== s.classList.contains($), c = !(s.textContent.length === 1 && s.textContent[0] === " ");
|
|
571
|
+
i || r.push(s), (s.textContent.length > 0 && a.test(s.textContent[s.textContent.length - 1]) || i) && o(), i && c && (r.push(s), n = s.classList.contains($));
|
|
529
572
|
}
|
|
530
573
|
o();
|
|
531
574
|
}
|
|
532
|
-
function
|
|
533
|
-
let
|
|
534
|
-
const
|
|
535
|
-
for (const
|
|
536
|
-
const c =
|
|
537
|
-
!c &&
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
const
|
|
541
|
-
time:
|
|
542
|
-
duration:
|
|
543
|
-
element:
|
|
575
|
+
function ot(t, e, a, r) {
|
|
576
|
+
let n = [], o = !0;
|
|
577
|
+
const s = [];
|
|
578
|
+
for (const i of t) {
|
|
579
|
+
const c = V(i.words);
|
|
580
|
+
!c && i.words.trim().length > 0 && (o = !1, n.reverse().forEach((f) => s.push(f)), n = []);
|
|
581
|
+
const l = document.createElement("span");
|
|
582
|
+
l.classList.add(jt), i.durationMs === 0 && l.classList.add(Vt), c && l.classList.add(Z);
|
|
583
|
+
const u = {
|
|
584
|
+
time: i.startTimeMs / 1e3,
|
|
585
|
+
duration: i.durationMs / 1e3,
|
|
586
|
+
element: l,
|
|
544
587
|
animationStartTimeMs: Number.POSITIVE_INFINITY
|
|
545
588
|
};
|
|
546
|
-
|
|
589
|
+
l.textContent = i.words, l.dataset.time = String(u.time), l.dataset.duration = String(u.duration), l.dataset.content = i.words, l.style.setProperty("--braccato-duration", `${i.durationMs}ms`), i.durationMs > r && (l.dataset.longWord = "true"), i.isBackground && l.classList.add($), i.words.trim().length === 0 && (l.style.display = "inline"), i.words.trim().length !== 0 && e.parts.push(u), c ? n.push(l) : s.push(l);
|
|
547
590
|
}
|
|
548
|
-
if (o &&
|
|
549
|
-
a.classList.add(
|
|
550
|
-
for (const
|
|
551
|
-
} else
|
|
552
|
-
|
|
591
|
+
if (o && n.length > 0) {
|
|
592
|
+
a.classList.add(Z);
|
|
593
|
+
for (const i of n) s.push(i);
|
|
594
|
+
} else n.length > 0 && n.reverse().forEach((i) => s.push(i));
|
|
595
|
+
te(a, s);
|
|
553
596
|
}
|
|
554
|
-
function
|
|
555
|
-
const { longWordThreshold: r = 1500, lineSyncedAnimationDelay:
|
|
597
|
+
function ee(t, e, a = {}) {
|
|
598
|
+
const { longWordThreshold: r = 1500, lineSyncedAnimationDelay: n = 50, disableRichsync: o = !1 } = a;
|
|
556
599
|
e.replaceChildren();
|
|
557
|
-
let
|
|
600
|
+
let i = t.every((u) => u.startTimeMs === 0) ? "none" : "synced";
|
|
558
601
|
const c = [];
|
|
559
|
-
for (let
|
|
560
|
-
const f = t[
|
|
561
|
-
m.classList.add(
|
|
562
|
-
const
|
|
602
|
+
for (let u = 0; u < t.length; u++) {
|
|
603
|
+
const f = t[u], m = f.isInstrumental ? Yt(f.durationMs, u) : document.createElement("div");
|
|
604
|
+
m.classList.add(Qt);
|
|
605
|
+
const p = {
|
|
563
606
|
element: m,
|
|
564
607
|
time: f.startTimeMs / 1e3,
|
|
565
608
|
duration: f.durationMs / 1e3,
|
|
@@ -575,45 +618,47 @@ function $t(t, e, a = {}) {
|
|
|
575
618
|
position: -1
|
|
576
619
|
};
|
|
577
620
|
if (f.isInstrumental) {
|
|
578
|
-
m.dataset.instrumental = "true", m.dataset.time = String(
|
|
621
|
+
m.dataset.instrumental = "true", m.dataset.time = String(p.time), m.dataset.duration = String(p.duration), m.dataset.lineNumber = String(u);
|
|
622
|
+
const b = Kt(t, u);
|
|
623
|
+
b && (m.dataset.agent = b), Xt(t, u) && m.classList.add(Z), c.push(p), e.appendChild(m);
|
|
579
624
|
continue;
|
|
580
625
|
}
|
|
581
|
-
let
|
|
582
|
-
if ((
|
|
583
|
-
startTimeMs: f.startTimeMs + v *
|
|
584
|
-
words:
|
|
626
|
+
let T = f.parts ?? [];
|
|
627
|
+
if ((T.length === 0 || o) && (T = f.words.split(" ").map((b, v) => ({
|
|
628
|
+
startTimeMs: f.startTimeMs + v * n,
|
|
629
|
+
words: b.trim().length < 1 ? b : `${b} `,
|
|
585
630
|
durationMs: 0
|
|
586
|
-
}))),
|
|
587
|
-
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
${f.romanization}`, m.appendChild(
|
|
631
|
+
}))), T.every((b) => b.durationMs === 0) || (i = "richsync"), ot(T, p, m, r), Q(m, 1), m.dataset.time = String(p.time), m.dataset.duration = String(p.duration), m.dataset.lineNumber = String(u), m.style.setProperty("--braccato-duration", `${f.durationMs}ms`), f.agent && (m.dataset.agent = f.agent), f.romanization) {
|
|
632
|
+
Q(m, 4);
|
|
633
|
+
const b = document.createElement("div");
|
|
634
|
+
b.classList.add(Zt), b.style.order = "5", f.timedRomanization && f.timedRomanization.length > 0 && !o ? ot(f.timedRomanization, p, b, r) : b.textContent = `
|
|
635
|
+
${f.romanization}`, m.appendChild(b);
|
|
591
636
|
}
|
|
592
637
|
if (f.translation) {
|
|
593
|
-
|
|
594
|
-
const
|
|
595
|
-
|
|
596
|
-
${f.translation.text}`, m.appendChild(
|
|
638
|
+
Q(m, 6);
|
|
639
|
+
const b = document.createElement("div");
|
|
640
|
+
b.classList.add(Jt), b.style.order = "7", b.textContent = `
|
|
641
|
+
${f.translation.text}`, m.appendChild(b);
|
|
597
642
|
}
|
|
598
|
-
c.push(
|
|
643
|
+
c.push(p), e.appendChild(m);
|
|
599
644
|
}
|
|
600
|
-
e.dataset.sync =
|
|
601
|
-
const
|
|
602
|
-
return
|
|
645
|
+
e.dataset.sync = i;
|
|
646
|
+
const l = document.createElement("div");
|
|
647
|
+
return l.className = "braccato--spacer", l.style.height = "100px", e.appendChild(l), {
|
|
603
648
|
lines: c,
|
|
604
|
-
syncType:
|
|
649
|
+
syncType: i,
|
|
605
650
|
width: e.clientWidth,
|
|
606
651
|
height: e.clientHeight,
|
|
607
652
|
container: e
|
|
608
653
|
};
|
|
609
654
|
}
|
|
610
|
-
const jt = ":host{display:block;overflow-y:auto;position:relative;container-type:size;scrollbar-width:none}:host::-webkit-scrollbar{display:none}:host(:has(.braccato--user-scrolling)){scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.15) transparent}:host(:has(.braccato--user-scrolling))::-webkit-scrollbar{display:block;width:6px}:host(:has(.braccato--user-scrolling))::-webkit-scrollbar-thumb{background:#ffffff26;border-radius:3px}:host(:has(.braccato--user-scrolling))::-webkit-scrollbar-track{background:transparent}.braccato-container{font-family:var(--braccato-font-family);font-size:var(--braccato-font-size);font-weight:var(--braccato-font-weight);isolation:isolate;line-height:var(--braccato-line-height);position:relative;z-index:1;transition:transform var(--braccato-scroll-duration) var(--braccato-scroll-timing-function) 0s;padding-top:2rem;padding-bottom:var(--braccato-padding-bottom)}.braccato-container>div{cursor:pointer;padding:var(--braccato-padding) 0;transform-origin:left center;word-break:break-word;transition:filter calc(var(--braccato-duration) / 3) .4s,opacity calc(var(--braccato-duration) / 2) .166s,transform .166s var(--braccato-anim-delay, 0s)}.braccato-container:has(.braccato--active):not(.braccato--user-scrolling)>div:not(.braccato--active):not(.braccato--active~div){opacity:.33;filter:blur(2.5px)}.braccato-container>div.braccato--active{opacity:1;filter:blur(0px)}.braccato-container>div.braccato--active~div{opacity:.66;filter:blur(0px)}.braccato-container>.braccato--animating{opacity:1!important;filter:blur(0px)!important}.braccato-container>div:hover{opacity:1!important;filter:blur(0px)!important;transform:scale(var(--braccato-hover-scale, 1.01));transition:all .3s ease}.braccato--active{cursor:default}:not(.braccato-background-lyric){order:0}.braccato-background-lyric{order:2}.braccato--line>span>span.braccato-background-lyric{font-size:.675em;font-weight:400}.braccato--line{transform:scale(var(--braccato-scale));transition-property:transform;transition-duration:var(--braccato-scale-transition-duration);transition-timing-function:ease;display:flex;flex-flow:row wrap;align-items:start;align-content:flex-start;padding-left:.25em;padding-right:.25em;box-sizing:border-box}.braccato--line.braccato--animating{transform:scale(var(--braccato-active-scale));transition-delay:var(--braccato-anim-delay)}.braccato--line>span{color:var(--braccato-inactive-color);display:inline-block;white-space:pre-wrap}.braccato--word{white-space:pre;display:inline-block;transform:translateY(0);position:relative}.braccato--line.braccato--pre-animating,.braccato--line.braccato--pre-animating .braccato--word{will-change:transform}.braccato--break{flex-basis:100%;height:0}.braccato--word.braccato--animating{animation:braccato-wobble var(--braccato-wobble-duration) forwards ease;animation-delay:var(--braccato-anim-delay);animation-play-state:running}.braccato--word.braccato--animating.braccato--paused{animation-play-state:paused}.braccato--word:after{position:absolute;content:attr(data-content);top:-2rem;left:-2rem;white-space:pre-wrap;padding:2rem;pointer-events:none;color:transparent;box-sizing:content-box;width:100%;background-image:linear-gradient(90deg,var(--braccato-active-color) calc(100% * var(--lyric-transition-amount-start) - 4rem * var(--lyric-transition-amount-start) + 2rem),#00000000 calc(100% * var(--lyric-transition-amount-end) - 4rem * var(--lyric-transition-amount-end) + 2rem + 1px));opacity:0;--lyric-transition-amount-start: -.2;--lyric-transition-amount-end: -.1;--braccato-glow-color: color(display-p3 1 1 1 / .0001);transition:--lyric-transition-amount-start 1s linear 1000s,--lyric-transition-amount-end 1s linear 1000s,opacity .5s ease;-webkit-background-clip:text;background-clip:text}.braccato--word[data-long-word]:after{--braccato-glow-color: color(display-p3 1 1 1 / 1)}.braccato--word.braccato--pre-animating:not(.braccato--animating):after{transition:none;--lyric-transition-amount-start: -.2;--lyric-transition-amount-end: -.1;opacity:0}.braccato--word.braccato--pre-animating:not(.braccato--animating):not(.braccato-zero-dur-animate):after{opacity:1}.braccato--word.braccato--animating:after{opacity:1;animation:braccato-glow max(calc(var(--braccato-duration) * 1.2),1.2s) forwards ease;animation-delay:var(--braccato-anim-delay);animation-play-state:running;--lyric-transition-amount-start: 1.4;--lyric-transition-amount-end: 1.5;transition-property:--lyric-transition-amount-start,--lyric-transition-amount-end,opacity;transition-duration:calc(var(--braccato-duration) * 1.6),calc(var(--braccato-duration) * 1.6),var(--braccato-highlight-fade-in-duration);transition-timing-function:linear,linear,ease;transition-delay:var(--braccato-swipe-delay),var(--braccato-swipe-delay),var(--braccato-anim-delay)}.braccato--word.braccato--animating.braccato--paused:after{transition-duration:100000000s,100000000s,100000000s;--lyric-transition-amount-start: 10;--lyric-transition-amount-end: 10;opacity:.5;animation-play-state:paused}.braccato--translated,.braccato--romanized{display:block;font-size:var(--braccato-translated-font-size);font-weight:var(--braccato-translated-font-weight);font-family:var(--braccato-translated-font-family);color:var(--braccato-translated-color);white-space:normal;line-height:1.1;margin-top:8px}.braccato--romanized>span{color:var(--braccato-inactive-color);display:inline-block;white-space:pre-wrap}.braccato--romanized{width:fit-content;font-size:calc(var(--braccato-translated-font-size) / 1.25);background:#ffffff0d;padding:.375rem .75rem;border:1px solid rgba(255,255,255,.1);border-radius:1rem}.braccato-rtl{direction:rtl}.braccato-rtl.braccato--word:after{background-image:linear-gradient(270deg,var(--braccato-active-color) calc(100% * var(--lyric-transition-amount-start) - 4rem * var(--lyric-transition-amount-start) + 2rem),#00000000 calc(100% * var(--lyric-transition-amount-end) - 4rem * var(--lyric-transition-amount-end) + 2rem + 1px))}.braccato--line[data-agent=v2],.braccato--line[data-agent=v3]{justify-content:flex-end;text-align:right;transform-origin:right center!important}.braccato--line[data-agent=v1000]{justify-content:center;text-align:center;transform-origin:center center!important}.braccato--spacer{padding:0;margin:0}.braccato-autoscroll-btn{font-family:var(--braccato-font-family);position:absolute;display:block;font-size:1.75rem;font-weight:600;white-space:normal;line-height:1.1;width:fit-content;background:#ffffff0d;padding:.5rem 1rem;border:1px solid rgba(255,255,255,.1);border-radius:1rem;color:#fff;left:50%;transform:translate(-50%,2em);-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;z-index:100;transition:opacity .15s linear .05s,transform .2s cubic-bezier(.5,1,.89,1)}.braccato-autoscroll-btn[hidden]{transition:opacity .1s linear,transform .15s ease-in;opacity:0;pointer-events:none;transform:translate(-50%,-3em)}@keyframes braccato-wobble{0%{transform:translateY(0)}to{transform:translateY(-.0375em)}}@keyframes braccato-glow{0%{filter:drop-shadow(0 0 .8rem var(--braccato-glow-color))}to{filter:drop-shadow(0 0 0rem var(--braccato-glow-color))}}", Ht = ':host{--braccato-text-color: color(display-p3 1 1 1 / 1);--braccato-glow-color: color(display-p3 1 1 1 / .5);--braccato-active-color: var(--braccato-text-color);--braccato-inactive-color: color( from var(--braccato-text-color) display-p3 r g b / var(--braccato-inactive-opacity, .3) );--braccato-active-opacity: 1;--braccato-inactive-opacity: .3;--braccato-richsync-timing-offset: .15s;--braccato-timing-offset: .115s;--braccato-scroll-timing-offset: .5s;--braccato-font-family: "Satoshi", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--braccato-font-size: 3rem;--braccato-font-weight: 600;--braccato-line-height: 1.333;--braccato-translated-font-size: 2rem;--braccato-translated-font-weight: 600;--braccato-translated-font-family: var(--braccato-font-family);--braccato-translated-color: color(display-p3 1 1 1 / var(--braccato-translated-opacity, .6));--braccato-scale-transition-duration: .166s;--braccato-highlight-fade-in-duration: .33s;--braccato-highlight-fade-out-duration: .5s;--braccato-wobble-duration: 1s;--braccato-padding: 1.25rem;--braccato-padding-bottom: 50cqh;--braccato-scale: .95;--braccato-active-scale: 1;--braccato-scroll-duration: .75s;--braccato-scroll-timing-function: cubic-bezier(.86, 0, .07, 1)}';
|
|
611
|
-
var
|
|
612
|
-
for (var
|
|
613
|
-
(
|
|
614
|
-
return
|
|
655
|
+
const ae = ':host{display:block;overflow-y:auto;position:relative;container-type:size;scrollbar-width:none}:host::-webkit-scrollbar{display:none}:host(:has(.braccato--user-scrolling)){scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.15) transparent}:host(:has(.braccato--user-scrolling))::-webkit-scrollbar{display:block;width:6px}:host(:has(.braccato--user-scrolling))::-webkit-scrollbar-thumb{background:#ffffff26;border-radius:3px}:host(:has(.braccato--user-scrolling))::-webkit-scrollbar-track{background:transparent}.braccato-container{font-family:var(--braccato-font-family);font-size:var(--braccato-font-size);font-weight:var(--braccato-font-weight);isolation:isolate;line-height:var(--braccato-line-height);position:relative;z-index:1;transition:transform var(--braccato-scroll-duration) var(--braccato-scroll-timing-function) 0s;padding-top:2rem;padding-bottom:var(--braccato-padding-bottom)}.braccato-container>div{cursor:pointer;padding:var(--braccato-padding) 0;transform-origin:left center;word-break:break-word;transition:filter calc(var(--braccato-duration) / 3) .4s,opacity calc(var(--braccato-duration) / 2) .166s,transform .166s var(--braccato-anim-delay, 0s)}.braccato-container:has(.braccato--active):not(.braccato--user-scrolling)>div:not(.braccato--active):not(.braccato--active~div){opacity:.33;filter:blur(2.5px)}.braccato-container>div.braccato--active{opacity:1;filter:blur(0px)}.braccato-container>div.braccato--active~div{opacity:.66;filter:blur(0px)}.braccato-container>.braccato--animating{opacity:1!important;filter:blur(0px)!important}.braccato-container>div:hover{opacity:1!important;filter:blur(0px)!important;transform:scale(var(--braccato-hover-scale, 1.01));transition:all .3s ease}.braccato--active{cursor:default}:not(.braccato-background-lyric){order:0}.braccato-background-lyric{order:2}.braccato--line>span>span.braccato-background-lyric{font-size:.675em;font-weight:400}.braccato--line{transform:scale(var(--braccato-scale));transition-property:transform;transition-duration:var(--braccato-scale-transition-duration);transition-timing-function:ease;display:flex;flex-flow:row wrap;align-items:start;align-content:flex-start;padding-left:.25em;padding-right:.25em;box-sizing:border-box}.braccato--line.braccato--animating{transform:scale(var(--braccato-active-scale));transition-delay:var(--braccato-anim-delay)}.braccato--line>span{color:var(--braccato-inactive-color);display:inline-block;white-space:pre-wrap}.braccato--word{white-space:pre;display:inline-block;transform:translateY(0);position:relative}.braccato--line.braccato--pre-animating,.braccato--line.braccato--pre-animating .braccato--word{will-change:transform}.braccato--break{flex-basis:100%;height:0}.braccato--word.braccato--animating{animation:braccato-wobble var(--braccato-wobble-duration) forwards ease;animation-delay:var(--braccato-anim-delay);animation-play-state:running}.braccato--word.braccato--animating.braccato--paused{animation-play-state:paused}.braccato--word:after{position:absolute;content:attr(data-content);top:-2rem;left:-2rem;white-space:pre-wrap;padding:2rem;pointer-events:none;color:transparent;box-sizing:content-box;width:100%;background-image:linear-gradient(90deg,var(--braccato-active-color) calc(100% * var(--lyric-transition-amount-start) - 4rem * var(--lyric-transition-amount-start) + 2rem),#00000000 calc(100% * var(--lyric-transition-amount-end) - 4rem * var(--lyric-transition-amount-end) + 2rem + 1px));opacity:0;--lyric-transition-amount-start: -.2;--lyric-transition-amount-end: -.1;--braccato-glow-color: color(display-p3 1 1 1 / .0001);transition:--lyric-transition-amount-start 1s linear 1000s,--lyric-transition-amount-end 1s linear 1000s,opacity .5s ease;-webkit-background-clip:text;background-clip:text}.braccato--word[data-long-word]:after{--braccato-glow-color: color(display-p3 1 1 1 / 1)}.braccato--word.braccato--pre-animating:not(.braccato--animating):after{transition:none;--lyric-transition-amount-start: -.2;--lyric-transition-amount-end: -.1;opacity:0}.braccato--word.braccato--pre-animating:not(.braccato--animating):not(.braccato-zero-dur-animate):after{opacity:1}.braccato--word.braccato--animating:after{opacity:1;animation:braccato-glow max(calc(var(--braccato-duration) * 1.2),1.2s) forwards ease;animation-delay:var(--braccato-anim-delay);animation-play-state:running;--lyric-transition-amount-start: 1.4;--lyric-transition-amount-end: 1.5;transition-property:--lyric-transition-amount-start,--lyric-transition-amount-end,opacity;transition-duration:calc(var(--braccato-duration) * 1.6),calc(var(--braccato-duration) * 1.6),var(--braccato-highlight-fade-in-duration);transition-timing-function:linear,linear,ease;transition-delay:var(--braccato-swipe-delay),var(--braccato-swipe-delay),var(--braccato-anim-delay)}.braccato--word.braccato--animating.braccato--paused:after{transition-duration:100000000s,100000000s,100000000s;--lyric-transition-amount-start: 10;--lyric-transition-amount-end: 10;opacity:.5;animation-play-state:paused}.braccato--translated,.braccato--romanized{display:block;font-size:var(--braccato-translated-font-size);font-weight:var(--braccato-translated-font-weight);font-family:var(--braccato-translated-font-family);color:var(--braccato-translated-color);white-space:normal;line-height:1.1;margin-top:8px}.braccato--romanized>span{color:var(--braccato-inactive-color);display:inline-block;white-space:pre-wrap}.braccato--romanized{width:fit-content;font-size:calc(var(--braccato-translated-font-size) / 1.25);background:#ffffff0d;padding:.375rem .75rem;border:1px solid rgba(255,255,255,.1);border-radius:1rem}.braccato-rtl{direction:rtl}.braccato-rtl.braccato--word:after{background-image:linear-gradient(270deg,var(--braccato-active-color) calc(100% * var(--lyric-transition-amount-start) - 4rem * var(--lyric-transition-amount-start) + 2rem),#00000000 calc(100% * var(--lyric-transition-amount-end) - 4rem * var(--lyric-transition-amount-end) + 2rem + 1px))}.braccato--line[data-agent=v2],.braccato--line[data-agent=v3]{justify-content:flex-end;text-align:right;transform-origin:right center!important}.braccato--line[data-agent=v1000]{justify-content:center;text-align:center;transform-origin:center center!important}.braccato--instrumental-icon{height:var(--braccato-font-size);width:calc(var(--braccato-font-size) + var(--braccato-font-size) / 3);overflow:visible;margin-left:calc(var(--braccato-font-size) / -3)}.braccato-rtl.braccato--instrumental .braccato--instrumental-icon,.braccato--instrumental[data-agent=v2] .braccato--instrumental-icon,.braccato--instrumental[data-agent=v3] .braccato--instrumental-icon{margin-left:0;margin-right:calc(var(--braccato-font-size) / -3)}.braccato--instrumental[data-agent=v1000] .braccato--instrumental-icon{margin-left:0;margin-right:0}.braccato--instrumental-bg{fill:var(--braccato-inactive-color)}.braccato--instrumental-fill{fill:var(--braccato-active-color);transition:opacity var(--braccato-highlight-fade-out-duration, .5s) ease;opacity:0}.braccato--instrumental.braccato--animating .braccato--instrumental-fill{transition:none;opacity:1}.braccato--instrumental:not(.braccato--pre-animating) .braccato--wave-clip{transition-property:transform;transition-duration:1000000s;transition-delay:0s;transform:translateY(0)}.braccato--instrumental.braccato--pre-animating:not(.braccato--animating) .braccato--wave-clip{animation:none;transform:translateY(78%)}.braccato--instrumental.braccato--animating .braccato--wave-clip{transition-property:transform;transition-duration:calc(var(--braccato-duration, 1ms) * 1);transition-timing-function:linear;transition-delay:var(--braccato-anim-delay);transform:translateY(-4%)}.braccato--paused .braccato--wave-clip{transition-duration:100000000s!important;transform:translateY(100%)!important}.braccato--wave-path{transform-box:fill-box;transform-origin:bottom;animation:braccato-wave 1.25s ease-in-out infinite;animation-play-state:paused;transform:scaleY(1.2)}.braccato--instrumental.braccato--animating:not(.braccato--paused) .braccato--wave-path{animation-play-state:running;transform:scaleY(0);transition-property:transform;transition-duration:calc(var(--braccato-duration, 1ms) * 1);transition-timing-function:ease-in;transition-delay:var(--braccato-anim-delay)}.braccato--instrumental.braccato--animating.braccato--paused .braccato--wave-path{transform:scaleY(.0001);transition-duration:10000000000s;transition-property:transform;transition-timing-function:ease-out;transition-delay:0s}@keyframes braccato-wave{0%,to{d:path("M -4 3 Q 1 2 5 3 Q 10 4 14 3 Q 18 2 22 3 Q 26 4 30 3 L 30 4 L -4 4 Z")}50%{d:path("M -4 3 Q 1 4 5 3 Q 10 2 14 3 Q 18 4 22 3 Q 26 2 30 3 L 30 4 L -4 4 Z")}}.braccato--spacer{padding:0;margin:0}.braccato-autoscroll-btn{font-family:var(--braccato-font-family);position:absolute;display:block;font-size:1.75rem;font-weight:600;white-space:normal;line-height:1.1;width:fit-content;background:#ffffff0d;padding:.5rem 1rem;border:1px solid rgba(255,255,255,.1);border-radius:1rem;color:#fff;left:50%;transform:translate(-50%,2em);-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);pointer-events:auto;cursor:pointer;-webkit-user-select:none;user-select:none;z-index:100;transition:opacity .15s linear .05s,transform .2s cubic-bezier(.5,1,.89,1)}.braccato-autoscroll-btn[hidden]{transition:opacity .1s linear,transform .15s ease-in;opacity:0;pointer-events:none;transform:translate(-50%,-3em)}@keyframes braccato-wobble{0%{transform:translateY(0)}to{transform:translateY(-.0375em)}}@keyframes braccato-glow{0%{filter:drop-shadow(0 0 .8rem var(--braccato-glow-color))}to{filter:drop-shadow(0 0 0rem var(--braccato-glow-color))}}', re = ':host{--braccato-text-color: color(display-p3 1 1 1 / 1);--braccato-glow-color: color(display-p3 1 1 1 / .5);--braccato-active-color: var(--braccato-text-color);--braccato-inactive-color: color( from var(--braccato-text-color) display-p3 r g b / var(--braccato-inactive-opacity, .3) );--braccato-active-opacity: 1;--braccato-inactive-opacity: .3;--braccato-richsync-timing-offset: .15s;--braccato-timing-offset: .115s;--braccato-scroll-timing-offset: .5s;--braccato-font-family: "Satoshi", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--braccato-font-size: 3rem;--braccato-font-weight: 600;--braccato-line-height: 1.333;--braccato-translated-font-size: 2rem;--braccato-translated-font-weight: 600;--braccato-translated-font-family: var(--braccato-font-family);--braccato-translated-color: color(display-p3 1 1 1 / var(--braccato-translated-opacity, .6));--braccato-scale-transition-duration: .166s;--braccato-highlight-fade-in-duration: .33s;--braccato-highlight-fade-out-duration: .5s;--braccato-wobble-duration: 1s;--braccato-padding: 1.25rem;--braccato-padding-bottom: 50cqh;--braccato-scale: .95;--braccato-active-scale: 1;--braccato-scroll-duration: .75s;--braccato-scroll-timing-function: cubic-bezier(.86, 0, .07, 1)}';
|
|
656
|
+
var ne = Object.defineProperty, D = (t, e, a, r) => {
|
|
657
|
+
for (var n = void 0, o = t.length - 1, s; o >= 0; o--)
|
|
658
|
+
(s = t[o]) && (n = s(e, a, n) || n);
|
|
659
|
+
return n && ne(e, a, n), n;
|
|
615
660
|
};
|
|
616
|
-
function
|
|
661
|
+
function ie() {
|
|
617
662
|
if (!(typeof CSS > "u" || !CSS.registerProperty))
|
|
618
663
|
try {
|
|
619
664
|
CSS.registerProperty({
|
|
@@ -630,16 +675,16 @@ function Yt() {
|
|
|
630
675
|
} catch {
|
|
631
676
|
}
|
|
632
677
|
}
|
|
633
|
-
|
|
634
|
-
const
|
|
678
|
+
ie();
|
|
679
|
+
const J = class J extends lt {
|
|
635
680
|
constructor() {
|
|
636
|
-
super(...arguments), this.lyrics = [], this.currentTime = 0, this.playing = !1, this.scrollMode = "internal", this.scrollContainer = null, this.dir = "auto", this.longWordThreshold = 1500, this.lineSyncedDelay = 50, this.disableRichsync = !1, this.debug = !1, this.source = null, this.src = null, this._lyricsData = null, this._animState =
|
|
681
|
+
super(...arguments), this.lyrics = [], this.currentTime = 0, this.playing = !1, this.scrollMode = "internal", this.scrollContainer = null, this.dir = "auto", this.longWordThreshold = 1500, this.lineSyncedDelay = 50, this.disableRichsync = !1, this.debug = !1, this.source = null, this.src = null, this._lyricsData = null, this._animState = Rt(), this._rafId = null, this._lastLyrics = [], this._resizeObserver = null, this._mediaElement = null, this._lastSrc = null, this._srcAbortController = null, this._tickCount = 0, this._onScroll = () => {
|
|
637
682
|
const e = this._animState.scroll;
|
|
638
683
|
if (e.skipScrolls > 0) {
|
|
639
684
|
e.skipScrolls--;
|
|
640
685
|
return;
|
|
641
686
|
}
|
|
642
|
-
|
|
687
|
+
At(e) ? at(e) : (at(e), this.dispatchEvent(
|
|
643
688
|
new CustomEvent("braccato:scroll-state", {
|
|
644
689
|
detail: { userScrolling: !0 },
|
|
645
690
|
bubbles: !0,
|
|
@@ -660,20 +705,20 @@ const V = class V extends st {
|
|
|
660
705
|
e.has("lyrics") && this.lyrics !== this._lastLyrics && (this._lastLyrics = this.lyrics, this._injectLyrics()), e.has("source") && this._resolveMediaElement(), e.has("src") && this.src !== this._lastSrc && (this._lastSrc = this.src, this._fetchLyricsFromSrc());
|
|
661
706
|
}
|
|
662
707
|
render() {
|
|
663
|
-
return
|
|
708
|
+
return dt`<div class="braccato-container" part="container"></div>`;
|
|
664
709
|
}
|
|
665
710
|
// -- Lyric Injection --------------------------
|
|
666
711
|
_log(...e) {
|
|
667
712
|
this.debug && console.log("[braccato]", ...e);
|
|
668
713
|
}
|
|
669
714
|
_injectLyrics() {
|
|
670
|
-
var
|
|
671
|
-
const e = (
|
|
715
|
+
var n, o, s, i;
|
|
716
|
+
const e = (n = this.shadowRoot) == null ? void 0 : n.querySelector(".braccato-container");
|
|
672
717
|
if (!e) {
|
|
673
718
|
this._log("_injectLyrics: no container found in shadowRoot");
|
|
674
719
|
return;
|
|
675
720
|
}
|
|
676
|
-
if (
|
|
721
|
+
if (Pt(this._animState), !this.lyrics || this.lyrics.length === 0) {
|
|
677
722
|
this._log("_injectLyrics: no lyrics, clearing"), e.replaceChildren(), this._lyricsData = null;
|
|
678
723
|
return;
|
|
679
724
|
}
|
|
@@ -682,17 +727,17 @@ const V = class V extends st {
|
|
|
682
727
|
lineSyncedAnimationDelay: this.lineSyncedDelay,
|
|
683
728
|
disableRichsync: this.disableRichsync
|
|
684
729
|
};
|
|
685
|
-
this._lyricsData =
|
|
730
|
+
this._lyricsData = ee(this.lyrics, e, a), this._log("_injectLyrics: rendered", {
|
|
686
731
|
lineCount: this._lyricsData.lines.length,
|
|
687
732
|
syncType: this._lyricsData.syncType,
|
|
688
733
|
firstLineTime: (o = this._lyricsData.lines[0]) == null ? void 0 : o.time,
|
|
689
|
-
lastLineTime: (
|
|
734
|
+
lastLineTime: (s = this._lyricsData.lines[this._lyricsData.lines.length - 1]) == null ? void 0 : s.time,
|
|
690
735
|
containerSize: { w: e.clientWidth, h: e.clientHeight }
|
|
691
736
|
});
|
|
692
737
|
for (let c = 0; c < this._lyricsData.lines.length; c++)
|
|
693
|
-
this._lyricsData.lines[c].element.addEventListener("click", (
|
|
738
|
+
this._lyricsData.lines[c].element.addEventListener("click", (u) => this._handleLineClick(u, c));
|
|
694
739
|
const r = this._getScrollContainer();
|
|
695
|
-
this._log("_injectLyrics: scrollContainer", r.tagName, r.className), r.addEventListener("scroll", this._onScroll, { passive: !0 }), (
|
|
740
|
+
this._log("_injectLyrics: scrollContainer", r.tagName, r.className), r.addEventListener("scroll", this._onScroll, { passive: !0 }), (i = this._resizeObserver) == null || i.disconnect(), this._resizeObserver = new ResizeObserver(() => this._recalculatePositions()), this._resizeObserver.observe(e), this._recalculatePositions(), this.dispatchEvent(
|
|
696
741
|
new CustomEvent("braccato:lyrics-loaded", {
|
|
697
742
|
detail: { syncType: this._lyricsData.syncType, lineCount: this._lyricsData.lines.length },
|
|
698
743
|
bubbles: !0,
|
|
@@ -706,8 +751,8 @@ const V = class V extends st {
|
|
|
706
751
|
const e = this._lyricsData.container;
|
|
707
752
|
this._lyricsData.width = e.clientWidth, this._lyricsData.height = e.clientHeight;
|
|
708
753
|
for (const a of this._lyricsData.lines) {
|
|
709
|
-
const r = a.element.getBoundingClientRect(),
|
|
710
|
-
a.position = r.top -
|
|
754
|
+
const r = a.element.getBoundingClientRect(), n = e.getBoundingClientRect();
|
|
755
|
+
a.position = r.top - n.top + e.scrollTop, a.height = r.height;
|
|
711
756
|
}
|
|
712
757
|
this._animState.scroll.wasUserScrolling = !0;
|
|
713
758
|
}
|
|
@@ -724,13 +769,13 @@ const V = class V extends st {
|
|
|
724
769
|
_tick() {
|
|
725
770
|
if (!this._lyricsData || this._lyricsData.syncType === "none") return;
|
|
726
771
|
if (this._tickCount++, this.debug && this._tickCount % 60 === 0) {
|
|
727
|
-
const
|
|
772
|
+
const n = this._lyricsData.lines.filter((s) => s.isScrolled), o = this._lyricsData.lines.filter((s) => s.isAnimating);
|
|
728
773
|
this._log("tick", {
|
|
729
774
|
currentTime: this.currentTime,
|
|
730
775
|
currentTimeSec: this.currentTime / 1e3,
|
|
731
776
|
playing: this.playing,
|
|
732
777
|
syncType: this._lyricsData.syncType,
|
|
733
|
-
activeLineCount:
|
|
778
|
+
activeLineCount: n.length,
|
|
734
779
|
animatingLineCount: o.length,
|
|
735
780
|
selectedIndex: this._animState.selectedElementIndex,
|
|
736
781
|
scrollResumeTime: this._animState.scroll.scrollResumeTime,
|
|
@@ -738,7 +783,7 @@ const V = class V extends st {
|
|
|
738
783
|
});
|
|
739
784
|
}
|
|
740
785
|
const e = this._mediaElement, a = e ? e.currentTime * 1e3 : this.currentTime, r = e ? !e.paused : this.playing;
|
|
741
|
-
|
|
786
|
+
zt(this._animState, {
|
|
742
787
|
currentTime: a / 1e3,
|
|
743
788
|
eventCreationTime: Date.now(),
|
|
744
789
|
isPlaying: r,
|
|
@@ -753,17 +798,17 @@ const V = class V extends st {
|
|
|
753
798
|
}
|
|
754
799
|
// -- Events --------------------------
|
|
755
800
|
_handleLineClick(e, a) {
|
|
756
|
-
var o,
|
|
801
|
+
var o, s;
|
|
757
802
|
const r = (o = this._lyricsData) == null ? void 0 : o.lines[a];
|
|
758
803
|
if (!r) return;
|
|
759
|
-
const
|
|
760
|
-
if (this._log("lineClick", { lineIndex: a, time:
|
|
761
|
-
const
|
|
762
|
-
if (
|
|
763
|
-
const c = Number.parseFloat(
|
|
804
|
+
const n = r.time * 1e3;
|
|
805
|
+
if (this._log("lineClick", { lineIndex: a, time: n, lineTimeSec: r.time, currentTime: this.currentTime }), e.altKey && ((s = this._lyricsData) == null ? void 0 : s.syncType) === "richsync") {
|
|
806
|
+
const i = e.target.closest(".braccato--word");
|
|
807
|
+
if (i) {
|
|
808
|
+
const c = Number.parseFloat(i.dataset.time || "0") * 1e3, l = r.parts.findIndex((u) => u.element === i);
|
|
764
809
|
this.dispatchEvent(
|
|
765
810
|
new CustomEvent("braccato:word-click", {
|
|
766
|
-
detail: { time: c, lineIndex: a, wordIndex:
|
|
811
|
+
detail: { time: c, lineIndex: a, wordIndex: l },
|
|
767
812
|
bubbles: !0,
|
|
768
813
|
composed: !0
|
|
769
814
|
})
|
|
@@ -771,13 +816,13 @@ const V = class V extends st {
|
|
|
771
816
|
return;
|
|
772
817
|
}
|
|
773
818
|
}
|
|
774
|
-
this._mediaElement && (this._mediaElement.currentTime =
|
|
819
|
+
this._mediaElement && (this._mediaElement.currentTime = n / 1e3, this._mediaElement.paused && this._mediaElement.play()), this.dispatchEvent(
|
|
775
820
|
new CustomEvent("braccato:line-click", {
|
|
776
|
-
detail: { time:
|
|
821
|
+
detail: { time: n, lineIndex: a },
|
|
777
822
|
bubbles: !0,
|
|
778
823
|
composed: !0
|
|
779
824
|
})
|
|
780
|
-
),
|
|
825
|
+
), rt(this._animState.scroll);
|
|
781
826
|
}
|
|
782
827
|
// -- Source Binding --------------------------
|
|
783
828
|
_resolveMediaElement() {
|
|
@@ -802,10 +847,10 @@ const V = class V extends st {
|
|
|
802
847
|
this._emitError(new Error(`Failed to fetch lyrics: ${r.status} ${r.statusText}`));
|
|
803
848
|
return;
|
|
804
849
|
}
|
|
805
|
-
const
|
|
850
|
+
const n = await r.text();
|
|
806
851
|
if (e.signal.aborted) return;
|
|
807
|
-
const o = this._mediaElement ? this._mediaElement.duration * 1e3 : 3e5,
|
|
808
|
-
this.lyrics =
|
|
852
|
+
const o = this._mediaElement ? this._mediaElement.duration * 1e3 : 3e5, s = wt(n);
|
|
853
|
+
this.lyrics = s.parse(n, o);
|
|
809
854
|
} catch (r) {
|
|
810
855
|
if (r instanceof DOMException && r.name === "AbortError") return;
|
|
811
856
|
this._emitError(r instanceof Error ? r : new Error(String(r)));
|
|
@@ -822,51 +867,51 @@ const V = class V extends st {
|
|
|
822
867
|
}
|
|
823
868
|
// -- Public Methods --------------------------
|
|
824
869
|
resumeAutoscroll() {
|
|
825
|
-
|
|
870
|
+
rt(this._animState.scroll);
|
|
826
871
|
}
|
|
827
872
|
recalculatePositions() {
|
|
828
873
|
this._recalculatePositions();
|
|
829
874
|
}
|
|
830
875
|
};
|
|
831
|
-
|
|
832
|
-
let
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
],
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
],
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
],
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
],
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
],
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
],
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
],
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
],
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
],
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
],
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
],
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
],
|
|
869
|
-
customElements.define("braccato-lyrics",
|
|
876
|
+
J.styles = [X(re), X(ae)];
|
|
877
|
+
let E = J;
|
|
878
|
+
D([
|
|
879
|
+
I({ type: Array })
|
|
880
|
+
], E.prototype, "lyrics");
|
|
881
|
+
D([
|
|
882
|
+
I({ attribute: "current-time", type: Number })
|
|
883
|
+
], E.prototype, "currentTime");
|
|
884
|
+
D([
|
|
885
|
+
I({ type: Boolean, reflect: !0 })
|
|
886
|
+
], E.prototype, "playing");
|
|
887
|
+
D([
|
|
888
|
+
I({ attribute: "scroll-mode", type: String, reflect: !0 })
|
|
889
|
+
], E.prototype, "scrollMode");
|
|
890
|
+
D([
|
|
891
|
+
I({ attribute: !1 })
|
|
892
|
+
], E.prototype, "scrollContainer");
|
|
893
|
+
D([
|
|
894
|
+
I({ type: String, reflect: !0 })
|
|
895
|
+
], E.prototype, "dir");
|
|
896
|
+
D([
|
|
897
|
+
I({ attribute: "long-word-threshold", type: Number })
|
|
898
|
+
], E.prototype, "longWordThreshold");
|
|
899
|
+
D([
|
|
900
|
+
I({ attribute: "line-synced-delay", type: Number })
|
|
901
|
+
], E.prototype, "lineSyncedDelay");
|
|
902
|
+
D([
|
|
903
|
+
I({ attribute: "disable-richsync", type: Boolean })
|
|
904
|
+
], E.prototype, "disableRichsync");
|
|
905
|
+
D([
|
|
906
|
+
I({ type: Boolean })
|
|
907
|
+
], E.prototype, "debug");
|
|
908
|
+
D([
|
|
909
|
+
I({ type: String, reflect: !0 })
|
|
910
|
+
], E.prototype, "source");
|
|
911
|
+
D([
|
|
912
|
+
I({ type: String, reflect: !0 })
|
|
913
|
+
], E.prototype, "src");
|
|
914
|
+
customElements.define("braccato-lyrics", E);
|
|
870
915
|
export {
|
|
871
|
-
|
|
916
|
+
E as BraccatoElement
|
|
872
917
|
};
|