@lucaismyname/ginger 0.0.30 → 0.0.31

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 (66) hide show
  1. package/README.md +140 -8
  2. package/dist/analyzer/liveAudioGraph.d.ts +14 -1
  3. package/dist/analyzer/liveAudioGraph.d.ts.map +1 -1
  4. package/dist/analyzer/useGingerLiveAnalyzer.d.ts +6 -0
  5. package/dist/analyzer/useGingerLiveAnalyzer.d.ts.map +1 -1
  6. package/dist/client.cjs +1 -1
  7. package/dist/client.js +36 -29
  8. package/dist/client.js.map +1 -1
  9. package/dist/context/GingerProvider.d.ts +1 -1
  10. package/dist/context/GingerProvider.d.ts.map +1 -1
  11. package/dist/core/playbackReducer.d.ts.map +1 -1
  12. package/dist/equalizer/index.cjs +2 -0
  13. package/dist/equalizer/index.cjs.map +1 -0
  14. package/dist/equalizer/index.d.ts +3 -0
  15. package/dist/equalizer/index.d.ts.map +1 -0
  16. package/dist/equalizer/index.js +51 -0
  17. package/dist/equalizer/index.js.map +1 -0
  18. package/dist/equalizer/useGingerEqualizer.d.ts +41 -0
  19. package/dist/equalizer/useGingerEqualizer.d.ts.map +1 -0
  20. package/dist/ginger-L2ZFgzH4.js +2223 -0
  21. package/dist/ginger-L2ZFgzH4.js.map +1 -0
  22. package/dist/ginger-NEcOSSJD.cjs +2 -0
  23. package/dist/ginger-NEcOSSJD.cjs.map +1 -0
  24. package/dist/hooks/useGingerChapterProgress.d.ts +14 -0
  25. package/dist/hooks/useGingerChapterProgress.d.ts.map +1 -0
  26. package/dist/hooks/useGingerKeyboardShortcuts.d.ts +6 -0
  27. package/dist/hooks/useGingerKeyboardShortcuts.d.ts.map +1 -1
  28. package/dist/hooks/useGingerPlaybackHistory.d.ts +26 -0
  29. package/dist/hooks/useGingerPlaybackHistory.d.ts.map +1 -0
  30. package/dist/hooks/useGingerSleepTimer.d.ts.map +1 -1
  31. package/dist/hooks/useGingerVolumeFade.d.ts +22 -0
  32. package/dist/hooks/useGingerVolumeFade.d.ts.map +1 -0
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.d.ts +18 -2
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +36 -29
  37. package/dist/index.js.map +1 -1
  38. package/dist/liveAudioGraph-CmEsdLgZ.js +150 -0
  39. package/dist/liveAudioGraph-CmEsdLgZ.js.map +1 -0
  40. package/dist/liveAudioGraph-D1BXMv_u.cjs +2 -0
  41. package/dist/liveAudioGraph-D1BXMv_u.cjs.map +1 -0
  42. package/dist/selectors-BalBCc7X.js +127 -0
  43. package/dist/selectors-BalBCc7X.js.map +1 -0
  44. package/dist/selectors-YXnP8Y8g.cjs +2 -0
  45. package/dist/selectors-YXnP8Y8g.cjs.map +1 -0
  46. package/dist/store.d.ts +46 -0
  47. package/dist/store.d.ts.map +1 -0
  48. package/dist/testing/index.cjs +1 -1
  49. package/dist/testing/index.js +1 -1
  50. package/dist/testing/mockWebAudio.d.ts +15 -1
  51. package/dist/testing/mockWebAudio.d.ts.map +1 -1
  52. package/dist/types.d.ts +30 -8
  53. package/dist/types.d.ts.map +1 -1
  54. package/dist/useGingerChapterProgress-BOqUimE7.cjs +2 -0
  55. package/dist/useGingerChapterProgress-BOqUimE7.cjs.map +1 -0
  56. package/dist/useGingerChapterProgress-DLYdGytK.js +321 -0
  57. package/dist/useGingerChapterProgress-DLYdGytK.js.map +1 -0
  58. package/package.json +7 -2
  59. package/dist/ginger-DYlsaFGA.js +0 -2283
  60. package/dist/ginger-DYlsaFGA.js.map +0 -1
  61. package/dist/ginger-YDZhJqet.cjs +0 -2
  62. package/dist/ginger-YDZhJqet.cjs.map +0 -1
  63. package/dist/useNextTrackPrefetch-BZdly__j.js +0 -265
  64. package/dist/useNextTrackPrefetch-BZdly__j.js.map +0 -1
  65. package/dist/useNextTrackPrefetch-pBFiWDyx.cjs +0 -2
  66. package/dist/useNextTrackPrefetch-pBFiWDyx.cjs.map +0 -1
