@lucaismyname/ginger 0.0.36 → 0.0.38

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