@lucaismyname/ginger 0.0.54 → 0.0.55

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