@@ -1,2283 +0,0 @@
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(
1282
- null
1283
- );
1284
- function wn() {
1285
- const e = Ce(Ne);
1286
- if (!e)
1287
- throw new Error(
1288
- "Ginger.Playlist.Track must be used inside <Ginger.Playlist>"
1289
- );
1290
- return e;
1291
- }
1292
- function Dr({
1293
- children: e,
1294
- unstyled: r = !1,
1295
- rowStyle: n,
1296
- renderTrack: a,
1297
- playOnSelect: t = !0,
1298
- style: i,
1299
- ...o
1300
- }) {
1301
- const { tracks: c, currentIndex: s, playTrackAt: l, selectTrackAt: g } = _(), m = r ? { ...i } : {
1302
- listStyle: "none",
1303
- margin: 0,
1304
- padding: 0,
1305
- fontFamily: "var(--ginger-font-family, system-ui, sans-serif)",
1306
- fontSize: "var(--ginger-font-size, 14px)",
1307
- color: "var(--ginger-primary-color, #111827)",
1308
- ...i
1309
- };
1310
- return e !== void 0 ? /* @__PURE__ */ u(Ne.Provider, { value: { playOnSelect: t }, children: /* @__PURE__ */ u("ul", { "data-ginger-component": "Playlist", 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) => {
1311
- const x = v === s;
1312
- return /* @__PURE__ */ u("li", { children: /* @__PURE__ */ u(
1313
- "button",
1314
- {
1315
- type: "button",
1316
- onClick: () => {
1317
- t ? l(v) : g(v);
1318
- },
1319
- style: {
1320
- width: r ? void 0 : "100%",
1321
- textAlign: r ? void 0 : "left",
1322
- border: r ? void 0 : "none",
1323
- background: r ? void 0 : x ? "var(--ginger-playlist-active-bg, rgba(17, 24, 39, 0.06))" : "transparent",
1324
- color: r ? void 0 : "inherit",
1325
- font: r ? void 0 : "inherit",
1326
- cursor: r ? void 0 : "pointer",
1327
- padding: r ? void 0 : "var(--ginger-playlist-row-padding, 6px 8px)",
1328
- ...n
1329
- },
1330
- children: a ? a(h, v, x) : /* @__PURE__ */ R("span", { children: [
1331
- h.title,
1332
- h.artist ? ` — ${h.artist}` : ""
1333
- ] })
1334
- }
1335
- ) }, `${v}-${J(h)}`);
1336
- }) }) });
1337
- }
1338
- Dr.displayName = "Ginger.Playlist";
1339
- function Fr({
1340
- index: e,
1341
- unstyled: r = !1,
1342
- className: n,
1343
- style: a,
1344
- children: t,
1345
- liProps: i,
1346
- onClick: o,
1347
- ...c
1348
- }) {
1349
- const { playOnSelect: s } = wn(), { tracks: l, currentIndex: g, playTrackAt: m, selectTrackAt: b } = _(), h = e === g, v = l[e], x = v != null ? /* @__PURE__ */ R("span", { "data-ginger-component": "PlaylistTrack", children: [
1350
- v.title,
1351
- v.artist ? ` — ${v.artist}` : ""
1352
- ] }) : null;
1353
- return /* @__PURE__ */ u("li", { ...i, "data-ginger-component": "PlaylistTrack", children: /* @__PURE__ */ u(
1354
- "button",
1355
- {
1356
- type: "button",
1357
- "data-ginger-component": "PlaylistTrackButton",
1358
- "aria-current": h ? "true" : void 0,
1359
- "data-ginger-active": h || void 0,
1360
- className: n,
1361
- style: {
1362
- width: r ? void 0 : "100%",
1363
- textAlign: r ? void 0 : "left",
1364
- border: r ? void 0 : "none",
1365
- background: r ? void 0 : h ? "var(--ginger-playlist-active-bg, rgba(17, 24, 39, 0.06))" : "transparent",
1366
- color: r ? void 0 : "inherit",
1367
- font: r ? void 0 : "inherit",
1368
- cursor: r ? void 0 : "pointer",
1369
- padding: r ? void 0 : "var(--ginger-playlist-row-padding, 6px 8px)",
1370
- ...a
1371
- },
1372
- ...c,
1373
- onClick: (f) => {
1374
- o == null || o(f), !f.defaultPrevented && (s ? m(e) : b(e));
1375
- },
1376
- children: t ?? x
1377
- }
1378
- ) });
1379
- }
1380
- Fr.displayName = "Ginger.Playlist.Track";
1381
- const _n = Object.assign(Dr, {
1382
- Track: Fr
1383
- }), Nn = H(
1384
- "Ginger.Queue.Title",
1385
- (e) => {
1386
- var r;
1387
- return (r = e.playlistMeta) == null ? void 0 : r.title;
1388
- }
1389
- ), Cn = H(
1390
- "Ginger.Queue.Subtitle",
1391
- (e) => {
1392
- var r;
1393
- return (r = e.playlistMeta) == null ? void 0 : r.subtitle;
1394
- }
1395
- ), Dn = H(
1396
- "Ginger.Queue.Description",
1397
- (e) => {
1398
- var r;
1399
- return (r = e.playlistMeta) == null ? void 0 : r.description;
1400
- }
1401
- ), Fn = H(
1402
- "Ginger.Queue.Copyright",
1403
- (e) => {
1404
- var r;
1405
- return (r = e.playlistMeta) == null ? void 0 : r.copyright;
1406
- }
1407
- );
1408
- function Ur({
1409
- className: e,
1410
- style: r,
1411
- fallback: n,
1412
- empty: a,
1413
- unstyled: t = !1,
1414
- imgStyle: i
1415
- }) {
1416
- var l, g;
1417
- const o = P(), c = (l = o.playlistMeta) == null ? void 0 : l.artworkUrl;
1418
- if (!c) {
1419
- const m = a ?? n ?? null;
1420
- return m ? /* @__PURE__ */ u("span", { className: e, style: r, children: m }) : null;
1421
- }
1422
- const s = ((g = o.playlistMeta) == null ? void 0 : g.title) ?? "Playlist artwork";
1423
- return /* @__PURE__ */ u(
1424
- "span",
1425
- {
1426
- "data-ginger-component": "Artwork",
1427
- className: e,
1428
- style: t ? { ...r } : {
1429
- display: "inline-block",
1430
- background: "var(--ginger-artwork-bg, #f3f4f6)",
1431
- borderRadius: "var(--ginger-artwork-radius, 6px)",
1432
- overflow: "hidden",
1433
- ...r
1434
- },
1435
- children: /* @__PURE__ */ u(
1436
- "img",
1437
- {
1438
- src: c,
1439
- alt: s,
1440
- style: {
1441
- display: t ? void 0 : "block",
1442
- width: t ? void 0 : "100%",
1443
- height: t ? void 0 : "100%",
1444
- objectFit: t ? void 0 : "cover",
1445
- ...i
1446
- }
1447
- }
1448
- )
1449
- }
1450
- );
1451
- }
1452
- Ur.displayName = "Ginger.Queue.Artwork";
1453
- function Re(e) {
1454
- return Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 1;
1455
- }
1456
- function Ue(e) {
1457
- return Number.isFinite(e) ? Math.min(4, Math.max(0.25, e)) : 1;
1458
- }
1459
- const $ = {
1460
- currentTime: 0,
1461
- duration: 0,
1462
- bufferedFraction: 0,
1463
- isBuffering: !1,
1464
- errorMessage: null
1465
- }, Un = {
1466
- ...$,
1467
- volume: 1,
1468
- muted: !1,
1469
- playbackRate: 1
1470
- };
1471
- function Vr(e) {
1472
- const r = [...e.tracks];
1473
- let n = A(e.currentIndex ?? 0, r.length), a = null, t = r;
1474
- return e.isShuffled && r.length > 1 && (a = [...r], t = qe(r, n), n = 0), {
1475
- tracks: t,
1476
- currentIndex: n,
1477
- playbackMode: e.playbackMode ?? "playlist",
1478
- isPaused: e.isPaused ?? !0,
1479
- isShuffled: !!(e.isShuffled && t.length > 1),
1480
- repeatMode: e.repeatMode ?? "off",
1481
- originalTracks: a,
1482
- playlistMeta: e.playlistMeta ?? null,
1483
- ...Un,
1484
- volume: Re(e.volume ?? 1),
1485
- muted: e.muted ?? !1,
1486
- playbackRate: Ue(e.playbackRate ?? 1)
1487
- };
1488
- }
1489
- function Vn(e, r) {
1490
- switch (r.type) {
1491
- case "INIT": {
1492
- const {
1493
- tracks: n,
1494
- currentIndex: a,
1495
- playlistMeta: t,
1496
- isPaused: i,
1497
- isShuffled: o,
1498
- repeatMode: c,
1499
- playbackMode: s,
1500
- volume: l,
1501
- muted: g,
1502
- playbackRate: m
1503
- } = r.payload;
1504
- return Vr({
1505
- tracks: n,
1506
- currentIndex: a,
1507
- playlistMeta: t ?? null,
1508
- isPaused: i ?? !0,
1509
- isShuffled: o ?? !1,
1510
- repeatMode: c ?? "off",
1511
- playbackMode: s ?? "playlist",
1512
- volume: l,
1513
- muted: g,
1514
- playbackRate: m
1515
- });
1516
- }
1517
- case "SET_QUEUE": {
1518
- const { tracks: n, currentIndex: a } = r.payload, t = [...n], i = A(a ?? e.currentIndex, t.length);
1519
- return {
1520
- ...e,
1521
- tracks: t,
1522
- currentIndex: i,
1523
- isShuffled: !1,
1524
- originalTracks: null,
1525
- ...$
1526
- };
1527
- }
1528
- case "INSERT_TRACK": {
1529
- const n = r.payload.index ?? e.tracks.length, a = Je(e.tracks, r.payload.track, n);
1530
- if (r.payload.autoPlay) {
1531
- const i = A(n, a.length);
1532
- return {
1533
- ...e,
1534
- tracks: a,
1535
- currentIndex: i,
1536
- isShuffled: !1,
1537
- originalTracks: null,
1538
- isPaused: !1,
1539
- ...$
1540
- };
1541
- }
1542
- const t = n <= e.currentIndex ? e.currentIndex + 1 : e.currentIndex;
1543
- return {
1544
- ...e,
1545
- tracks: a,
1546
- isShuffled: !1,
1547
- originalTracks: null,
1548
- currentIndex: A(t, a.length)
1549
- };
1550
- }
1551
- case "REMOVE_TRACK": {
1552
- 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;
1553
- return {
1554
- ...e,
1555
- tracks: a,
1556
- isShuffled: !1,
1557
- originalTracks: null,
1558
- currentIndex: A(t, a.length),
1559
- ...n === e.currentIndex ? $ : {}
1560
- };
1561
- }
1562
- case "MOVE_TRACK": {
1563
- const { fromIndex: n, toIndex: a } = r.payload, t = on(e.tracks, n, a);
1564
- let i = e.currentIndex;
1565
- return e.currentIndex === n ? i = a : n < e.currentIndex && a >= e.currentIndex ? i -= 1 : n > e.currentIndex && a <= e.currentIndex && (i += 1), {
1566
- ...e,
1567
- tracks: t,
1568
- isShuffled: !1,
1569
- originalTracks: null,
1570
- currentIndex: A(i, t.length)
1571
- };
1572
- }
1573
- case "ADD_NEXT": {
1574
- const n = un(e.tracks, e.currentIndex, r.payload.track);
1575
- return {
1576
- ...e,
1577
- tracks: n,
1578
- isShuffled: !1,
1579
- originalTracks: null
1580
- };
1581
- }
1582
- case "SET_INDEX": {
1583
- const n = A(r.payload.index, e.tracks.length), a = r.payload.autoPlay, t = a === !0 ? !1 : a === !1 ? !0 : e.isPaused;
1584
- return {
1585
- ...e,
1586
- currentIndex: n,
1587
- ...$,
1588
- isPaused: t
1589
- };
1590
- }
1591
- case "PLAY":
1592
- return { ...e, isPaused: !1 };
1593
- case "PAUSE":
1594
- return { ...e, isPaused: !0 };
1595
- case "TOGGLE_PAUSE":
1596
- return { ...e, isPaused: !e.isPaused };
1597
- case "SET_REPEAT":
1598
- return { ...e, repeatMode: r.payload };
1599
- case "CYCLE_REPEAT":
1600
- return { ...e, repeatMode: dn(e.repeatMode) };
1601
- case "TOGGLE_SHUFFLE": {
1602
- if (e.tracks.length <= 1) return { ...e, isShuffled: !1, originalTracks: null };
1603
- if (!e.isShuffled) {
1604
- const i = [...e.tracks], o = qe(i, e.currentIndex);
1605
- return {
1606
- ...e,
1607
- isShuffled: !0,
1608
- originalTracks: i,
1609
- tracks: o,
1610
- currentIndex: 0
1611
- };
1612
- }
1613
- const n = e.originalTracks ? [...e.originalTracks] : [...e.tracks], a = e.tracks[e.currentIndex], t = tn(n, a);
1614
- return {
1615
- ...e,
1616
- isShuffled: !1,
1617
- originalTracks: null,
1618
- tracks: n,
1619
- currentIndex: A(t, n.length)
1620
- };
1621
- }
1622
- case "NEXT": {
1623
- const n = ln(e), a = n === e.currentIndex;
1624
- return {
1625
- ...e,
1626
- currentIndex: n,
1627
- ...a ? {} : $,
1628
- isPaused: a ? e.isPaused : !1
1629
- };
1630
- }
1631
- case "PREV": {
1632
- const n = sn(e), a = n === e.currentIndex;
1633
- return {
1634
- ...e,
1635
- currentIndex: n,
1636
- ...a ? {} : $,
1637
- isPaused: a ? e.isPaused : !1
1638
- };
1639
- }
1640
- case "MEDIA_TIME_UPDATE":
1641
- return {
1642
- ...e,
1643
- currentTime: r.payload.currentTime,
1644
- duration: Number.isFinite(r.payload.duration) ? r.payload.duration : e.duration,
1645
- bufferedFraction: r.payload.bufferedFraction,
1646
- isBuffering: !1
1647
- };
1648
- case "MEDIA_LOADED_METADATA":
1649
- return {
1650
- ...e,
1651
- duration: Number.isFinite(r.payload.duration) ? r.payload.duration : e.duration,
1652
- bufferedFraction: r.payload.bufferedFraction,
1653
- errorMessage: null
1654
- };
1655
- case "SET_PLAYLIST_META":
1656
- return { ...e, playlistMeta: r.payload };
1657
- case "SET_PLAYBACK_MODE":
1658
- return { ...e, playbackMode: r.payload };
1659
- case "MEDIA_ERROR":
1660
- return {
1661
- ...e,
1662
- errorMessage: r.payload.message,
1663
- isPaused: !0,
1664
- isBuffering: !1
1665
- };
1666
- case "MEDIA_WAITING":
1667
- return { ...e, isBuffering: !0 };
1668
- case "MEDIA_CANPLAY":
1669
- return { ...e, isBuffering: !1, errorMessage: null };
1670
- case "MEDIA_PLAY":
1671
- return { ...e, isPaused: !1, isBuffering: !1 };
1672
- case "MEDIA_PAUSE":
1673
- return { ...e, isPaused: !0 };
1674
- case "RESET_MEDIA_TIMES":
1675
- return { ...e, currentTime: 0, duration: 0, bufferedFraction: 0 };
1676
- case "MEDIA_SOURCE_CLEARED":
1677
- return { ...e, ...$ };
1678
- case "SET_VOLUME":
1679
- return { ...e, volume: Re(r.payload) };
1680
- case "SET_MUTED":
1681
- return { ...e, muted: r.payload };
1682
- case "TOGGLE_MUTE":
1683
- return { ...e, muted: !e.muted };
1684
- case "SET_PLAYBACK_RATE":
1685
- return { ...e, playbackRate: Ue(r.payload) };
1686
- case "MEDIA_VOLUME_SYNC": {
1687
- const { volume: n, muted: a } = r.payload, t = Re(n);
1688
- return t === e.volume && a === e.muted ? e : { ...e, volume: t, muted: a };
1689
- }
1690
- default:
1691
- return e;
1692
- }
1693
- }
1694
- function _e() {
1695
- return typeof navigator > "u" || !("mediaSession" in navigator) ? null : navigator.mediaSession;
1696
- }
1697
- function Bn(e, r, n) {
1698
- var s;
1699
- 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);
1700
- E(() => {
1701
- const l = _e();
1702
- !e || !l || (l.metadata = new MediaMetadata({
1703
- title: t ?? "Unknown track",
1704
- artist: i,
1705
- album: o,
1706
- artwork: c ? [{ src: c }] : void 0
1707
- }));
1708
- }, [e, t, i, o, c]), E(() => {
1709
- const l = _e();
1710
- !e || !l || (l.playbackState = r.isPaused ? "paused" : "playing");
1711
- }, [e, r.isPaused]), E(() => {
1712
- const l = _e();
1713
- if (!(!e || !l)) {
1714
- try {
1715
- l.setActionHandler("play", n.play), l.setActionHandler("pause", n.pause), l.setActionHandler("nexttrack", n.next), l.setActionHandler("previoustrack", n.prev), l.setActionHandler("seekto", (g) => {
1716
- typeof g.seekTime == "number" && Number.isFinite(g.seekTime) && n.seek(g.seekTime);
1717
- });
1718
- } catch {
1719
- }
1720
- return () => {
1721
- try {
1722
- l.setActionHandler("play", null), l.setActionHandler("pause", null), l.setActionHandler("nexttrack", null), l.setActionHandler("previoustrack", null), l.setActionHandler("seekto", null);
1723
- } catch {
1724
- }
1725
- };
1726
- }
1727
- }, [e, n]);
1728
- }
1729
- const $n = {
1730
- "--ginger-primary-color": "#111827",
1731
- "--ginger-muted-color": "#6b7280",
1732
- "--ginger-font-size": "14px",
1733
- "--ginger-font-family": "system-ui, sans-serif",
1734
- "--ginger-playlist-row-padding": "6px 8px",
1735
- "--ginger-artwork-radius": "6px",
1736
- "--ginger-artwork-bg": "#f3f4f6",
1737
- "--ginger-playlist-active-bg": "rgba(17, 24, 39, 0.06)",
1738
- "--ginger-buffer-color": "rgba(107, 114, 128, 0.35)",
1739
- "--ginger-focus-ring": "0 0 0 2px rgba(59, 130, 246, 0.45)"
1740
- };
1741
- function On({
1742
- children: e,
1743
- initialTracks: r = [],
1744
- initialIndex: n = 0,
1745
- initialPlaylistMeta: a = null,
1746
- initialShuffle: t = !1,
1747
- initialRepeatMode: i = "off",
1748
- initialPlaybackMode: o = "playlist",
1749
- initialPaused: c = !0,
1750
- initialVolume: s = 1,
1751
- initialMuted: l = !1,
1752
- initialPlaybackRate: g = 1,
1753
- initialStateKey: m,
1754
- locale: b,
1755
- mediaSession: h = !1,
1756
- beforePlay: v,
1757
- onPlayBlocked: x,
1758
- persistence: f,
1759
- hydrateOnMount: I = !1,
1760
- resumeOnTrackChange: L = !1,
1761
- unstyled: D = !1,
1762
- asChild: ee = !1,
1763
- className: re,
1764
- style: Ge,
1765
- onTrackChange: ne,
1766
- onPlay: te,
1767
- onPause: ae,
1768
- onQueueEnd: ie,
1769
- onError: oe
1770
- }) {
1771
- var Qe;
1772
- const Y = Q(null), [d, y] = zr(
1773
- Vn,
1774
- void 0,
1775
- () => Vr({
1776
- tracks: r,
1777
- currentIndex: n,
1778
- playlistMeta: a,
1779
- isPaused: c,
1780
- isShuffled: t,
1781
- repeatMode: i,
1782
- playbackMode: o,
1783
- volume: s,
1784
- muted: l,
1785
- playbackRate: g
1786
- })
1787
- ), Ve = Q(d), Le = Q({
1788
- tracks: r,
1789
- currentIndex: n,
1790
- playlistMeta: a,
1791
- isPaused: c,
1792
- isShuffled: t,
1793
- repeatMode: i,
1794
- playbackMode: o,
1795
- volume: s,
1796
- muted: l,
1797
- playbackRate: g
1798
- });
1799
- Le.current = {
1800
- tracks: r,
1801
- currentIndex: n,
1802
- playlistMeta: a,
1803
- isPaused: c,
1804
- isShuffled: t,
1805
- repeatMode: i,
1806
- playbackMode: o,
1807
- volume: s,
1808
- muted: l,
1809
- playbackRate: g
1810
- };
1811
- const K = Q(void 0);
1812
- E(() => {
1813
- if (m === void 0) {
1814
- K.current = void 0;
1815
- return;
1816
- }
1817
- if (K.current === void 0) {
1818
- K.current = m;
1819
- return;
1820
- }
1821
- if (K.current === m) return;
1822
- K.current = m;
1823
- const p = Le.current;
1824
- y({
1825
- type: "INIT",
1826
- payload: {
1827
- tracks: p.tracks,
1828
- currentIndex: p.currentIndex,
1829
- playlistMeta: p.playlistMeta,
1830
- isPaused: p.isPaused,
1831
- isShuffled: p.isShuffled,
1832
- repeatMode: p.repeatMode,
1833
- playbackMode: p.playbackMode,
1834
- volume: p.volume,
1835
- muted: p.muted,
1836
- playbackRate: p.playbackRate
1837
- }
1838
- });
1839
- }, [m, y]), E(() => {
1840
- Ve.current = d;
1841
- }, [d]);
1842
- const Be = d.tracks[d.currentIndex] ?? null;
1843
- E(() => {
1844
- ne == null || ne(Be, d.currentIndex);
1845
- }, [Be, d.currentIndex, ne]), E(() => {
1846
- d.errorMessage && (oe == null || oe(d.errorMessage));
1847
- }, [d.errorMessage, oe]);
1848
- const ue = Q(void 0);
1849
- E(() => {
1850
- if (ue.current === void 0) {
1851
- ue.current = d.isPaused;
1852
- return;
1853
- }
1854
- ue.current !== d.isPaused && (d.isPaused ? ae == null || ae() : te == null || te()), ue.current = d.isPaused;
1855
- }, [d.isPaused, ae, te]);
1856
- const U = T(() => {
1857
- y({ type: "PLAY" });
1858
- }, []), V = T(() => {
1859
- var p;
1860
- y({ type: "PAUSE" }), (p = Y.current) == null || p.pause();
1861
- }, []), ce = T(() => {
1862
- d.isPaused ? U() : V();
1863
- }, [V, U, d.isPaused]), B = T((p) => {
1864
- const k = Y.current;
1865
- k && Number.isFinite(p) && (k.currentTime = Math.max(0, p));
1866
- }, []), le = T((p) => {
1867
- y({ type: "SET_VOLUME", payload: Re(p) });
1868
- }, []), se = T((p) => {
1869
- y({ type: "SET_MUTED", payload: p });
1870
- }, []), de = T(() => {
1871
- y({ type: "TOGGLE_MUTE" });
1872
- }, []), pe = T((p) => {
1873
- y({ type: "SET_PLAYBACK_RATE", payload: Ue(p) });
1874
- }, []), z = T(() => {
1875
- y({ type: "NEXT" });
1876
- }, []), W = T(() => {
1877
- y({ type: "PREV" });
1878
- }, []), fe = T((p) => {
1879
- y({ type: "SET_REPEAT", payload: p });
1880
- }, []), ge = T(() => {
1881
- y({ type: "CYCLE_REPEAT" });
1882
- }, []), me = T(() => {
1883
- y({ type: "TOGGLE_SHUFFLE" });
1884
- }, []), ye = T((p, k) => {
1885
- y({ type: "SET_QUEUE", payload: { tracks: p, currentIndex: k } });
1886
- }, []), he = T((p, k, M) => {
1887
- y({ type: "INSERT_TRACK", payload: { track: p, index: k, autoPlay: M } });
1888
- }, []), ve = T((p) => {
1889
- y({ type: "REMOVE_TRACK", payload: { index: p } });
1890
- }, []), be = T((p, k) => {
1891
- y({ type: "MOVE_TRACK", payload: { fromIndex: p, toIndex: k } });
1892
- }, []), ke = T((p) => {
1893
- y({ type: "ADD_NEXT", payload: { track: p } });
1894
- }, []), Me = T((p) => {
1895
- y({ type: "SET_INDEX", payload: { index: p, autoPlay: !0 } });
1896
- }, []), xe = T((p) => {
1897
- y({ type: "SET_INDEX", payload: { index: p, autoPlay: !1 } });
1898
- }, []), Te = T((p) => {
1899
- y({ type: "SET_PLAYLIST_META", payload: p });
1900
- }, []), Ie = T((p) => {
1901
- y({ type: "SET_PLAYBACK_MODE", payload: p });
1902
- }, []), Pe = T((p) => {
1903
- y({ type: "INIT", payload: p });
1904
- }, []);
1905
- E(() => {
1906
- if (!f || !I) return;
1907
- 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;
1908
- y({
1909
- type: "INIT",
1910
- payload: {
1911
- tracks: C.tracks,
1912
- playlistMeta: C.playlistMeta,
1913
- isPaused: C.isPaused,
1914
- isShuffled: C.isShuffled,
1915
- playbackMode: C.playbackMode,
1916
- currentIndex: typeof Se == "number" ? Se : C.currentIndex,
1917
- repeatMode: F === "off" || F === "all" || F === "one" ? F : C.repeatMode,
1918
- volume: typeof p == "number" ? p : C.volume,
1919
- muted: typeof k == "boolean" ? k : C.muted,
1920
- playbackRate: typeof M == "number" ? M : C.playbackRate
1921
- }
1922
- });
1923
- }, [I, f]), E(() => {
1924
- 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));
1925
- }, [
1926
- f,
1927
- d.volume,
1928
- d.muted,
1929
- d.playbackRate,
1930
- d.repeatMode,
1931
- d.currentIndex
1932
- ]), E(() => {
1933
- if (!f || !L) return;
1934
- const p = d.tracks[d.currentIndex];
1935
- if (!p) return;
1936
- const k = `ginger:resume:${J(p)}`, M = f.get(k);
1937
- typeof M == "number" && Number.isFinite(M) && B(M);
1938
- }, [f, L, d.currentIndex, d.tracks, B]), E(() => {
1939
- if (!f || !L) return;
1940
- const p = d.tracks[d.currentIndex];
1941
- if (!p || !(d.currentTime >= 0)) return;
1942
- const k = `ginger:resume:${J(p)}`, M = setTimeout(() => f.set(k, d.currentTime), 250);
1943
- return () => clearTimeout(M);
1944
- }, [f, L, d.currentIndex, d.tracks, d.currentTime]);
1945
- const Br = (Qe = d.tracks[d.currentIndex]) == null ? void 0 : Qe.fileUrl;
1946
- E(() => {
1947
- const p = Y.current;
1948
- if (!p) return;
1949
- if (d.isPaused) {
1950
- p.pause();
1951
- return;
1952
- }
1953
- let k = !1;
1954
- return (async () => {
1955
- if (v) {
1956
- let M = !1;
1957
- try {
1958
- M = await v();
1959
- } catch (F) {
1960
- const Se = F instanceof Error ? F.message : "beforePlay rejected";
1961
- y({ type: "MEDIA_ERROR", payload: { message: Se } });
1962
- return;
1963
- }
1964
- if (!M) {
1965
- k || (y({ type: "PAUSE" }), x == null || x());
1966
- return;
1967
- }
1968
- }
1969
- k || p.play().catch((M) => {
1970
- const F = M instanceof Error ? M.message : typeof M == "string" ? M : "Playback failed (e.g. autoplay blocked or unavailable source)";
1971
- y({ type: "MEDIA_ERROR", payload: { message: F } });
1972
- });
1973
- })(), () => {
1974
- k = !0;
1975
- };
1976
- }, [v, Br, x, d.isPaused]);
1977
- const Ee = T(() => {
1978
- const p = cn(Ve.current);
1979
- if (p.kind === "replay_same") {
1980
- const M = Y.current;
1981
- M && (M.currentTime = 0), y({ type: "PLAY" });
1982
- return;
1983
- }
1984
- if (p.kind === "stop") {
1985
- y({ type: "PAUSE" }), ie == null || ie();
1986
- return;
1987
- }
1988
- const k = p.nextIndex;
1989
- y({ type: "SET_INDEX", payload: { index: k, autoPlay: !0 } });
1990
- }, [ie]), $r = S(
1991
- () => ({ play: U, pause: V, next: z, prev: W, seek: B }),
1992
- [U, V, z, W, B]
1993
- );
1994
- Bn(!!h, d, $r);
1995
- const $e = b != null && b.seek && /[\u0590-\u08FF]/.test(b.seek) ? "rtl" : "ltr", Or = S(
1996
- () => ({
1997
- state: d,
1998
- dispatch: y,
1999
- audioRef: Y,
2000
- notifyEnded: Ee,
2001
- init: Pe,
2002
- play: U,
2003
- pause: V,
2004
- togglePlayPause: ce,
2005
- seek: B,
2006
- setVolume: le,
2007
- setMuted: se,
2008
- toggleMute: de,
2009
- setPlaybackRate: pe,
2010
- next: z,
2011
- prev: W,
2012
- setRepeatMode: fe,
2013
- cycleRepeat: ge,
2014
- toggleShuffle: me,
2015
- setQueue: ye,
2016
- insertTrackAt: he,
2017
- removeTrackAt: ve,
2018
- moveTrack: be,
2019
- enqueueNext: ke,
2020
- playTrackAt: Me,
2021
- selectTrackAt: xe,
2022
- setPlaylistMeta: Te,
2023
- setPlaybackMode: Ie
2024
- }),
2025
- [
2026
- ge,
2027
- y,
2028
- Pe,
2029
- z,
2030
- Ee,
2031
- V,
2032
- U,
2033
- Me,
2034
- he,
2035
- ve,
2036
- be,
2037
- ke,
2038
- xe,
2039
- W,
2040
- B,
2041
- se,
2042
- pe,
2043
- ye,
2044
- fe,
2045
- Te,
2046
- Ie,
2047
- le,
2048
- d,
2049
- de,
2050
- ce,
2051
- me
2052
- ]
2053
- ), Yr = S(
2054
- () => ({
2055
- tracks: d.tracks,
2056
- currentIndex: d.currentIndex,
2057
- isPaused: d.isPaused,
2058
- isShuffled: d.isShuffled,
2059
- repeatMode: d.repeatMode,
2060
- originalTracks: d.originalTracks,
2061
- playlistMeta: d.playlistMeta,
2062
- init: Pe,
2063
- play: U,
2064
- pause: V,
2065
- togglePlayPause: ce,
2066
- next: z,
2067
- prev: W,
2068
- setRepeatMode: fe,
2069
- cycleRepeat: ge,
2070
- toggleShuffle: me,
2071
- playbackMode: d.playbackMode,
2072
- setQueue: ye,
2073
- insertTrackAt: he,
2074
- removeTrackAt: ve,
2075
- moveTrack: be,
2076
- enqueueNext: ke,
2077
- playTrackAt: Me,
2078
- selectTrackAt: xe,
2079
- setPlaylistMeta: Te,
2080
- setPlaybackMode: Ie,
2081
- dispatch: y
2082
- }),
2083
- [
2084
- d.tracks,
2085
- d.currentIndex,
2086
- d.isPaused,
2087
- d.isShuffled,
2088
- d.repeatMode,
2089
- d.playbackMode,
2090
- d.originalTracks,
2091
- d.playlistMeta,
2092
- Pe,
2093
- U,
2094
- V,
2095
- ce,
2096
- z,
2097
- W,
2098
- fe,
2099
- ge,
2100
- me,
2101
- ye,
2102
- he,
2103
- ve,
2104
- be,
2105
- ke,
2106
- Me,
2107
- xe,
2108
- Te,
2109
- Ie,
2110
- y
2111
- ]
2112
- ), Qr = S(
2113
- () => ({
2114
- currentTime: d.currentTime,
2115
- duration: d.duration,
2116
- bufferedFraction: d.bufferedFraction,
2117
- isBuffering: d.isBuffering,
2118
- errorMessage: d.errorMessage,
2119
- volume: d.volume,
2120
- muted: d.muted,
2121
- playbackRate: d.playbackRate,
2122
- seek: B,
2123
- setVolume: le,
2124
- setMuted: se,
2125
- toggleMute: de,
2126
- setPlaybackRate: pe,
2127
- audioRef: Y,
2128
- notifyEnded: Ee,
2129
- dispatch: y
2130
- }),
2131
- [
2132
- d.currentTime,
2133
- d.duration,
2134
- d.bufferedFraction,
2135
- d.isBuffering,
2136
- d.errorMessage,
2137
- d.volume,
2138
- d.muted,
2139
- d.playbackRate,
2140
- B,
2141
- le,
2142
- se,
2143
- de,
2144
- pe,
2145
- Y,
2146
- Ee,
2147
- y
2148
- ]
2149
- ), Oe = er(d), Ye = S(
2150
- () => D ? Ge : { ...$n, ...Ge },
2151
- [Ge, D]
2152
- ), N = S(
2153
- () => ({
2154
- className: re,
2155
- style: Ye,
2156
- "data-ginger-playback": Oe,
2157
- dir: $e
2158
- }),
2159
- [re, Ye, Oe, $e]
2160
- ), Hr = S(() => {
2161
- if (!ee)
2162
- return /* @__PURE__ */ u(
2163
- "div",
2164
- {
2165
- className: N.className,
2166
- style: N.style,
2167
- "data-ginger-playback": N["data-ginger-playback"],
2168
- dir: N.dir,
2169
- children: e
2170
- }
2171
- );
2172
- const p = Wr.only(e);
2173
- if (!Xr(p))
2174
- throw new Error("Ginger.Provider asChild expects a single React element child.");
2175
- const k = p, M = k.props.style;
2176
- return Kr(k, {
2177
- className: Yn(k.props.className, N.className),
2178
- style: M && typeof M == "object" ? { ...M, ...N.style } : N.style,
2179
- "data-ginger-playback": N["data-ginger-playback"],
2180
- dir: N.dir
2181
- });
2182
- }, [ee, e, N]);
2183
- 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 }) }) }) });
2184
- }
2185
- function Yn(e, r) {
2186
- const n = [e, r].filter(Boolean).join(" ");
2187
- return n === "" ? void 0 : n;
2188
- }
2189
- const zn = {
2190
- Provider: On,
2191
- Player: en,
2192
- Current: {
2193
- Title: kn,
2194
- Artist: Mn,
2195
- Album: xn,
2196
- Description: Tn,
2197
- Copyright: In,
2198
- Genre: Pn,
2199
- Label: En,
2200
- Isrc: Sn,
2201
- TrackNumber: An,
2202
- Year: br,
2203
- Lyrics: kr,
2204
- LyricsSynced: Mr,
2205
- Chapters: xr,
2206
- FileUrl: Tr,
2207
- Artwork: Ir,
2208
- QueueIndex: Pr,
2209
- QueueLength: Er,
2210
- QueuePosition: Sr,
2211
- Elapsed: Ar,
2212
- Duration: Rr,
2213
- Remaining: Gr,
2214
- Progress: Lr,
2215
- TimeRail: wr,
2216
- BufferRail: _r,
2217
- PlaybackState: Nr,
2218
- ErrorMessage: Cr
2219
- },
2220
- Queue: {
2221
- Title: Nn,
2222
- Subtitle: Cn,
2223
- Description: Dn,
2224
- Copyright: Fn,
2225
- Artwork: Ur
2226
- },
2227
- Control: {
2228
- PlayPause: sr,
2229
- Repeat: dr,
2230
- Next: pr,
2231
- Previous: fr,
2232
- Shuffle: gr,
2233
- SeekBar: mr,
2234
- Volume: yr,
2235
- Mute: hr,
2236
- PlaybackRate: vr
2237
- },
2238
- Icon: {
2239
- Play: tr,
2240
- Pause: nr,
2241
- SkipForward: ur,
2242
- SkipBack: or,
2243
- Shuffle: ir,
2244
- Volume2: cr,
2245
- VolumeX: lr,
2246
- RepeatGlyph: ar,
2247
- Wrapper: w
2248
- },
2249
- Playlist: _n
2250
- };
2251
- export {
2252
- xr as C,
2253
- zn as G,
2254
- Mr as L,
2255
- nr as P,
2256
- ar as R,
2257
- ir as S,
2258
- cr as V,
2259
- w as W,
2260
- tr as a,
2261
- or as b,
2262
- ur as c,
2263
- lr as d,
2264
- Ue as e,
2265
- Re as f,
2266
- Ae as g,
2267
- er as h,
2268
- G as i,
2269
- Gn as j,
2270
- vn as k,
2271
- yn as l,
2272
- hn as m,
2273
- gn as n,
2274
- rr as o,
2275
- Rn as p,
2276
- fn as q,
2277
- mn as r,
2278
- Z as s,
2279
- O as t,
2280
- Ln as u,
2281
- ln as v
2282
- };
2283
- //# sourceMappingURL=ginger-DYlsaFGA.js.map