@lucaismyname/ginger 0.0.28 → 0.0.29

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