@lucaismyname/ginger 0.0.15 → 0.0.20

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.
Files changed (59) hide show
  1. package/README.md +113 -1
  2. package/dist/client.cjs +1 -1
  3. package/dist/client.js +31 -28
  4. package/dist/client.test.d.ts +2 -0
  5. package/dist/client.test.d.ts.map +1 -0
  6. package/dist/components/controls/Controls.d.ts +26 -13
  7. package/dist/components/controls/Controls.d.ts.map +1 -1
  8. package/dist/components/current/Chapters.d.ts +15 -0
  9. package/dist/components/current/Chapters.d.ts.map +1 -0
  10. package/dist/components/current/ChaptersLyricsSynced.test.d.ts +2 -0
  11. package/dist/components/current/ChaptersLyricsSynced.test.d.ts.map +1 -0
  12. package/dist/components/current/LyricsSynced.d.ts +16 -0
  13. package/dist/components/current/LyricsSynced.d.ts.map +1 -0
  14. package/dist/components/current/index.d.ts +4 -0
  15. package/dist/components/current/index.d.ts.map +1 -1
  16. package/dist/core/transitions.d.ts +5 -3
  17. package/dist/core/transitions.d.ts.map +1 -1
  18. package/dist/experimental-gapless/index.cjs.map +1 -1
  19. package/dist/experimental-gapless/index.d.ts +3 -1
  20. package/dist/experimental-gapless/index.d.ts.map +1 -1
  21. package/dist/experimental-gapless/index.js.map +1 -1
  22. package/dist/ginger-8x4WzVmw.js +1818 -0
  23. package/dist/ginger-8x4WzVmw.js.map +1 -0
  24. package/dist/ginger-CMbd3s8C.cjs +2 -0
  25. package/dist/ginger-CMbd3s8C.cjs.map +1 -0
  26. package/dist/ginger.d.ts +2 -0
  27. package/dist/ginger.d.ts.map +1 -1
  28. package/dist/hooks/useNextTrackPrefetch.d.ts +16 -0
  29. package/dist/hooks/useNextTrackPrefetch.d.ts.map +1 -0
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.d.ts +50 -2
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +31 -28
  34. package/dist/testing/helpers.d.ts +29 -0
  35. package/dist/testing/helpers.d.ts.map +1 -1
  36. package/dist/testing/helpers.test.d.ts +2 -0
  37. package/dist/testing/helpers.test.d.ts.map +1 -0
  38. package/dist/testing/index.cjs +48 -43
  39. package/dist/testing/index.cjs.map +1 -1
  40. package/dist/testing/index.d.ts +1 -1
  41. package/dist/testing/index.d.ts.map +1 -1
  42. package/dist/testing/index.js +6888 -3749
  43. package/dist/testing/index.js.map +1 -1
  44. package/dist/testing/index.test.d.ts +2 -0
  45. package/dist/testing/index.test.d.ts.map +1 -0
  46. package/dist/testing/renderGinger.d.ts.map +1 -1
  47. package/dist/useNextTrackPrefetch-CFoUynDv.cjs +2 -0
  48. package/dist/useNextTrackPrefetch-CFoUynDv.cjs.map +1 -0
  49. package/dist/useNextTrackPrefetch-CV1khU0h.js +257 -0
  50. package/dist/useNextTrackPrefetch-CV1khU0h.js.map +1 -0
  51. package/package.json +9 -1
  52. package/dist/ginger-BTPRqWHs.js +0 -1621
  53. package/dist/ginger-BTPRqWHs.js.map +0 -1
  54. package/dist/ginger-BiI69vrn.cjs +0 -2
  55. package/dist/ginger-BiI69vrn.cjs.map +0 -1
  56. package/dist/useSeekDrag-Br1V0Vao.js +0 -290
  57. package/dist/useSeekDrag-Br1V0Vao.js.map +0 -1
  58. package/dist/useSeekDrag-aS7uk26h.cjs +0 -2
  59. package/dist/useSeekDrag-aS7uk26h.cjs.map +0 -1
@@ -0,0 +1,1818 @@
1
+ import { jsx as d, jsxs as Ae } from "react/jsx-runtime";
2
+ import { useContext as Ge, createContext as Ne, useRef as O, useState as Nr, useEffect as E, useMemo as P, useReducer as wr, useCallback as v } from "react";
3
+ import { c as I, b as _, u as j, g as $e, G as Cr, d as Lr } from "./GingerSplitContexts-BzBExb95.js";
4
+ const Oe = Ne(null);
5
+ function Dr() {
6
+ const e = Ge(Oe);
7
+ if (!e) throw new Error("Ginger components must be used within <Ginger.Provider>");
8
+ return e;
9
+ }
10
+ function Ue(e) {
11
+ const { buffered: r, duration: n } = e;
12
+ return !(n > 0) || r.length === 0 ? 0 : Math.min(1, r.end(r.length - 1) / n);
13
+ }
14
+ function Fr({
15
+ className: e,
16
+ style: r,
17
+ preload: n = "metadata",
18
+ crossOrigin: a,
19
+ respectReducedMotion: t = !1
20
+ }) {
21
+ var S;
22
+ const { audioRef: i, dispatch: o, state: u, notifyEnded: s } = Dr(), c = ((S = u.tracks[u.currentIndex]) == null ? void 0 : S.fileUrl) ?? "", g = O({
23
+ currentTime: -1,
24
+ duration: -1,
25
+ bufferedFraction: -1
26
+ }), m = O(""), [y, k] = Nr(!1);
27
+ E(() => {
28
+ if (!t || typeof window > "u") return;
29
+ const p = window.matchMedia("(prefers-reduced-motion: reduce)"), T = () => k(p.matches);
30
+ return T(), p.addEventListener("change", T), () => p.removeEventListener("change", T);
31
+ }, [t]);
32
+ const b = (p, T = !1) => {
33
+ const R = {
34
+ currentTime: p.currentTime,
35
+ duration: p.duration,
36
+ bufferedFraction: Ue(p)
37
+ }, w = g.current, Se = y ? 0.5 : 0.25, K = Math.abs(R.currentTime - w.currentTime) >= Se || Math.abs(R.duration - w.duration) >= 0.01 || Math.abs(R.bufferedFraction - w.bufferedFraction) >= 0.01;
38
+ !T && !K || (g.current = R, o({
39
+ type: "MEDIA_TIME_UPDATE",
40
+ payload: R
41
+ }));
42
+ };
43
+ return E(() => {
44
+ const p = i.current;
45
+ p && (p.volume = u.volume, p.muted = u.muted, p.playbackRate = u.playbackRate);
46
+ }, [i, u.volume, u.muted, u.playbackRate]), E(() => {
47
+ const p = i.current;
48
+ if (p) {
49
+ if (!c) {
50
+ p.removeAttribute("src"), g.current = { currentTime: -1, duration: -1, bufferedFraction: -1 }, m.current !== "" && o({ type: "MEDIA_SOURCE_CLEARED" }), m.current = "";
51
+ return;
52
+ }
53
+ p.getAttribute("src") !== c && (p.src = c, p.load(), g.current = { currentTime: -1, duration: -1, bufferedFraction: -1 }), m.current = c;
54
+ }
55
+ }, [i, o, u.currentIndex, u.tracks, c]), /* @__PURE__ */ d(
56
+ "audio",
57
+ {
58
+ ref: i,
59
+ className: e,
60
+ style: r,
61
+ preload: n,
62
+ crossOrigin: a,
63
+ controls: !1,
64
+ playsInline: !0,
65
+ onTimeUpdate: (p) => {
66
+ b(p.currentTarget);
67
+ },
68
+ onLoadedMetadata: (p) => {
69
+ const T = p.currentTarget;
70
+ g.current = { currentTime: -1, duration: -1, bufferedFraction: -1 }, o({
71
+ type: "MEDIA_LOADED_METADATA",
72
+ payload: {
73
+ duration: T.duration,
74
+ bufferedFraction: Ue(T)
75
+ }
76
+ });
77
+ },
78
+ onSeeking: (p) => b(p.currentTarget, !0),
79
+ onSeeked: (p) => b(p.currentTarget, !0),
80
+ onEnded: () => s(),
81
+ onPlay: () => o({ type: "MEDIA_PLAY" }),
82
+ onPause: () => o({ type: "MEDIA_PAUSE" }),
83
+ onWaiting: () => o({ type: "MEDIA_WAITING" }),
84
+ onCanPlay: () => o({ type: "MEDIA_CANPLAY" }),
85
+ onProgress: (p) => b(p.currentTarget, !0),
86
+ onVolumeChange: (p) => {
87
+ const T = p.currentTarget;
88
+ o({
89
+ type: "MEDIA_VOLUME_SYNC",
90
+ payload: { volume: T.volume, muted: T.muted }
91
+ });
92
+ },
93
+ onError: () => {
94
+ var w;
95
+ const p = i.current, T = (w = p == null ? void 0 : p.error) == null ? void 0 : w.code;
96
+ o({ type: "MEDIA_ERROR", payload: { message: T === 1 ? "MEDIA_ERR_ABORTED" : T === 2 ? "MEDIA_ERR_NETWORK" : T === 3 ? "MEDIA_ERR_DECODE" : T === 4 ? "MEDIA_ERR_SRC_NOT_SUPPORTED" : "MEDIA_ERR_UNKNOWN" } });
97
+ }
98
+ }
99
+ );
100
+ }
101
+ function A(e, r) {
102
+ return r <= 0 ? 0 : Math.max(0, Math.min(r - 1, e));
103
+ }
104
+ function Be(e, r) {
105
+ if (e.length <= 1) return [...e];
106
+ const n = e[r];
107
+ if (!n) return [...e];
108
+ const a = e.filter((t, i) => i !== r);
109
+ for (let t = a.length - 1; t > 0; t--) {
110
+ const i = Math.floor(Math.random() * (t + 1));
111
+ [a[t], a[i]] = [a[i], a[t]];
112
+ }
113
+ return [n, ...a];
114
+ }
115
+ function W(e) {
116
+ return e ? e.id != null && e.id !== "" ? `id:${e.id}` : `file:${e.fileUrl}` : "";
117
+ }
118
+ function Ur(e, r) {
119
+ var o, u;
120
+ if (!r) return 0;
121
+ const n = e.findIndex((s) => s === r);
122
+ if (n !== -1) return n;
123
+ const a = W(r);
124
+ if (!a) return 0;
125
+ const t = [];
126
+ for (let s = 0; s < e.length; s += 1)
127
+ W(e[s]) === a && t.push(s);
128
+ if (t.length === 0) return 0;
129
+ if (t.length === 1) return t[0];
130
+ const i = typeof globalThis < "u" && "process" in globalThis ? (u = (o = globalThis.process) == null ? void 0 : o.env) == null ? void 0 : u.NODE_ENV : void 0;
131
+ return i != null && i !== "production" && console.warn(
132
+ "[@lucaismyname/ginger] Ambiguous track identity: multiple queue rows share the same fileUrl without a unique `id`. Resolving to the first match."
133
+ ), t[0];
134
+ }
135
+ function Ye(e, r, n) {
136
+ const a = [...e], t = Math.max(0, Math.min(a.length, n ?? a.length));
137
+ return a.splice(t, 0, r), a;
138
+ }
139
+ function Vr(e, r) {
140
+ if (r < 0 || r >= e.length) return [...e];
141
+ const n = [...e];
142
+ return n.splice(r, 1), n;
143
+ }
144
+ function $r(e, r, n) {
145
+ if (r === n || r < 0 || r >= e.length || n < 0 || n >= e.length)
146
+ return [...e];
147
+ const a = [...e], [t] = a.splice(r, 1);
148
+ return t ? (a.splice(n, 0, t), a) : [...e];
149
+ }
150
+ function Or(e, r, n) {
151
+ return Ye(e, n, Math.max(0, Math.min(e.length, r + 1)));
152
+ }
153
+ function Br(e) {
154
+ const { tracks: r, currentIndex: n, repeatMode: a, playbackMode: t } = e, i = r.length;
155
+ return i === 0 ? { kind: "stop", nextIndex: 0 } : a === "one" ? { kind: "replay_same" } : t === "single" ? { kind: "stop", nextIndex: A(n, i) } : n < i - 1 ? { kind: "advance", nextIndex: n + 1 } : a === "all" ? { kind: "wrap", nextIndex: 0 } : { kind: "stop", nextIndex: A(n, i) };
156
+ }
157
+ function Yr(e) {
158
+ const { tracks: r, currentIndex: n, repeatMode: a, playbackMode: t } = e, i = r.length;
159
+ return i === 0 ? 0 : t === "single" ? A(n, i) : n < i - 1 ? n + 1 : a === "all" ? 0 : A(n, i);
160
+ }
161
+ function Qr(e) {
162
+ const { tracks: r, currentIndex: n, repeatMode: a, playbackMode: t } = e, i = r.length;
163
+ return i === 0 ? 0 : t === "single" ? A(n, i) : n > 0 ? n - 1 : a === "all" ? i - 1 : 0;
164
+ }
165
+ function Hr(e) {
166
+ return e === "off" ? "all" : e === "all" ? "one" : "off";
167
+ }
168
+ function Qe(e, r) {
169
+ return (e == null ? void 0 : e.artworkUrl) ?? r ?? void 0;
170
+ }
171
+ function jr(e, r) {
172
+ return (e == null ? void 0 : e.album) ?? r ?? void 0;
173
+ }
174
+ function V(e) {
175
+ return e.tracks[e.currentIndex] ?? null;
176
+ }
177
+ function He(e) {
178
+ return e.errorMessage ? "error" : e.tracks.length === 0 ? "idle" : e.isBuffering ? "loading" : e.isPaused ? Number.isFinite(e.duration) && e.duration > 0 && e.currentTime >= e.duration - 0.05 ? "ended" : "paused" : "playing";
179
+ }
180
+ function q(e) {
181
+ var a;
182
+ const r = e.duration;
183
+ if (Number.isFinite(r) && r > 0) return r;
184
+ const n = (a = e.tracks[e.currentIndex]) == null ? void 0 : a.durationSeconds;
185
+ return typeof n == "number" && Number.isFinite(n) && n > 0 ? n : 0;
186
+ }
187
+ function Kr(e) {
188
+ const n = q(e) - e.currentTime;
189
+ return Number.isFinite(n) ? Math.max(0, n) : 0;
190
+ }
191
+ function je(e) {
192
+ const r = q(e);
193
+ return r > 0 ? Math.min(1, Math.max(0, e.currentTime / r)) : 0;
194
+ }
195
+ function Xr(e) {
196
+ var n;
197
+ const r = V(e);
198
+ return Qe(r, (n = e.playlistMeta) == null ? void 0 : n.artworkUrl);
199
+ }
200
+ function zr(e) {
201
+ var n;
202
+ const r = V(e);
203
+ return jr(r, (n = e.playlistMeta) == null ? void 0 : n.subtitle);
204
+ }
205
+ function B(e, r) {
206
+ function n(a) {
207
+ const t = I(), o = (r(t) ?? "").trim(), { className: u, style: s, fallback: c, empty: g, children: m } = a;
208
+ if (!o) {
209
+ const y = g ?? c ?? null;
210
+ return y ? /* @__PURE__ */ d("span", { className: u, style: s, children: y }) : null;
211
+ }
212
+ return m ? /* @__PURE__ */ d("span", { className: u, style: s, children: m(o, t) }) : /* @__PURE__ */ d("span", { className: u, style: s, children: o });
213
+ }
214
+ return n.displayName = e, n;
215
+ }
216
+ function Y(e, r) {
217
+ return B(e, (n) => r(V(n)));
218
+ }
219
+ const Wr = Y("Ginger.Current.Title", (e) => e == null ? void 0 : e.title), qr = Y("Ginger.Current.Artist", (e) => e == null ? void 0 : e.artist), Jr = B("Ginger.Current.Album", (e) => zr(e)), Zr = Y("Ginger.Current.Description", (e) => e == null ? void 0 : e.description), en = B("Ginger.Current.Copyright", (e) => {
220
+ var n;
221
+ const r = V(e);
222
+ return (r == null ? void 0 : r.copyright) ?? ((n = e.playlistMeta) == null ? void 0 : n.copyright);
223
+ }), rn = Y("Ginger.Current.Genre", (e) => e == null ? void 0 : e.genre), nn = Y("Ginger.Current.Label", (e) => e == null ? void 0 : e.label), tn = Y("Ginger.Current.Isrc", (e) => e == null ? void 0 : e.isrc), an = Y(
224
+ "Ginger.Current.TrackNumber",
225
+ (e) => (e == null ? void 0 : e.trackNumber) != null ? String(e.trackNumber) : void 0
226
+ );
227
+ function Ke({ className: e, style: r, fallback: n, empty: a, children: t, format: i }) {
228
+ var c;
229
+ const o = I(), u = (c = V(o)) == null ? void 0 : c.year;
230
+ if (typeof u != "number" || !Number.isFinite(u)) {
231
+ const g = a ?? n ?? null;
232
+ return g ? /* @__PURE__ */ d("span", { className: e, style: r, children: g }) : null;
233
+ }
234
+ const s = i ? i(u) : String(u);
235
+ return t ? /* @__PURE__ */ d("span", { className: e, style: r, children: t(s, o) }) : /* @__PURE__ */ d("span", { className: e, style: r, children: s });
236
+ }
237
+ Ke.displayName = "Ginger.Current.Year";
238
+ function Xe({ className: e, style: r, fallback: n, empty: a, children: t, preserveWhitespace: i = !0 }) {
239
+ var g;
240
+ const o = I(), u = ((g = V(o)) == null ? void 0 : g.lyrics) ?? "", s = i ? u.replace(/^\s+|\s+$/g, "") : u.trim();
241
+ if (!s) {
242
+ const m = a ?? n ?? null;
243
+ return m ? /* @__PURE__ */ d("span", { className: e, style: r, children: m }) : null;
244
+ }
245
+ const c = i ? { whiteSpace: "pre-wrap" } : void 0;
246
+ return t ? /* @__PURE__ */ d("span", { className: e, style: { ...c, ...r }, children: t(s, o) }) : /* @__PURE__ */ d("span", { className: e, style: { ...c, ...r }, children: s });
247
+ }
248
+ Xe.displayName = "Ginger.Current.Lyrics";
249
+ const Ve = /\[(\d{1,2}):(\d{2})(?:\.(\d{1,3}))?\]/g;
250
+ function on(e) {
251
+ const r = [];
252
+ for (const n of e.split(/\r?\n/)) {
253
+ const a = [...n.matchAll(Ve)];
254
+ if (a.length === 0) continue;
255
+ const t = n.replace(Ve, "").trim();
256
+ for (const i of a) {
257
+ const o = Number(i[1] ?? 0), u = Number(i[2] ?? 0), s = Number((i[3] ?? "0").padEnd(3, "0")), c = o * 60 + u + s / 1e3;
258
+ Number.isFinite(c) && c >= 0 && r.push({ time: c, text: t });
259
+ }
260
+ }
261
+ return r.sort((n, a) => n.time - a.time);
262
+ }
263
+ function un() {
264
+ const { tracks: e, currentIndex: r } = _(), { currentTime: n } = j(), a = e[r], t = P(() => a ? Array.isArray(a.lyricsTimed) && a.lyricsTimed.length > 0 ? [...a.lyricsTimed].filter((o) => Number.isFinite(o.time) && o.time >= 0).sort((o, u) => o.time - u.time) : typeof a.lyrics == "string" ? on(a.lyrics) : [] : [], [a]), i = P(() => {
265
+ for (let o = t.length - 1; o >= 0; o -= 1)
266
+ if (n >= t[o].time) return o;
267
+ return -1;
268
+ }, [n, t]);
269
+ return {
270
+ lines: t,
271
+ activeIndex: i,
272
+ activeLine: i >= 0 ? t[i] ?? null : null
273
+ };
274
+ }
275
+ function ze({
276
+ className: e,
277
+ style: r,
278
+ fallback: n,
279
+ empty: a,
280
+ unstyled: t = !1,
281
+ activeClassName: i,
282
+ lineClassName: o,
283
+ children: u
284
+ }) {
285
+ const s = I(), { lines: c, activeIndex: g } = un();
286
+ if (c.length === 0) {
287
+ const y = a ?? n ?? null;
288
+ return y ? /* @__PURE__ */ d("span", { className: e, style: r, children: y }) : null;
289
+ }
290
+ return /* @__PURE__ */ d("ul", { className: e, style: { ...t ? {} : {
291
+ listStyle: "none",
292
+ margin: 0,
293
+ padding: 0,
294
+ fontFamily: "var(--ginger-font-family, system-ui, sans-serif)",
295
+ fontSize: "var(--ginger-font-size, 14px)",
296
+ color: "var(--ginger-primary-color, #111827)"
297
+ }, ...r }, "aria-label": "Synced lyrics", children: c.map((y, k) => {
298
+ const b = k === g;
299
+ return /* @__PURE__ */ d(
300
+ "li",
301
+ {
302
+ "aria-current": b ? "true" : void 0,
303
+ "data-ginger-active": b || void 0,
304
+ className: [o, b ? i : void 0].filter(Boolean).join(" ") || void 0,
305
+ style: t ? void 0 : {
306
+ padding: "var(--ginger-playlist-row-padding, 4px 8px)",
307
+ fontWeight: b ? 600 : 400,
308
+ opacity: b ? 1 : 0.75
309
+ },
310
+ children: u ? u(y, k, b, s) : y.text
311
+ },
312
+ `${y.time}-${k}`
313
+ );
314
+ }) });
315
+ }
316
+ ze.displayName = "Ginger.Current.LyricsSynced";
317
+ function sn() {
318
+ const { tracks: e, currentIndex: r } = _(), { currentTime: n, seek: a } = j(), t = P(() => {
319
+ var u;
320
+ return [...((u = e[r]) == null ? void 0 : u.chapters) ?? []].filter((s) => s && Number.isFinite(s.startSeconds) && s.startSeconds >= 0).sort((s, c) => s.startSeconds - c.startSeconds);
321
+ }, [r, e]), i = P(() => {
322
+ if (t.length === 0) return -1;
323
+ for (let o = t.length - 1; o >= 0; o -= 1)
324
+ if (n >= t[o].startSeconds) return o;
325
+ return -1;
326
+ }, [n, t]);
327
+ return {
328
+ list: t,
329
+ activeIndex: i,
330
+ active: i >= 0 ? t[i] ?? null : null,
331
+ seekTo: (o) => {
332
+ const u = t[o];
333
+ u && a(u.startSeconds);
334
+ }
335
+ };
336
+ }
337
+ function z(e) {
338
+ if (!Number.isFinite(e) || e < 0) return "0:00";
339
+ const r = Math.floor(e % 60);
340
+ return `${Math.floor(e / 60)}:${r.toString().padStart(2, "0")}`;
341
+ }
342
+ function We({
343
+ className: e,
344
+ style: r,
345
+ fallback: n,
346
+ empty: a,
347
+ unstyled: t = !1,
348
+ formatStart: i = z,
349
+ children: o
350
+ }) {
351
+ const u = I(), { list: s, activeIndex: c, seekTo: g } = sn();
352
+ if (s.length === 0) {
353
+ const y = a ?? n ?? null;
354
+ return y ? /* @__PURE__ */ d("span", { className: e, style: r, children: y }) : null;
355
+ }
356
+ return /* @__PURE__ */ d("ul", { className: e, style: { ...t ? {} : {
357
+ listStyle: "none",
358
+ margin: 0,
359
+ padding: 0,
360
+ fontFamily: "var(--ginger-font-family, system-ui, sans-serif)",
361
+ fontSize: "var(--ginger-font-size, 14px)",
362
+ color: "var(--ginger-primary-color, #111827)"
363
+ }, ...r }, "aria-label": "Chapters", children: s.map((y, k) => {
364
+ const b = k === c;
365
+ return /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d(
366
+ "button",
367
+ {
368
+ type: "button",
369
+ "aria-current": b ? "true" : void 0,
370
+ "data-ginger-active": b || void 0,
371
+ onClick: () => g(k),
372
+ style: {
373
+ width: t ? void 0 : "100%",
374
+ textAlign: t ? void 0 : "left",
375
+ border: t ? void 0 : "none",
376
+ background: t ? void 0 : b ? "var(--ginger-playlist-active-bg, rgba(17, 24, 39, 0.06))" : "transparent",
377
+ color: t ? void 0 : "inherit",
378
+ font: t ? void 0 : "inherit",
379
+ cursor: t ? void 0 : "pointer",
380
+ padding: t ? void 0 : "var(--ginger-playlist-row-padding, 6px 8px)"
381
+ },
382
+ children: o ? o(y, k, b, u) : /* @__PURE__ */ Ae("span", { children: [
383
+ /* @__PURE__ */ d("span", { style: { opacity: 0.75, marginRight: "0.35em" }, children: i(y.startSeconds) }),
384
+ y.title
385
+ ] })
386
+ }
387
+ ) }, `${y.startSeconds}-${y.title}`);
388
+ }) });
389
+ }
390
+ We.displayName = "Ginger.Current.Chapters";
391
+ function qe({ visible: e = !1, className: r, style: n, fallback: a, empty: t, children: i }) {
392
+ var s;
393
+ const o = I();
394
+ if (!e) return null;
395
+ const u = ((s = V(o)) == null ? void 0 : s.fileUrl) ?? "";
396
+ if (!u) {
397
+ const c = t ?? a ?? null;
398
+ return c ? /* @__PURE__ */ d("span", { className: r, style: n, children: c }) : null;
399
+ }
400
+ return i ? /* @__PURE__ */ d("span", { className: r, style: n, children: i(u, o) }) : /* @__PURE__ */ d("span", { className: r, style: n, children: u });
401
+ }
402
+ qe.displayName = "Ginger.Current.FileUrl";
403
+ function Je({
404
+ className: e,
405
+ style: r,
406
+ fallback: n,
407
+ empty: a,
408
+ sizes: t,
409
+ loading: i,
410
+ onError: o,
411
+ decoding: u,
412
+ unstyled: s = !1,
413
+ imgStyle: c
414
+ }) {
415
+ const g = I(), m = V(g), y = Xr(g);
416
+ if (!y) {
417
+ const b = a ?? n ?? null;
418
+ return b ? /* @__PURE__ */ d("span", { className: e, style: r, children: b }) : null;
419
+ }
420
+ const k = [m == null ? void 0 : m.title, m == null ? void 0 : m.artist].filter(Boolean).join(" — ") || "Artwork";
421
+ return /* @__PURE__ */ d(
422
+ "div",
423
+ {
424
+ className: e,
425
+ style: s ? { ...r } : {
426
+ background: "var(--ginger-artwork-bg, transparent)",
427
+ borderRadius: "var(--ginger-artwork-radius, 0)",
428
+ overflow: "hidden",
429
+ ...r
430
+ },
431
+ children: /* @__PURE__ */ d(
432
+ "img",
433
+ {
434
+ src: y,
435
+ alt: k,
436
+ sizes: t,
437
+ loading: i,
438
+ decoding: u,
439
+ onError: o,
440
+ style: {
441
+ display: s ? void 0 : "block",
442
+ width: s ? void 0 : "100%",
443
+ height: s ? void 0 : "100%",
444
+ objectFit: s ? void 0 : "cover",
445
+ ...c
446
+ }
447
+ }
448
+ )
449
+ }
450
+ );
451
+ }
452
+ Je.displayName = "Ginger.Current.Artwork";
453
+ function Ze({ base: e = 0, className: r, style: n, fallback: a, empty: t, children: i }) {
454
+ const o = I();
455
+ if (o.tracks.length === 0) {
456
+ const c = t ?? a ?? null;
457
+ return c ? /* @__PURE__ */ d("span", { className: r, style: n, children: c }) : null;
458
+ }
459
+ const s = String(o.currentIndex + e);
460
+ return i ? /* @__PURE__ */ d("span", { className: r, style: n, children: i(s, o) }) : /* @__PURE__ */ d("span", { className: r, style: n, children: s });
461
+ }
462
+ Ze.displayName = "Ginger.Current.QueueIndex";
463
+ function er({ className: e, style: r, fallback: n, empty: a, children: t }) {
464
+ const i = I(), o = String(i.tracks.length);
465
+ if (i.tracks.length === 0) {
466
+ const u = a ?? n ?? null;
467
+ return u ? /* @__PURE__ */ d("span", { className: e, style: r, children: u }) : null;
468
+ }
469
+ return t ? /* @__PURE__ */ d("span", { className: e, style: r, children: t(o, i) }) : /* @__PURE__ */ d("span", { className: e, style: r, children: o });
470
+ }
471
+ er.displayName = "Ginger.Current.QueueLength";
472
+ function rr({
473
+ base: e = 0,
474
+ separator: r = " / ",
475
+ className: n,
476
+ style: a,
477
+ fallback: t,
478
+ empty: i,
479
+ children: o
480
+ }) {
481
+ const u = I(), s = u.tracks.length;
482
+ if (s === 0) {
483
+ const y = i ?? t ?? null;
484
+ return y ? /* @__PURE__ */ d("span", { className: n, style: a, children: y }) : null;
485
+ }
486
+ const c = String(u.currentIndex + e), g = String(s), m = `${c}${r}${g}`;
487
+ return o ? /* @__PURE__ */ d("span", { className: n, style: a, children: o({ index: c, length: g, label: m }, u) }) : /* @__PURE__ */ d("span", { className: n, style: a, children: m });
488
+ }
489
+ rr.displayName = "Ginger.Current.QueuePosition";
490
+ function we(e, r, n) {
491
+ const { className: a, style: t, fallback: i, empty: o, children: u, format: s = z } = n;
492
+ if (!(e >= 0) || !Number.isFinite(e)) {
493
+ const g = o ?? i ?? null;
494
+ return g ? /* @__PURE__ */ d("span", { className: a, style: t, children: g }) : null;
495
+ }
496
+ const c = s(e);
497
+ return u ? /* @__PURE__ */ d("span", { className: a, style: t, children: u(c, r) }) : /* @__PURE__ */ d("span", { className: a, style: t, children: c });
498
+ }
499
+ function nr(e) {
500
+ const r = I();
501
+ return we(r.currentTime, r, e);
502
+ }
503
+ nr.displayName = "Ginger.Current.Elapsed";
504
+ function tr(e) {
505
+ const r = I();
506
+ return we(q(r), r, e);
507
+ }
508
+ tr.displayName = "Ginger.Current.Duration";
509
+ function ar(e) {
510
+ const r = I();
511
+ return we(Kr(r), r, e);
512
+ }
513
+ ar.displayName = "Ginger.Current.Remaining";
514
+ function ir({ className: e, style: r, fallback: n, empty: a, children: t }) {
515
+ const i = I(), o = q(i), u = je(i);
516
+ if (!(o > 0)) {
517
+ const s = a ?? n ?? null;
518
+ return s ? /* @__PURE__ */ d("span", { className: e, style: r, children: s }) : null;
519
+ }
520
+ return t ? /* @__PURE__ */ d("span", { className: e, style: r, children: t({ fraction: u, currentTime: i.currentTime, duration: o }, i) }) : /* @__PURE__ */ d("span", { className: e, style: r, children: `${Math.round(u * 100)}%` });
521
+ }
522
+ ir.displayName = "Ginger.Current.Progress";
523
+ function or({
524
+ className: e,
525
+ style: r,
526
+ height: n = 4,
527
+ showBuffered: a = !1,
528
+ unstyled: t = !1
529
+ }) {
530
+ const i = I(), o = `${Math.round(je(i) * 100)}%`, u = `${Math.round(Math.min(1, Math.max(0, i.bufferedFraction)) * 100)}%`;
531
+ return /* @__PURE__ */ Ae(
532
+ "div",
533
+ {
534
+ className: e,
535
+ style: t ? { ...r } : {
536
+ width: "100%",
537
+ height: n,
538
+ background: "var(--ginger-muted-color, #e5e7eb)",
539
+ borderRadius: 999,
540
+ overflow: "hidden",
541
+ position: "relative",
542
+ ...r
543
+ },
544
+ "aria-hidden": !0,
545
+ children: [
546
+ a ? /* @__PURE__ */ d(
547
+ "div",
548
+ {
549
+ style: {
550
+ position: t ? void 0 : "absolute",
551
+ left: t ? void 0 : 0,
552
+ top: t ? void 0 : 0,
553
+ height: t ? void 0 : "100%",
554
+ width: u,
555
+ background: t ? void 0 : "var(--ginger-buffer-color, rgba(107, 114, 128, 0.35))"
556
+ }
557
+ }
558
+ ) : null,
559
+ /* @__PURE__ */ d(
560
+ "div",
561
+ {
562
+ style: {
563
+ position: t ? void 0 : "relative",
564
+ width: o,
565
+ height: t ? void 0 : "100%",
566
+ background: t ? void 0 : "var(--ginger-primary-color, #111827)"
567
+ }
568
+ }
569
+ )
570
+ ]
571
+ }
572
+ );
573
+ }
574
+ or.displayName = "Ginger.Current.TimeRail";
575
+ function ur({ className: e, style: r, height: n = 4, unstyled: a = !1 }) {
576
+ const t = I(), i = `${Math.round(Math.min(1, Math.max(0, t.bufferedFraction)) * 100)}%`;
577
+ return /* @__PURE__ */ d(
578
+ "div",
579
+ {
580
+ className: e,
581
+ style: a ? { ...r } : {
582
+ width: "100%",
583
+ height: n,
584
+ background: "var(--ginger-muted-color, #e5e7eb)",
585
+ borderRadius: 999,
586
+ overflow: "hidden",
587
+ ...r
588
+ },
589
+ "aria-hidden": !0,
590
+ children: /* @__PURE__ */ d(
591
+ "div",
592
+ {
593
+ style: {
594
+ width: i,
595
+ height: a ? void 0 : "100%",
596
+ background: a ? void 0 : "var(--ginger-buffer-color, rgba(107, 114, 128, 0.35))"
597
+ }
598
+ }
599
+ )
600
+ }
601
+ );
602
+ }
603
+ ur.displayName = "Ginger.Current.BufferRail";
604
+ function sr({ className: e, style: r, fallback: n, empty: a, children: t }) {
605
+ const i = I(), o = He(i);
606
+ return t ? /* @__PURE__ */ d("span", { className: e, style: r, children: t(o, i) }) : /* @__PURE__ */ d("span", { className: e, style: r, children: o });
607
+ }
608
+ sr.displayName = "Ginger.Current.PlaybackState";
609
+ function lr({ className: e, style: r, fallback: n, empty: a, live: t = "polite", children: i }) {
610
+ const o = I(), u = o.errorMessage ?? "";
611
+ if (!u) {
612
+ const s = a ?? n ?? null;
613
+ return s ? /* @__PURE__ */ d("span", { className: e, style: r, children: s }) : null;
614
+ }
615
+ return i ? /* @__PURE__ */ d("span", { className: e, style: r, "aria-live": t, children: i(u, o) }) : /* @__PURE__ */ d("span", { className: e, style: r, "aria-live": t, children: u });
616
+ }
617
+ lr.displayName = "Ginger.Current.ErrorMessage";
618
+ const Ie = {
619
+ seek: "Seek",
620
+ volume: "Volume",
621
+ playbackSpeed: "Playback speed",
622
+ nextTrack: "Next track",
623
+ previousTrack: "Previous track",
624
+ shuffle: "Shuffle",
625
+ mute: "Mute",
626
+ unmute: "Unmute",
627
+ play: "Play",
628
+ pause: "Pause",
629
+ repeat: {
630
+ off: "Repeat off",
631
+ all: "Repeat all",
632
+ one: "Repeat one"
633
+ },
634
+ playbackRateNormal: "1× normal",
635
+ playbackRateTimes: (e) => `${e}×`
636
+ };
637
+ function ln(e) {
638
+ return e ? {
639
+ ...Ie,
640
+ ...e,
641
+ repeat: { ...Ie.repeat, ...e.repeat }
642
+ } : Ie;
643
+ }
644
+ const cr = Ne(Ie);
645
+ function cn({
646
+ locale: e,
647
+ children: r
648
+ }) {
649
+ const n = ln(e);
650
+ return /* @__PURE__ */ d(cr.Provider, { value: n, children: r });
651
+ }
652
+ function N() {
653
+ return Ge(cr);
654
+ }
655
+ function dn() {
656
+ const e = _(), r = j(), n = N(), a = P(() => $e(e, r), [e, r]), t = q(a), i = t > 0 ? a.currentTime : 0, o = Number.isFinite(i) ? i : 0, u = t > 0 ? `${z(o)} of ${z(t)}` : z(o), s = (c) => {
657
+ r.seek(Number(c.currentTarget.value));
658
+ };
659
+ return {
660
+ state: a,
661
+ value: o,
662
+ min: 0,
663
+ max: t > 0 ? t : 1,
664
+ step: "any",
665
+ ariaValueText: u,
666
+ ariaLabel: n.seek,
667
+ onSeekInput: s,
668
+ onSeekChange: s
669
+ };
670
+ }
671
+ function fn() {
672
+ const e = _(), r = j(), n = N(), a = P(() => $e(e, r), [e, r]), t = (i) => {
673
+ r.setVolume(Number(i.currentTarget.value));
674
+ };
675
+ return {
676
+ state: a,
677
+ value: a.volume,
678
+ min: 0,
679
+ max: 1,
680
+ step: "any",
681
+ ariaValueText: `${Math.round(a.volume * 100)}%`,
682
+ ariaLabel: n.volume,
683
+ onVolumeInput: t,
684
+ onVolumeChange: t
685
+ };
686
+ }
687
+ function pn(e) {
688
+ const r = _(), n = N(), a = (e == null ? void 0 : e.playAriaLabel) ?? n.play, t = (e == null ? void 0 : e.pauseAriaLabel) ?? n.pause;
689
+ return {
690
+ isPaused: r.isPaused,
691
+ toggle: r.togglePlayPause,
692
+ ariaLabel: r.isPaused ? a : t
693
+ };
694
+ }
695
+ function dr({
696
+ playLabel: e = "Play",
697
+ pauseLabel: r = "Pause",
698
+ playAriaLabel: n,
699
+ pauseAriaLabel: a,
700
+ children: t,
701
+ type: i = "button",
702
+ onClick: o,
703
+ ...u
704
+ }) {
705
+ const s = N(), c = typeof e == "string" ? e : s.play, g = typeof r == "string" ? r : s.pause, m = pn({
706
+ playAriaLabel: n ?? c,
707
+ pauseAriaLabel: a ?? g
708
+ });
709
+ return /* @__PURE__ */ d(
710
+ "button",
711
+ {
712
+ ...u,
713
+ type: i,
714
+ "aria-label": m.ariaLabel,
715
+ onClick: (y) => {
716
+ m.toggle(), o == null || o(y);
717
+ },
718
+ children: t ?? (m.isPaused ? e : r)
719
+ }
720
+ );
721
+ }
722
+ dr.displayName = "Ginger.Control.PlayPause";
723
+ function fr({ type: e = "button", ariaLabel: r, onClick: n, ...a }) {
724
+ const { repeatMode: t, cycleRepeat: i } = _(), u = N().repeat[t];
725
+ return /* @__PURE__ */ d(
726
+ "button",
727
+ {
728
+ ...a,
729
+ type: e,
730
+ "aria-label": r ?? u,
731
+ onClick: (s) => {
732
+ i(), n == null || n(s);
733
+ },
734
+ children: u
735
+ }
736
+ );
737
+ }
738
+ fr.displayName = "Ginger.Control.Repeat";
739
+ function pr({
740
+ type: e = "button",
741
+ children: r = "Next",
742
+ ariaLabel: n,
743
+ onClick: a,
744
+ ...t
745
+ }) {
746
+ const { next: i } = _(), o = N();
747
+ return /* @__PURE__ */ d(
748
+ "button",
749
+ {
750
+ ...t,
751
+ type: e,
752
+ "aria-label": n ?? o.nextTrack,
753
+ onClick: (u) => {
754
+ i(), a == null || a(u);
755
+ },
756
+ children: r
757
+ }
758
+ );
759
+ }
760
+ pr.displayName = "Ginger.Control.Next";
761
+ function gr({
762
+ type: e = "button",
763
+ children: r = "Previous",
764
+ ariaLabel: n,
765
+ onClick: a,
766
+ ...t
767
+ }) {
768
+ const { prev: i } = _(), o = N();
769
+ return /* @__PURE__ */ d(
770
+ "button",
771
+ {
772
+ ...t,
773
+ type: e,
774
+ "aria-label": n ?? o.previousTrack,
775
+ onClick: (u) => {
776
+ i(), a == null || a(u);
777
+ },
778
+ children: r
779
+ }
780
+ );
781
+ }
782
+ gr.displayName = "Ginger.Control.Previous";
783
+ function mr({
784
+ type: e = "button",
785
+ children: r = "Shuffle",
786
+ ariaLabel: n,
787
+ onClick: a,
788
+ ...t
789
+ }) {
790
+ const { isShuffled: i, toggleShuffle: o } = _(), u = N();
791
+ return /* @__PURE__ */ d(
792
+ "button",
793
+ {
794
+ ...t,
795
+ type: e,
796
+ "aria-pressed": i,
797
+ "aria-label": n ?? u.shuffle,
798
+ onClick: (s) => {
799
+ o(), a == null || a(s);
800
+ },
801
+ children: r
802
+ }
803
+ );
804
+ }
805
+ mr.displayName = "Ginger.Control.Shuffle";
806
+ function yr({ inputStyle: e, style: r, unstyled: n = !1, ariaLabel: a, ...t }) {
807
+ const i = dn(), o = n ? { ...r, ...e } : { width: "100%", ...r, ...e };
808
+ return /* @__PURE__ */ d(
809
+ "input",
810
+ {
811
+ ...t,
812
+ type: "range",
813
+ min: i.min,
814
+ max: i.max,
815
+ step: i.step,
816
+ value: i.value,
817
+ "aria-label": a ?? i.ariaLabel,
818
+ "aria-valuetext": i.ariaValueText,
819
+ onInput: i.onSeekInput,
820
+ onChange: i.onSeekChange,
821
+ style: o
822
+ }
823
+ );
824
+ }
825
+ yr.displayName = "Ginger.Control.SeekBar";
826
+ function hr({ inputStyle: e, style: r, unstyled: n = !1, ariaLabel: a, ...t }) {
827
+ const i = fn(), o = n ? { ...r, ...e } : { width: "100%", ...r, ...e };
828
+ return /* @__PURE__ */ d(
829
+ "input",
830
+ {
831
+ ...t,
832
+ type: "range",
833
+ min: i.min,
834
+ max: i.max,
835
+ step: i.step,
836
+ value: i.value,
837
+ "aria-label": a ?? i.ariaLabel,
838
+ "aria-valuetext": i.ariaValueText,
839
+ onInput: i.onVolumeInput,
840
+ onChange: i.onVolumeChange,
841
+ style: o
842
+ }
843
+ );
844
+ }
845
+ hr.displayName = "Ginger.Control.Volume";
846
+ function br({
847
+ ariaLabel: e,
848
+ muteLabel: r,
849
+ unmuteLabel: n,
850
+ type: a = "button",
851
+ onClick: t,
852
+ ...i
853
+ }) {
854
+ const { muted: o, toggleMute: u } = j(), s = N(), c = r ?? s.mute, g = n ?? s.unmute;
855
+ return /* @__PURE__ */ d(
856
+ "button",
857
+ {
858
+ ...i,
859
+ type: a,
860
+ "aria-pressed": o,
861
+ "aria-label": e ?? (o ? s.unmute : s.mute),
862
+ onClick: (m) => {
863
+ u(), t == null || t(m);
864
+ },
865
+ children: o ? g : c
866
+ }
867
+ );
868
+ }
869
+ br.displayName = "Ginger.Control.Mute";
870
+ const gn = [0.5, 0.75, 1, 1.25, 1.5, 2];
871
+ function vr({
872
+ rates: e = gn,
873
+ style: r,
874
+ ariaLabel: n,
875
+ ...a
876
+ }) {
877
+ const { playbackRate: t, setPlaybackRate: i } = j(), o = N(), u = P(
878
+ () => Array.from(/* @__PURE__ */ new Set([...e, t])).sort((s, c) => s - c),
879
+ [e, t]
880
+ );
881
+ return /* @__PURE__ */ d(
882
+ "select",
883
+ {
884
+ ...a,
885
+ "aria-label": n ?? o.playbackSpeed,
886
+ value: String(t),
887
+ style: r,
888
+ onChange: (s) => i(Number(s.currentTarget.value)),
889
+ children: u.map((s) => /* @__PURE__ */ d("option", { value: String(s), children: s === 1 ? o.playbackRateNormal : o.playbackRateTimes(s) }, s))
890
+ }
891
+ );
892
+ }
893
+ vr.displayName = "Ginger.Control.PlaybackRate";
894
+ const _e = Ne(null);
895
+ function mn() {
896
+ const e = Ge(_e);
897
+ if (!e)
898
+ throw new Error("Ginger.Playlist.Track must be used inside <Ginger.Playlist>");
899
+ return e;
900
+ }
901
+ function kr({
902
+ children: e,
903
+ unstyled: r = !1,
904
+ rowStyle: n,
905
+ renderTrack: a,
906
+ playOnSelect: t = !0,
907
+ style: i,
908
+ ...o
909
+ }) {
910
+ const { tracks: u, currentIndex: s, playTrackAt: c, selectTrackAt: g } = _(), m = r ? { ...i } : {
911
+ listStyle: "none",
912
+ margin: 0,
913
+ padding: 0,
914
+ fontFamily: "var(--ginger-font-family, system-ui, sans-serif)",
915
+ fontSize: "var(--ginger-font-size, 14px)",
916
+ color: "var(--ginger-primary-color, #111827)",
917
+ ...i
918
+ };
919
+ return e !== void 0 ? /* @__PURE__ */ d(_e.Provider, { value: { playOnSelect: t }, children: /* @__PURE__ */ d("ul", { style: m, ...o, children: e }) }) : /* @__PURE__ */ d(_e.Provider, { value: { playOnSelect: t }, children: /* @__PURE__ */ d("ul", { style: m, ...o, children: u.map((k, b) => {
920
+ const S = b === s;
921
+ return /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d(
922
+ "button",
923
+ {
924
+ type: "button",
925
+ onClick: () => {
926
+ t ? c(b) : g(b);
927
+ },
928
+ style: {
929
+ width: r ? void 0 : "100%",
930
+ textAlign: r ? void 0 : "left",
931
+ border: r ? void 0 : "none",
932
+ background: r ? void 0 : S ? "var(--ginger-playlist-active-bg, rgba(17, 24, 39, 0.06))" : "transparent",
933
+ color: r ? void 0 : "inherit",
934
+ font: r ? void 0 : "inherit",
935
+ cursor: r ? void 0 : "pointer",
936
+ padding: r ? void 0 : "var(--ginger-playlist-row-padding, 6px 8px)",
937
+ ...n
938
+ },
939
+ children: a ? a(k, b, S) : /* @__PURE__ */ Ae("span", { children: [
940
+ k.title,
941
+ k.artist ? ` — ${k.artist}` : ""
942
+ ] })
943
+ }
944
+ ) }, `${b}-${W(k)}`);
945
+ }) }) });
946
+ }
947
+ kr.displayName = "Ginger.Playlist";
948
+ function Mr({
949
+ index: e,
950
+ unstyled: r = !1,
951
+ className: n,
952
+ style: a,
953
+ children: t,
954
+ liProps: i,
955
+ onClick: o,
956
+ ...u
957
+ }) {
958
+ const { playOnSelect: s } = mn(), { tracks: c, currentIndex: g, playTrackAt: m, selectTrackAt: y } = _(), k = e === g, b = c[e], S = b != null ? /* @__PURE__ */ Ae("span", { children: [
959
+ b.title,
960
+ b.artist ? ` — ${b.artist}` : ""
961
+ ] }) : null;
962
+ return /* @__PURE__ */ d("li", { ...i, children: /* @__PURE__ */ d(
963
+ "button",
964
+ {
965
+ type: "button",
966
+ "aria-current": k ? "true" : void 0,
967
+ "data-ginger-active": k || void 0,
968
+ className: n,
969
+ style: {
970
+ width: r ? void 0 : "100%",
971
+ textAlign: r ? void 0 : "left",
972
+ border: r ? void 0 : "none",
973
+ background: r ? void 0 : k ? "var(--ginger-playlist-active-bg, rgba(17, 24, 39, 0.06))" : "transparent",
974
+ color: r ? void 0 : "inherit",
975
+ font: r ? void 0 : "inherit",
976
+ cursor: r ? void 0 : "pointer",
977
+ padding: r ? void 0 : "var(--ginger-playlist-row-padding, 6px 8px)",
978
+ ...a
979
+ },
980
+ ...u,
981
+ onClick: (p) => {
982
+ o == null || o(p), !p.defaultPrevented && (s ? m(e) : y(e));
983
+ },
984
+ children: t ?? S
985
+ }
986
+ ) });
987
+ }
988
+ Mr.displayName = "Ginger.Playlist.Track";
989
+ const yn = Object.assign(kr, {
990
+ Track: Mr
991
+ }), hn = B("Ginger.Queue.Title", (e) => {
992
+ var r;
993
+ return (r = e.playlistMeta) == null ? void 0 : r.title;
994
+ }), bn = B("Ginger.Queue.Subtitle", (e) => {
995
+ var r;
996
+ return (r = e.playlistMeta) == null ? void 0 : r.subtitle;
997
+ }), vn = B("Ginger.Queue.Description", (e) => {
998
+ var r;
999
+ return (r = e.playlistMeta) == null ? void 0 : r.description;
1000
+ }), kn = B("Ginger.Queue.Copyright", (e) => {
1001
+ var r;
1002
+ return (r = e.playlistMeta) == null ? void 0 : r.copyright;
1003
+ });
1004
+ function xr({ className: e, style: r, fallback: n, empty: a, unstyled: t = !1, imgStyle: i }) {
1005
+ var c, g;
1006
+ const o = I(), u = (c = o.playlistMeta) == null ? void 0 : c.artworkUrl;
1007
+ if (!u) {
1008
+ const m = a ?? n ?? null;
1009
+ return m ? /* @__PURE__ */ d("span", { className: e, style: r, children: m }) : null;
1010
+ }
1011
+ const s = ((g = o.playlistMeta) == null ? void 0 : g.title) ?? "Playlist artwork";
1012
+ return /* @__PURE__ */ d(
1013
+ "span",
1014
+ {
1015
+ className: e,
1016
+ style: t ? { ...r } : {
1017
+ display: "inline-block",
1018
+ background: "var(--ginger-artwork-bg, #f3f4f6)",
1019
+ borderRadius: "var(--ginger-artwork-radius, 6px)",
1020
+ overflow: "hidden",
1021
+ ...r
1022
+ },
1023
+ children: /* @__PURE__ */ d(
1024
+ "img",
1025
+ {
1026
+ src: u,
1027
+ alt: s,
1028
+ style: {
1029
+ display: t ? void 0 : "block",
1030
+ width: t ? void 0 : "100%",
1031
+ height: t ? void 0 : "100%",
1032
+ objectFit: t ? void 0 : "cover",
1033
+ ...i
1034
+ }
1035
+ }
1036
+ )
1037
+ }
1038
+ );
1039
+ }
1040
+ xr.displayName = "Ginger.Queue.Artwork";
1041
+ function Ee(e) {
1042
+ return Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 1;
1043
+ }
1044
+ function Ce(e) {
1045
+ return Number.isFinite(e) ? Math.min(4, Math.max(0.25, e)) : 1;
1046
+ }
1047
+ const U = {
1048
+ currentTime: 0,
1049
+ duration: 0,
1050
+ bufferedFraction: 0,
1051
+ isBuffering: !1,
1052
+ errorMessage: null
1053
+ }, Mn = {
1054
+ ...U,
1055
+ volume: 1,
1056
+ muted: !1,
1057
+ playbackRate: 1
1058
+ };
1059
+ function Tr(e) {
1060
+ const r = [...e.tracks];
1061
+ let n = A(e.currentIndex ?? 0, r.length), a = null, t = r;
1062
+ return e.isShuffled && r.length > 1 && (a = [...r], t = Be(r, n), n = 0), {
1063
+ tracks: t,
1064
+ currentIndex: n,
1065
+ playbackMode: e.playbackMode ?? "playlist",
1066
+ isPaused: e.isPaused ?? !0,
1067
+ isShuffled: !!(e.isShuffled && t.length > 1),
1068
+ repeatMode: e.repeatMode ?? "off",
1069
+ originalTracks: a,
1070
+ playlistMeta: e.playlistMeta ?? null,
1071
+ ...Mn,
1072
+ volume: Ee(e.volume ?? 1),
1073
+ muted: e.muted ?? !1,
1074
+ playbackRate: Ce(e.playbackRate ?? 1)
1075
+ };
1076
+ }
1077
+ function xn(e, r) {
1078
+ switch (r.type) {
1079
+ case "INIT": {
1080
+ const {
1081
+ tracks: n,
1082
+ currentIndex: a,
1083
+ playlistMeta: t,
1084
+ isPaused: i,
1085
+ isShuffled: o,
1086
+ repeatMode: u,
1087
+ playbackMode: s,
1088
+ volume: c,
1089
+ muted: g,
1090
+ playbackRate: m
1091
+ } = r.payload;
1092
+ return Tr({
1093
+ tracks: n,
1094
+ currentIndex: a,
1095
+ playlistMeta: t ?? null,
1096
+ isPaused: i ?? !0,
1097
+ isShuffled: o ?? !1,
1098
+ repeatMode: u ?? "off",
1099
+ playbackMode: s ?? "playlist",
1100
+ volume: c,
1101
+ muted: g,
1102
+ playbackRate: m
1103
+ });
1104
+ }
1105
+ case "SET_QUEUE": {
1106
+ const { tracks: n, currentIndex: a } = r.payload, t = [...n], i = A(a ?? e.currentIndex, t.length);
1107
+ return {
1108
+ ...e,
1109
+ tracks: t,
1110
+ currentIndex: i,
1111
+ isShuffled: !1,
1112
+ originalTracks: null,
1113
+ ...U
1114
+ };
1115
+ }
1116
+ case "INSERT_TRACK": {
1117
+ const n = r.payload.index ?? e.tracks.length, a = Ye(e.tracks, r.payload.track, n);
1118
+ if (r.payload.autoPlay) {
1119
+ const i = A(n, a.length);
1120
+ return {
1121
+ ...e,
1122
+ tracks: a,
1123
+ currentIndex: i,
1124
+ isShuffled: !1,
1125
+ originalTracks: null,
1126
+ isPaused: !1,
1127
+ ...U
1128
+ };
1129
+ }
1130
+ const t = n <= e.currentIndex ? e.currentIndex + 1 : e.currentIndex;
1131
+ return {
1132
+ ...e,
1133
+ tracks: a,
1134
+ isShuffled: !1,
1135
+ originalTracks: null,
1136
+ currentIndex: A(t, a.length)
1137
+ };
1138
+ }
1139
+ case "REMOVE_TRACK": {
1140
+ const n = r.payload.index, a = Vr(e.tracks, n), t = n < e.currentIndex ? e.currentIndex - 1 : n === e.currentIndex ? Math.min(e.currentIndex, Math.max(0, a.length - 1)) : e.currentIndex;
1141
+ return {
1142
+ ...e,
1143
+ tracks: a,
1144
+ isShuffled: !1,
1145
+ originalTracks: null,
1146
+ currentIndex: A(t, a.length),
1147
+ ...n === e.currentIndex ? U : {}
1148
+ };
1149
+ }
1150
+ case "MOVE_TRACK": {
1151
+ const { fromIndex: n, toIndex: a } = r.payload, t = $r(e.tracks, n, a);
1152
+ let i = e.currentIndex;
1153
+ return e.currentIndex === n ? i = a : n < e.currentIndex && a >= e.currentIndex ? i -= 1 : n > e.currentIndex && a <= e.currentIndex && (i += 1), {
1154
+ ...e,
1155
+ tracks: t,
1156
+ isShuffled: !1,
1157
+ originalTracks: null,
1158
+ currentIndex: A(i, t.length)
1159
+ };
1160
+ }
1161
+ case "ADD_NEXT": {
1162
+ const n = Or(e.tracks, e.currentIndex, r.payload.track);
1163
+ return {
1164
+ ...e,
1165
+ tracks: n,
1166
+ isShuffled: !1,
1167
+ originalTracks: null
1168
+ };
1169
+ }
1170
+ case "SET_INDEX": {
1171
+ const n = A(r.payload.index, e.tracks.length), a = r.payload.autoPlay, t = a === !0 ? !1 : a === !1 ? !0 : e.isPaused;
1172
+ return {
1173
+ ...e,
1174
+ currentIndex: n,
1175
+ ...U,
1176
+ isPaused: t
1177
+ };
1178
+ }
1179
+ case "PLAY":
1180
+ return { ...e, isPaused: !1 };
1181
+ case "PAUSE":
1182
+ return { ...e, isPaused: !0 };
1183
+ case "TOGGLE_PAUSE":
1184
+ return { ...e, isPaused: !e.isPaused };
1185
+ case "SET_REPEAT":
1186
+ return { ...e, repeatMode: r.payload };
1187
+ case "CYCLE_REPEAT":
1188
+ return { ...e, repeatMode: Hr(e.repeatMode) };
1189
+ case "TOGGLE_SHUFFLE": {
1190
+ if (e.tracks.length <= 1) return { ...e, isShuffled: !1, originalTracks: null };
1191
+ if (!e.isShuffled) {
1192
+ const i = [...e.tracks], o = Be(i, e.currentIndex);
1193
+ return {
1194
+ ...e,
1195
+ isShuffled: !0,
1196
+ originalTracks: i,
1197
+ tracks: o,
1198
+ currentIndex: 0
1199
+ };
1200
+ }
1201
+ const n = e.originalTracks ? [...e.originalTracks] : [...e.tracks], a = e.tracks[e.currentIndex], t = Ur(n, a);
1202
+ return {
1203
+ ...e,
1204
+ isShuffled: !1,
1205
+ originalTracks: null,
1206
+ tracks: n,
1207
+ currentIndex: A(t, n.length)
1208
+ };
1209
+ }
1210
+ case "NEXT": {
1211
+ const n = Yr(e), a = n === e.currentIndex;
1212
+ return {
1213
+ ...e,
1214
+ currentIndex: n,
1215
+ ...a ? {} : U,
1216
+ isPaused: a ? e.isPaused : !1
1217
+ };
1218
+ }
1219
+ case "PREV": {
1220
+ const n = Qr(e), a = n === e.currentIndex;
1221
+ return {
1222
+ ...e,
1223
+ currentIndex: n,
1224
+ ...a ? {} : U,
1225
+ isPaused: a ? e.isPaused : !1
1226
+ };
1227
+ }
1228
+ case "MEDIA_TIME_UPDATE":
1229
+ return {
1230
+ ...e,
1231
+ currentTime: r.payload.currentTime,
1232
+ duration: Number.isFinite(r.payload.duration) ? r.payload.duration : e.duration,
1233
+ bufferedFraction: r.payload.bufferedFraction,
1234
+ isBuffering: !1
1235
+ };
1236
+ case "MEDIA_LOADED_METADATA":
1237
+ return {
1238
+ ...e,
1239
+ duration: Number.isFinite(r.payload.duration) ? r.payload.duration : e.duration,
1240
+ bufferedFraction: r.payload.bufferedFraction,
1241
+ errorMessage: null
1242
+ };
1243
+ case "SET_PLAYLIST_META":
1244
+ return { ...e, playlistMeta: r.payload };
1245
+ case "SET_PLAYBACK_MODE":
1246
+ return { ...e, playbackMode: r.payload };
1247
+ case "MEDIA_ERROR":
1248
+ return {
1249
+ ...e,
1250
+ errorMessage: r.payload.message,
1251
+ isPaused: !0,
1252
+ isBuffering: !1
1253
+ };
1254
+ case "MEDIA_WAITING":
1255
+ return { ...e, isBuffering: !0 };
1256
+ case "MEDIA_CANPLAY":
1257
+ return { ...e, isBuffering: !1, errorMessage: null };
1258
+ case "MEDIA_PLAY":
1259
+ return { ...e, isPaused: !1, isBuffering: !1 };
1260
+ case "MEDIA_PAUSE":
1261
+ return { ...e, isPaused: !0 };
1262
+ case "RESET_MEDIA_TIMES":
1263
+ return { ...e, currentTime: 0, duration: 0, bufferedFraction: 0 };
1264
+ case "MEDIA_SOURCE_CLEARED":
1265
+ return { ...e, ...U };
1266
+ case "SET_VOLUME":
1267
+ return { ...e, volume: Ee(r.payload) };
1268
+ case "SET_MUTED":
1269
+ return { ...e, muted: r.payload };
1270
+ case "TOGGLE_MUTE":
1271
+ return { ...e, muted: !e.muted };
1272
+ case "SET_PLAYBACK_RATE":
1273
+ return { ...e, playbackRate: Ce(r.payload) };
1274
+ case "MEDIA_VOLUME_SYNC": {
1275
+ const { volume: n, muted: a } = r.payload, t = Ee(n);
1276
+ return t === e.volume && a === e.muted ? e : { ...e, volume: t, muted: a };
1277
+ }
1278
+ default:
1279
+ return e;
1280
+ }
1281
+ }
1282
+ function Re() {
1283
+ return typeof navigator > "u" || !("mediaSession" in navigator) ? null : navigator.mediaSession;
1284
+ }
1285
+ function Tn(e, r, n) {
1286
+ var s;
1287
+ const a = r.tracks[r.currentIndex], t = a == null ? void 0 : a.title, i = a == null ? void 0 : a.artist, o = a == null ? void 0 : a.album, u = Qe(a, (s = r.playlistMeta) == null ? void 0 : s.artworkUrl);
1288
+ E(() => {
1289
+ const c = Re();
1290
+ !e || !c || (c.metadata = new MediaMetadata({
1291
+ title: t ?? "Unknown track",
1292
+ artist: i,
1293
+ album: o,
1294
+ artwork: u ? [{ src: u }] : void 0
1295
+ }));
1296
+ }, [e, t, i, o, u]), E(() => {
1297
+ const c = Re();
1298
+ !e || !c || (c.playbackState = r.isPaused ? "paused" : "playing");
1299
+ }, [e, r.isPaused]), E(() => {
1300
+ const c = Re();
1301
+ if (!(!e || !c)) {
1302
+ try {
1303
+ c.setActionHandler("play", n.play), c.setActionHandler("pause", n.pause), c.setActionHandler("nexttrack", n.next), c.setActionHandler("previoustrack", n.prev), c.setActionHandler("seekto", (g) => {
1304
+ typeof g.seekTime == "number" && Number.isFinite(g.seekTime) && n.seek(g.seekTime);
1305
+ });
1306
+ } catch {
1307
+ }
1308
+ return () => {
1309
+ try {
1310
+ c.setActionHandler("play", null), c.setActionHandler("pause", null), c.setActionHandler("nexttrack", null), c.setActionHandler("previoustrack", null), c.setActionHandler("seekto", null);
1311
+ } catch {
1312
+ }
1313
+ };
1314
+ }
1315
+ }, [e, n]);
1316
+ }
1317
+ const In = {
1318
+ "--ginger-primary-color": "#111827",
1319
+ "--ginger-muted-color": "#6b7280",
1320
+ "--ginger-font-size": "14px",
1321
+ "--ginger-font-family": "system-ui, sans-serif",
1322
+ "--ginger-playlist-row-padding": "6px 8px",
1323
+ "--ginger-artwork-radius": "6px",
1324
+ "--ginger-artwork-bg": "#f3f4f6",
1325
+ "--ginger-playlist-active-bg": "rgba(17, 24, 39, 0.06)",
1326
+ "--ginger-buffer-color": "rgba(107, 114, 128, 0.35)",
1327
+ "--ginger-focus-ring": "0 0 0 2px rgba(59, 130, 246, 0.45)"
1328
+ };
1329
+ function En({
1330
+ children: e,
1331
+ initialTracks: r = [],
1332
+ initialIndex: n = 0,
1333
+ initialPlaylistMeta: a = null,
1334
+ initialShuffle: t = !1,
1335
+ initialRepeatMode: i = "off",
1336
+ initialPlaybackMode: o = "playlist",
1337
+ initialPaused: u = !0,
1338
+ initialVolume: s = 1,
1339
+ initialMuted: c = !1,
1340
+ initialPlaybackRate: g = 1,
1341
+ initialStateKey: m,
1342
+ locale: y,
1343
+ mediaSession: k = !1,
1344
+ beforePlay: b,
1345
+ onPlayBlocked: S,
1346
+ persistence: p,
1347
+ hydrateOnMount: T = !1,
1348
+ resumeOnTrackChange: R = !1,
1349
+ unstyled: w = !1,
1350
+ className: Se,
1351
+ style: K,
1352
+ onTrackChange: J,
1353
+ onPlay: Z,
1354
+ onPause: ee,
1355
+ onQueueEnd: re,
1356
+ onError: ne
1357
+ }) {
1358
+ var Fe;
1359
+ const $ = O(null), [l, h] = wr(
1360
+ xn,
1361
+ void 0,
1362
+ () => Tr({
1363
+ tracks: r,
1364
+ currentIndex: n,
1365
+ playlistMeta: a,
1366
+ isPaused: u,
1367
+ isShuffled: t,
1368
+ repeatMode: i,
1369
+ playbackMode: o,
1370
+ volume: s,
1371
+ muted: c,
1372
+ playbackRate: g
1373
+ })
1374
+ ), Le = O(l), Pe = O({
1375
+ tracks: r,
1376
+ currentIndex: n,
1377
+ playlistMeta: a,
1378
+ isPaused: u,
1379
+ isShuffled: t,
1380
+ repeatMode: i,
1381
+ playbackMode: o,
1382
+ volume: s,
1383
+ muted: c,
1384
+ playbackRate: g
1385
+ });
1386
+ Pe.current = {
1387
+ tracks: r,
1388
+ currentIndex: n,
1389
+ playlistMeta: a,
1390
+ isPaused: u,
1391
+ isShuffled: t,
1392
+ repeatMode: i,
1393
+ playbackMode: o,
1394
+ volume: s,
1395
+ muted: c,
1396
+ playbackRate: g
1397
+ };
1398
+ const X = O(void 0);
1399
+ E(() => {
1400
+ if (m === void 0) {
1401
+ X.current = void 0;
1402
+ return;
1403
+ }
1404
+ if (X.current === void 0) {
1405
+ X.current = m;
1406
+ return;
1407
+ }
1408
+ if (X.current === m) return;
1409
+ X.current = m;
1410
+ const f = Pe.current;
1411
+ h({
1412
+ type: "INIT",
1413
+ payload: {
1414
+ tracks: f.tracks,
1415
+ currentIndex: f.currentIndex,
1416
+ playlistMeta: f.playlistMeta,
1417
+ isPaused: f.isPaused,
1418
+ isShuffled: f.isShuffled,
1419
+ repeatMode: f.repeatMode,
1420
+ playbackMode: f.playbackMode,
1421
+ volume: f.volume,
1422
+ muted: f.muted,
1423
+ playbackRate: f.playbackRate
1424
+ }
1425
+ });
1426
+ }, [m, h]), E(() => {
1427
+ Le.current = l;
1428
+ }, [l]);
1429
+ const De = l.tracks[l.currentIndex] ?? null;
1430
+ E(() => {
1431
+ J == null || J(De, l.currentIndex);
1432
+ }, [De, l.currentIndex, J]), E(() => {
1433
+ l.errorMessage && (ne == null || ne(l.errorMessage));
1434
+ }, [l.errorMessage, ne]);
1435
+ const te = O(void 0);
1436
+ E(() => {
1437
+ if (te.current === void 0) {
1438
+ te.current = l.isPaused;
1439
+ return;
1440
+ }
1441
+ te.current !== l.isPaused && (l.isPaused ? ee == null || ee() : Z == null || Z()), te.current = l.isPaused;
1442
+ }, [l.isPaused, ee, Z]);
1443
+ const L = v(() => {
1444
+ h({ type: "PLAY" });
1445
+ }, []), D = v(() => {
1446
+ var f;
1447
+ h({ type: "PAUSE" }), (f = $.current) == null || f.pause();
1448
+ }, []), ae = v(() => {
1449
+ l.isPaused ? L() : D();
1450
+ }, [D, L, l.isPaused]), F = v((f) => {
1451
+ const M = $.current;
1452
+ M && Number.isFinite(f) && (M.currentTime = Math.max(0, f));
1453
+ }, []), ie = v((f) => {
1454
+ h({ type: "SET_VOLUME", payload: Ee(f) });
1455
+ }, []), oe = v((f) => {
1456
+ h({ type: "SET_MUTED", payload: f });
1457
+ }, []), ue = v(() => {
1458
+ h({ type: "TOGGLE_MUTE" });
1459
+ }, []), se = v((f) => {
1460
+ h({ type: "SET_PLAYBACK_RATE", payload: Ce(f) });
1461
+ }, []), Q = v(() => {
1462
+ h({ type: "NEXT" });
1463
+ }, []), H = v(() => {
1464
+ h({ type: "PREV" });
1465
+ }, []), le = v((f) => {
1466
+ h({ type: "SET_REPEAT", payload: f });
1467
+ }, []), ce = v(() => {
1468
+ h({ type: "CYCLE_REPEAT" });
1469
+ }, []), de = v(() => {
1470
+ h({ type: "TOGGLE_SHUFFLE" });
1471
+ }, []), fe = v((f, M) => {
1472
+ h({ type: "SET_QUEUE", payload: { tracks: f, currentIndex: M } });
1473
+ }, []), pe = v((f, M, x) => {
1474
+ h({ type: "INSERT_TRACK", payload: { track: f, index: M, autoPlay: x } });
1475
+ }, []), ge = v((f) => {
1476
+ h({ type: "REMOVE_TRACK", payload: { index: f } });
1477
+ }, []), me = v((f, M) => {
1478
+ h({ type: "MOVE_TRACK", payload: { fromIndex: f, toIndex: M } });
1479
+ }, []), ye = v((f) => {
1480
+ h({ type: "ADD_NEXT", payload: { track: f } });
1481
+ }, []), he = v((f) => {
1482
+ h({ type: "SET_INDEX", payload: { index: f, autoPlay: !0 } });
1483
+ }, []), be = v((f) => {
1484
+ h({ type: "SET_INDEX", payload: { index: f, autoPlay: !1 } });
1485
+ }, []), ve = v((f) => {
1486
+ h({ type: "SET_PLAYLIST_META", payload: f });
1487
+ }, []), ke = v((f) => {
1488
+ h({ type: "SET_PLAYBACK_MODE", payload: f });
1489
+ }, []), Me = v((f) => {
1490
+ h({ type: "INIT", payload: f });
1491
+ }, []);
1492
+ E(() => {
1493
+ if (!p || !T) return;
1494
+ const f = p.get("ginger:volume"), M = p.get("ginger:muted"), x = p.get("ginger:playbackRate"), C = p.get("ginger:repeatMode"), Te = p.get("ginger:currentIndex"), G = Pe.current;
1495
+ h({
1496
+ type: "INIT",
1497
+ payload: {
1498
+ tracks: G.tracks,
1499
+ playlistMeta: G.playlistMeta,
1500
+ isPaused: G.isPaused,
1501
+ isShuffled: G.isShuffled,
1502
+ playbackMode: G.playbackMode,
1503
+ currentIndex: typeof Te == "number" ? Te : G.currentIndex,
1504
+ repeatMode: C === "off" || C === "all" || C === "one" ? C : G.repeatMode,
1505
+ volume: typeof f == "number" ? f : G.volume,
1506
+ muted: typeof M == "boolean" ? M : G.muted,
1507
+ playbackRate: typeof x == "number" ? x : G.playbackRate
1508
+ }
1509
+ });
1510
+ }, [T, p]), E(() => {
1511
+ p && (p.set("ginger:volume", l.volume), p.set("ginger:muted", l.muted), p.set("ginger:playbackRate", l.playbackRate), p.set("ginger:repeatMode", l.repeatMode), p.set("ginger:currentIndex", l.currentIndex));
1512
+ }, [p, l.volume, l.muted, l.playbackRate, l.repeatMode, l.currentIndex]), E(() => {
1513
+ if (!p || !R) return;
1514
+ const f = l.tracks[l.currentIndex];
1515
+ if (!f) return;
1516
+ const M = `ginger:resume:${W(f)}`, x = p.get(M);
1517
+ typeof x == "number" && Number.isFinite(x) && F(x);
1518
+ }, [p, R, l.currentIndex, l.tracks, F]), E(() => {
1519
+ if (!p || !R) return;
1520
+ const f = l.tracks[l.currentIndex];
1521
+ if (!f || !(l.currentTime >= 0)) return;
1522
+ const M = `ginger:resume:${W(f)}`, x = setTimeout(() => p.set(M, l.currentTime), 250);
1523
+ return () => clearTimeout(x);
1524
+ }, [p, R, l.currentIndex, l.tracks, l.currentTime]);
1525
+ const Ir = (Fe = l.tracks[l.currentIndex]) == null ? void 0 : Fe.fileUrl;
1526
+ E(() => {
1527
+ const f = $.current;
1528
+ if (!f) return;
1529
+ if (l.isPaused) {
1530
+ f.pause();
1531
+ return;
1532
+ }
1533
+ let M = !1;
1534
+ return (async () => {
1535
+ if (b) {
1536
+ let x = !1;
1537
+ try {
1538
+ x = await b();
1539
+ } catch (C) {
1540
+ const Te = C instanceof Error ? C.message : "beforePlay rejected";
1541
+ h({ type: "MEDIA_ERROR", payload: { message: Te } });
1542
+ return;
1543
+ }
1544
+ if (!x) {
1545
+ M || (h({ type: "PAUSE" }), S == null || S());
1546
+ return;
1547
+ }
1548
+ }
1549
+ M || f.play().catch((x) => {
1550
+ const C = x instanceof Error ? x.message : typeof x == "string" ? x : "Playback failed (e.g. autoplay blocked or unavailable source)";
1551
+ h({ type: "MEDIA_ERROR", payload: { message: C } });
1552
+ });
1553
+ })(), () => {
1554
+ M = !0;
1555
+ };
1556
+ }, [b, Ir, S, l.isPaused]);
1557
+ const xe = v(() => {
1558
+ const f = Br(Le.current);
1559
+ if (f.kind === "replay_same") {
1560
+ const x = $.current;
1561
+ x && (x.currentTime = 0), h({ type: "PLAY" });
1562
+ return;
1563
+ }
1564
+ if (f.kind === "stop") {
1565
+ h({ type: "PAUSE" }), re == null || re();
1566
+ return;
1567
+ }
1568
+ const M = f.nextIndex;
1569
+ h({ type: "SET_INDEX", payload: { index: M, autoPlay: !0 } });
1570
+ }, [re]), Er = P(
1571
+ () => ({ play: L, pause: D, next: Q, prev: H, seek: F }),
1572
+ [L, D, Q, H, F]
1573
+ );
1574
+ Tn(!!k, l, Er);
1575
+ const Ar = y != null && y.seek && /[\u0590-\u08FF]/.test(y.seek) ? "rtl" : "ltr", Sr = P(
1576
+ () => ({
1577
+ state: l,
1578
+ dispatch: h,
1579
+ audioRef: $,
1580
+ notifyEnded: xe,
1581
+ init: Me,
1582
+ play: L,
1583
+ pause: D,
1584
+ togglePlayPause: ae,
1585
+ seek: F,
1586
+ setVolume: ie,
1587
+ setMuted: oe,
1588
+ toggleMute: ue,
1589
+ setPlaybackRate: se,
1590
+ next: Q,
1591
+ prev: H,
1592
+ setRepeatMode: le,
1593
+ cycleRepeat: ce,
1594
+ toggleShuffle: de,
1595
+ setQueue: fe,
1596
+ insertTrackAt: pe,
1597
+ removeTrackAt: ge,
1598
+ moveTrack: me,
1599
+ enqueueNext: ye,
1600
+ playTrackAt: he,
1601
+ selectTrackAt: be,
1602
+ setPlaylistMeta: ve,
1603
+ setPlaybackMode: ke
1604
+ }),
1605
+ [
1606
+ ce,
1607
+ h,
1608
+ Me,
1609
+ Q,
1610
+ xe,
1611
+ D,
1612
+ L,
1613
+ he,
1614
+ pe,
1615
+ ge,
1616
+ me,
1617
+ ye,
1618
+ be,
1619
+ H,
1620
+ F,
1621
+ oe,
1622
+ se,
1623
+ fe,
1624
+ le,
1625
+ ve,
1626
+ ke,
1627
+ ie,
1628
+ l,
1629
+ ue,
1630
+ ae,
1631
+ de
1632
+ ]
1633
+ ), Pr = P(
1634
+ () => ({
1635
+ tracks: l.tracks,
1636
+ currentIndex: l.currentIndex,
1637
+ isPaused: l.isPaused,
1638
+ isShuffled: l.isShuffled,
1639
+ repeatMode: l.repeatMode,
1640
+ originalTracks: l.originalTracks,
1641
+ playlistMeta: l.playlistMeta,
1642
+ init: Me,
1643
+ play: L,
1644
+ pause: D,
1645
+ togglePlayPause: ae,
1646
+ next: Q,
1647
+ prev: H,
1648
+ setRepeatMode: le,
1649
+ cycleRepeat: ce,
1650
+ toggleShuffle: de,
1651
+ playbackMode: l.playbackMode,
1652
+ setQueue: fe,
1653
+ insertTrackAt: pe,
1654
+ removeTrackAt: ge,
1655
+ moveTrack: me,
1656
+ enqueueNext: ye,
1657
+ playTrackAt: he,
1658
+ selectTrackAt: be,
1659
+ setPlaylistMeta: ve,
1660
+ setPlaybackMode: ke,
1661
+ dispatch: h
1662
+ }),
1663
+ [
1664
+ l.tracks,
1665
+ l.currentIndex,
1666
+ l.isPaused,
1667
+ l.isShuffled,
1668
+ l.repeatMode,
1669
+ l.playbackMode,
1670
+ l.originalTracks,
1671
+ l.playlistMeta,
1672
+ Me,
1673
+ L,
1674
+ D,
1675
+ ae,
1676
+ Q,
1677
+ H,
1678
+ le,
1679
+ ce,
1680
+ de,
1681
+ fe,
1682
+ pe,
1683
+ ge,
1684
+ me,
1685
+ ye,
1686
+ he,
1687
+ be,
1688
+ ve,
1689
+ ke,
1690
+ h
1691
+ ]
1692
+ ), Rr = P(
1693
+ () => ({
1694
+ currentTime: l.currentTime,
1695
+ duration: l.duration,
1696
+ bufferedFraction: l.bufferedFraction,
1697
+ isBuffering: l.isBuffering,
1698
+ errorMessage: l.errorMessage,
1699
+ volume: l.volume,
1700
+ muted: l.muted,
1701
+ playbackRate: l.playbackRate,
1702
+ seek: F,
1703
+ setVolume: ie,
1704
+ setMuted: oe,
1705
+ toggleMute: ue,
1706
+ setPlaybackRate: se,
1707
+ audioRef: $,
1708
+ notifyEnded: xe,
1709
+ dispatch: h
1710
+ }),
1711
+ [
1712
+ l.currentTime,
1713
+ l.duration,
1714
+ l.bufferedFraction,
1715
+ l.isBuffering,
1716
+ l.errorMessage,
1717
+ l.volume,
1718
+ l.muted,
1719
+ l.playbackRate,
1720
+ F,
1721
+ ie,
1722
+ oe,
1723
+ ue,
1724
+ se,
1725
+ $,
1726
+ xe,
1727
+ h
1728
+ ]
1729
+ ), _r = He(l), Gr = P(
1730
+ () => w ? K : { ...In, ...K },
1731
+ [K, w]
1732
+ );
1733
+ return /* @__PURE__ */ d(cn, { locale: y, children: /* @__PURE__ */ d(Cr.Provider, { value: Pr, children: /* @__PURE__ */ d(Lr.Provider, { value: Rr, children: /* @__PURE__ */ d(Oe.Provider, { value: Sr, children: /* @__PURE__ */ d(
1734
+ "div",
1735
+ {
1736
+ className: Se,
1737
+ style: Gr,
1738
+ "data-ginger-playback": _r,
1739
+ dir: Ar,
1740
+ children: e
1741
+ }
1742
+ ) }) }) }) });
1743
+ }
1744
+ const Rn = {
1745
+ Provider: En,
1746
+ Player: Fr,
1747
+ Current: {
1748
+ Title: Wr,
1749
+ Artist: qr,
1750
+ Album: Jr,
1751
+ Description: Zr,
1752
+ Copyright: en,
1753
+ Genre: rn,
1754
+ Label: nn,
1755
+ Isrc: tn,
1756
+ TrackNumber: an,
1757
+ Year: Ke,
1758
+ Lyrics: Xe,
1759
+ LyricsSynced: ze,
1760
+ Chapters: We,
1761
+ FileUrl: qe,
1762
+ Artwork: Je,
1763
+ QueueIndex: Ze,
1764
+ QueueLength: er,
1765
+ QueuePosition: rr,
1766
+ Elapsed: nr,
1767
+ Duration: tr,
1768
+ Remaining: ar,
1769
+ Progress: ir,
1770
+ TimeRail: or,
1771
+ BufferRail: ur,
1772
+ PlaybackState: sr,
1773
+ ErrorMessage: lr
1774
+ },
1775
+ Queue: {
1776
+ Title: hn,
1777
+ Subtitle: bn,
1778
+ Description: vn,
1779
+ Copyright: kn,
1780
+ Artwork: xr
1781
+ },
1782
+ Control: {
1783
+ PlayPause: dr,
1784
+ Repeat: fr,
1785
+ Next: pr,
1786
+ Previous: gr,
1787
+ Shuffle: mr,
1788
+ SeekBar: yr,
1789
+ Volume: hr,
1790
+ Mute: br,
1791
+ PlaybackRate: vr
1792
+ },
1793
+ Playlist: yn
1794
+ };
1795
+ export {
1796
+ We as C,
1797
+ Rn as G,
1798
+ ze as L,
1799
+ Ee as a,
1800
+ He as b,
1801
+ Ce as c,
1802
+ Ie as d,
1803
+ N as e,
1804
+ un as f,
1805
+ pn as g,
1806
+ dn as h,
1807
+ fn as i,
1808
+ Xr as j,
1809
+ je as k,
1810
+ Kr as l,
1811
+ q as m,
1812
+ V as n,
1813
+ Yr as o,
1814
+ on as p,
1815
+ zr as r,
1816
+ sn as u
1817
+ };
1818
+ //# sourceMappingURL=ginger-8x4WzVmw.js.map