react-modern-audio-player 2.0.0 → 2.2.0

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 (57) hide show
  1. package/README.md +232 -24
  2. package/dist/index.es.js +1382 -1195
  3. package/dist/types/components/AudioPlayer/Context/StateContext/index.d.ts +1 -0
  4. package/dist/types/components/AudioPlayer/Context/UIContext.d.ts +1 -0
  5. package/dist/types/{hooks/context → components/AudioPlayer/Context/hooks}/index.d.ts +0 -1
  6. package/dist/types/components/AudioPlayer/Context/hooks/useAudioAttrsContext.d.ts +2 -0
  7. package/dist/types/components/AudioPlayer/Context/hooks/usePlaybackContext.d.ts +2 -0
  8. package/dist/types/components/AudioPlayer/Context/hooks/useResourceContext.d.ts +2 -0
  9. package/dist/types/components/AudioPlayer/Context/hooks/useTimeContext.d.ts +2 -0
  10. package/dist/types/components/AudioPlayer/Context/hooks/useTrackContext.d.ts +2 -0
  11. package/dist/types/components/AudioPlayer/Context/hooks/useUIContext.d.ts +1 -0
  12. package/dist/types/components/AudioPlayer/Context/index.d.ts +1 -0
  13. package/dist/types/components/AudioPlayer/Interface/Controller/Button/RepeatTypeBtn.d.ts +3 -1
  14. package/dist/types/components/AudioPlayer/Interface/Controller/Button/TransportControls/index.d.ts +4 -0
  15. package/dist/types/components/AudioPlayer/Interface/Controller/Button/VolumeIcon.d.ts +2 -0
  16. package/dist/types/components/AudioPlayer/Interface/Controller/Button/index.d.ts +5 -4
  17. package/dist/types/components/AudioPlayer/Interface/Controller/Drawer/SortablePlayList/index.d.ts +5 -1
  18. package/dist/types/components/AudioPlayer/Interface/Controller/Input/Progress/index.d.ts +12 -1
  19. package/dist/types/components/AudioPlayer/Interface/Controller/Tooltip/Volume/index.d.ts +3 -1
  20. package/dist/types/components/AudioPlayer/Interface/Information/Artwork.d.ts +3 -1
  21. package/dist/types/components/AudioPlayer/Interface/Information/TrackInfo.d.ts +3 -1
  22. package/dist/types/components/AudioPlayer/Interface/Information/TrackTime/index.d.ts +3 -1
  23. package/dist/types/components/AudioPlayer/Interface/PlayListEmpty/index.d.ts +6 -0
  24. package/dist/types/components/AudioPlayer/Interface/compound/index.d.ts +3 -0
  25. package/dist/types/components/AudioPlayer/Interface/compound/slotMetaMap.d.ts +10 -0
  26. package/dist/types/components/AudioPlayer/Interface/compound/useCompoundSlots.d.ts +6 -0
  27. package/dist/types/components/AudioPlayer/Interface/compound/useDuplicateSlotWarning.d.ts +7 -0
  28. package/dist/types/components/AudioPlayer/Interface/contexts/index.d.ts +2 -0
  29. package/dist/types/components/AudioPlayer/Interface/contexts/playListEmptyContext.d.ts +2 -0
  30. package/dist/types/components/AudioPlayer/Interface/contexts/playListPortalContext.d.ts +1 -0
  31. package/dist/types/components/AudioPlayer/Interface/hooks/index.d.ts +2 -0
  32. package/dist/types/components/AudioPlayer/Interface/hooks/useGridTemplate.d.ts +3 -0
  33. package/dist/types/components/AudioPlayer/Interface/hooks/useResolvedGridArea.d.ts +2 -0
  34. package/dist/types/components/AudioPlayer/index.d.ts +23 -2
  35. package/dist/types/components/Drawer/Drawer.d.ts +1 -0
  36. package/dist/types/components/Dropdown/DropdownTrigger.d.ts +4 -2
  37. package/dist/types/components/Grid/Item.d.ts +3 -2
  38. package/dist/types/components/Grid/index.d.ts +1 -0
  39. package/dist/types/components/SortableList/useSortableListItem.d.ts +1 -0
  40. package/dist/types/hooks/index.d.ts +1 -2
  41. package/dist/types/index.d.ts +2 -2
  42. package/dist/types/utils/ssr.d.ts +0 -2
  43. package/llms.txt +61 -0
  44. package/package.json +26 -9
  45. package/dist/types/components/AudioPlayer/Interface/Controller/Button/VolumeTriggerBtn.d.ts +0 -1
  46. package/dist/types/hooks/context/useAudioAttrsContext.d.ts +0 -2
  47. package/dist/types/hooks/context/usePlaybackContext.d.ts +0 -2
  48. package/dist/types/hooks/context/useResourceContext.d.ts +0 -2
  49. package/dist/types/hooks/context/useTimeContext.d.ts +0 -2
  50. package/dist/types/hooks/context/useTrackContext.d.ts +0 -2
  51. package/dist/types/hooks/context/useUIContext.d.ts +0 -1
  52. package/dist/types/hooks/useGridTemplate.d.ts +0 -2
  53. /package/dist/types/components/AudioPlayer/Interface/Controller/Button/{NextBtn.d.ts → TransportControls/NextBtn.d.ts} +0 -0
  54. /package/dist/types/components/AudioPlayer/Interface/Controller/Button/{PlayBtn.d.ts → TransportControls/PlayBtn.d.ts} +0 -0
  55. /package/dist/types/components/AudioPlayer/Interface/Controller/Button/{PrevBtn.d.ts → TransportControls/PrevBtn.d.ts} +0 -0
  56. /package/dist/types/{utils → components/AudioPlayer/utils}/clampVolume.d.ts +0 -0
  57. /package/dist/types/hooks/{context/useNonNullableContext.d.ts → useNonNullableContext.d.ts} +0 -0
package/dist/index.es.js CHANGED
@@ -1,16 +1,16 @@
1
1
  "use client";
2
2
  import './index.css';
3
- import { jsx as i, Fragment as z, jsxs as S } from "react/jsx-runtime";
4
- import te, { createContext as H, useReducer as nt, useMemo as D, useContext as st, forwardRef as ve, useCallback as g, useRef as A, useEffect as E, memo as W, useState as b, useId as ke, useLayoutEffect as it, cloneElement as lt } from "react";
5
- import ct, { flushSync as ut } from "react-dom";
6
- const F = {
3
+ import { jsx as s, Fragment as R, jsxs as w } from "react/jsx-runtime";
4
+ import ee, { createContext as O, useContext as he, useReducer as kt, useMemo as k, forwardRef as Pe, useCallback as g, useRef as A, useEffect as P, memo as G, useState as b, useId as Be, useLayoutEffect as Ct, cloneElement as xt, isValidElement as Mt } from "react";
5
+ import _t, { flushSync as $e } from "react-dom";
6
+ const H = {
7
7
  isPlaying: !1,
8
8
  volume: 1,
9
9
  muted: !1,
10
10
  repeatType: "ALL",
11
11
  currentTime: 0,
12
12
  duration: 0
13
- }, pr = 10, k = {
13
+ }, _r = 10, de = {
14
14
  templateArea: {
15
15
  artwork: "row1-1",
16
16
  trackInfo: "row1-2",
@@ -22,17 +22,18 @@ const F = {
22
22
  playButton: "row1-8",
23
23
  playList: "row1-9"
24
24
  }
25
- }, w = H(null);
26
- w.displayName = "AudioPlayerDispatchContext";
27
- const be = (e) => isFinite(e) ? Math.min(Math.max(e, 0), 1) : 1, Le = (e, t) => Math.round(Math.random() * (t - e) + e), dt = 1, Ne = (e, t, o) => {
28
- if (o - t < 1) return e;
29
- let r = Le(t, o);
30
- for (; r === e; )
31
- r = Le(t, o);
32
- return r;
33
- }, mt = (e, t) => {
25
+ }, L = O(null);
26
+ L.displayName = "AudioPlayerDispatchContext";
27
+ const Fe = (e) => isFinite(e) ? Math.min(Math.max(e, 0), 1) : 1, Oe = (e, t) => Math.round(Math.random() * (t - e) + e), Dt = 1, Ve = (e, t, n) => {
28
+ if (n - t < 1) return e;
29
+ let a = Oe(t, n);
30
+ for (; a === e; )
31
+ a = Oe(t, n);
32
+ return a;
33
+ }, Ut = (e, t) => {
34
34
  switch (t.type) {
35
35
  case "NEXT_AUDIO": {
36
+ if (e.playList.length === 0) return e;
36
37
  if (e.curAudioState.repeatType === "NONE" && e.curIdx + 1 === e.playList.length)
37
38
  return {
38
39
  ...e,
@@ -50,7 +51,7 @@ const be = (e) => isFinite(e) ? Math.min(Math.max(e, 0), 1) : 1, Le = (e, t) =>
50
51
  audioResetKey: e.audioResetKey + 1,
51
52
  curAudioState: { ...e.curAudioState, currentTime: 0 }
52
53
  };
53
- const r = Ne(
54
+ const a = Ve(
54
55
  e.curIdx,
55
56
  0,
56
57
  e.playList.length - 1
@@ -58,8 +59,8 @@ const be = (e) => isFinite(e) ? Math.min(Math.max(e, 0), 1) : 1, Le = (e, t) =>
58
59
  return {
59
60
  ...e,
60
61
  audioResetKey: e.audioResetKey + 1,
61
- curPlayId: e.playList[r].id,
62
- curIdx: r,
62
+ curPlayId: e.playList[a].id,
63
+ curIdx: a,
63
64
  curAudioState: {
64
65
  ...e.curAudioState,
65
66
  isLoadedMetaData: !1,
@@ -67,41 +68,41 @@ const be = (e) => isFinite(e) ? Math.min(Math.max(e, 0), 1) : 1, Le = (e, t) =>
67
68
  }
68
69
  };
69
70
  }
70
- const o = (e.curIdx + 1) % e.playList.length;
71
+ const n = (e.curIdx + 1) % e.playList.length;
71
72
  return {
72
73
  ...e,
73
74
  audioResetKey: e.audioResetKey + 1,
74
- curIdx: o,
75
- curPlayId: e.playList[o].id,
75
+ curIdx: n,
76
+ curPlayId: e.playList[n].id,
76
77
  curAudioState: { ...e.curAudioState, currentTime: 0 }
77
78
  };
78
79
  }
79
80
  case "PREV_AUDIO": {
80
- const o = e.playList.length <= 1, r = t.currentTime > dt, a = e.curAudioState.repeatType === "NONE" && e.curIdx === 0;
81
- if (o || r || a)
81
+ const n = e.playList.length <= 1, a = t.currentTime > Dt, r = e.curAudioState.repeatType === "NONE" && e.curIdx === 0;
82
+ if (n || a || r)
82
83
  return {
83
84
  ...e,
84
85
  audioResetKey: e.audioResetKey + 1,
85
86
  curAudioState: { ...e.curAudioState, currentTime: 0 }
86
87
  };
87
88
  if (e.curAudioState.repeatType === "SHUFFLE") {
88
- const n = Ne(
89
+ const o = Ve(
89
90
  e.curIdx,
90
91
  0,
91
92
  e.playList.length - 1
92
93
  );
93
94
  return {
94
95
  ...e,
95
- curPlayId: e.playList[n].id,
96
- curIdx: n,
96
+ curPlayId: e.playList[o].id,
97
+ curIdx: o,
97
98
  curAudioState: { ...e.curAudioState, currentTime: 0 }
98
99
  };
99
100
  }
100
- const s = (e.curIdx - 1 + e.playList.length) % e.playList.length;
101
+ const i = (e.curIdx - 1 + e.playList.length) % e.playList.length;
101
102
  return {
102
103
  ...e,
103
- curPlayId: e.playList[s].id,
104
- curIdx: s,
104
+ curPlayId: e.playList[i].id,
105
+ curIdx: i,
105
106
  curAudioState: {
106
107
  ...e.curAudioState,
107
108
  isLoadedMetaData: !1,
@@ -110,19 +111,42 @@ const be = (e) => isFinite(e) ? Math.min(Math.max(e, 0), 1) : 1, Le = (e, t) =>
110
111
  };
111
112
  }
112
113
  case "UPDATE_PLAY_LIST": {
114
+ if (t.playList.length === 0)
115
+ return {
116
+ ...e,
117
+ playList: t.playList,
118
+ curPlayId: 0,
119
+ curIdx: -1,
120
+ curAudioState: {
121
+ ...e.curAudioState,
122
+ isPlaying: !1,
123
+ currentTime: 0,
124
+ duration: 0,
125
+ isLoadedMetaData: !1
126
+ }
127
+ };
113
128
  if (!t.playList.find(
114
- (a) => a.id === e.curPlayId
129
+ (r) => r.id === e.curPlayId
115
130
  ))
116
- return console.error(
117
- "UPDATE_PLAY_LIST ERROR - curPlayId is not found on playList"
118
- ), e;
119
- const r = t.playList.findIndex(
120
- (a) => a.id === e.curPlayId
131
+ return {
132
+ ...e,
133
+ playList: t.playList,
134
+ curPlayId: t.playList[0].id,
135
+ curIdx: 0,
136
+ audioResetKey: e.audioResetKey + 1,
137
+ curAudioState: {
138
+ ...e.curAudioState,
139
+ currentTime: 0,
140
+ isLoadedMetaData: !1
141
+ }
142
+ };
143
+ const a = t.playList.findIndex(
144
+ (r) => r.id === e.curPlayId
121
145
  );
122
146
  return {
123
147
  ...e,
124
148
  playList: t.playList,
125
- curIdx: r
149
+ curIdx: a
126
150
  };
127
151
  }
128
152
  case "SET_VOLUME":
@@ -130,7 +154,7 @@ const be = (e) => isFinite(e) ? Math.min(Math.max(e, 0), 1) : 1, Le = (e, t) =>
130
154
  ...e,
131
155
  curAudioState: {
132
156
  ...e.curAudioState,
133
- volume: be(t.volume)
157
+ volume: Fe(t.volume)
134
158
  }
135
159
  };
136
160
  case "SET_AUDIO_STATE":
@@ -223,372 +247,381 @@ const be = (e) => isFinite(e) ? Math.min(Math.max(e, 0), 1) : 1, Le = (e, t) =>
223
247
  default:
224
248
  throw new Error("Unhandled action");
225
249
  }
226
- }, he = H(null);
227
- he.displayName = "PlaybackContext";
228
- const Te = H(null);
229
- Te.displayName = "AudioAttrsContext";
230
- const ge = H(null);
231
- ge.displayName = "TrackContext";
232
- const fe = H(null);
233
- fe.displayName = "UIContext";
234
- const Ae = H(null);
235
- Ae.displayName = "ResourceContext";
236
- const Ee = H(null);
237
- Ee.displayName = "TimeContext";
238
- function pt(e) {
250
+ }, Ae = O(null);
251
+ Ae.displayName = "PlaybackContext";
252
+ const Ie = O(null);
253
+ Ie.displayName = "AudioAttrsContext";
254
+ const Se = O(null);
255
+ Se.displayName = "TrackContext";
256
+ const we = O(null);
257
+ we.displayName = "UIContext";
258
+ const Le = O(null);
259
+ Le.displayName = "ResourceContext";
260
+ const Ne = O(null);
261
+ Ne.displayName = "TimeContext";
262
+ const E = (e) => {
263
+ const t = he(e);
264
+ if (!t) {
265
+ const n = e.displayName || "Context";
266
+ throw new Error(`${n} is not provided`);
267
+ }
268
+ return t;
269
+ }, C = () => E(Ae), te = () => E(Ne), K = () => E(Se), x = () => E(we), N = () => E(Le), Ot = () => E(Ie);
270
+ function Vt(e) {
239
271
  const {
240
272
  playList: t,
241
- audioInitialState: o,
242
- activeUI: r,
243
- placement: a,
244
- customIcons: s,
245
- coverImgsCss: n
273
+ audioInitialState: n,
274
+ activeUI: a,
275
+ placement: r,
276
+ customIcons: i,
277
+ coverImgsCss: o
246
278
  } = e, c = {
247
- isPlaying: (o == null ? void 0 : o.isPlaying) ?? F.isPlaying,
248
- repeatType: (o == null ? void 0 : o.repeatType) ?? F.repeatType,
249
- volume: typeof (o == null ? void 0 : o.volume) == "number" ? be(o.volume) : F.volume,
250
- muted: (o == null ? void 0 : o.muted) ?? F.muted
251
- }, l = r || { playButton: !0 }, u = {
252
- playerPlacement: a == null ? void 0 : a.player,
253
- playListPlacement: (a == null ? void 0 : a.playList) || "bottom",
254
- interfacePlacement: (a == null ? void 0 : a.interface) || {
279
+ isPlaying: (n == null ? void 0 : n.isPlaying) ?? H.isPlaying,
280
+ repeatType: (n == null ? void 0 : n.repeatType) ?? H.repeatType,
281
+ volume: typeof (n == null ? void 0 : n.volume) == "number" ? Fe(n.volume) : H.volume,
282
+ muted: (n == null ? void 0 : n.muted) ?? H.muted
283
+ }, u = a || { playButton: !0 }, d = {
284
+ playerPlacement: r == null ? void 0 : r.player,
285
+ playListPlacement: (r == null ? void 0 : r.playList) || "bottom",
286
+ interfacePlacement: (r == null ? void 0 : r.interface) || {
255
287
  templateArea: {
256
- playButton: k.templateArea.playButton
288
+ playButton: de.templateArea.playButton
257
289
  }
258
290
  },
259
- volumeSliderPlacement: a == null ? void 0 : a.volumeSlider
260
- };
291
+ volumeSliderPlacement: r == null ? void 0 : r.volumeSlider
292
+ }, l = t.length === 0, p = n == null ? void 0 : n.curPlayId, m = p == null ? -1 : t.findIndex((y) => y.id === p);
261
293
  return {
262
294
  playList: t,
263
- curPlayId: (o == null ? void 0 : o.curPlayId) || 1,
264
- curIdx: o != null && o.curPlayId ? t.findIndex(
265
- (m) => m.id === (o == null ? void 0 : o.curPlayId)
266
- ) : 0,
295
+ curPlayId: l ? 0 : m >= 0 ? p : t[0].id,
296
+ curIdx: l ? -1 : m >= 0 ? m : 0,
267
297
  curAudioState: c,
268
- activeUI: l,
298
+ activeUI: u,
269
299
  audioResetKey: 0,
270
300
  seekRequestKey: 0,
271
- ...u,
272
- customIcons: s,
273
- coverImgsCss: n
301
+ ...d,
302
+ customIcons: i,
303
+ coverImgsCss: o
274
304
  };
275
305
  }
276
- const yt = ({
306
+ const Kt = ({
277
307
  children: e,
278
308
  colorScheme: t,
279
- ...o
309
+ ...n
280
310
  }) => {
281
- var d, p;
282
- const [r, a] = nt(
283
- mt,
284
- o,
285
- pt
286
- ), s = D(
311
+ var y, f;
312
+ const [a, r] = kt(
313
+ Ut,
314
+ n,
315
+ Vt
316
+ ), i = k(
287
317
  () => ({
288
- currentTime: r.curAudioState.currentTime ?? F.currentTime,
289
- duration: r.curAudioState.duration ?? F.duration,
290
- seekRequestKey: r.seekRequestKey
318
+ currentTime: a.curAudioState.currentTime ?? H.currentTime,
319
+ duration: a.curAudioState.duration ?? H.duration,
320
+ seekRequestKey: a.seekRequestKey
291
321
  }),
292
322
  [
293
- r.curAudioState.currentTime,
294
- r.curAudioState.duration,
295
- r.seekRequestKey
323
+ a.curAudioState.currentTime,
324
+ a.curAudioState.duration,
325
+ a.seekRequestKey
296
326
  ]
297
- ), n = D(
327
+ ), o = k(
298
328
  () => ({
299
- isPlaying: r.curAudioState.isPlaying ?? F.isPlaying,
300
- volume: r.curAudioState.volume ?? F.volume,
301
- muted: r.curAudioState.muted ?? F.muted,
302
- repeatType: r.curAudioState.repeatType,
303
- isLoadedMetaData: r.curAudioState.isLoadedMetaData,
304
- audioResetKey: r.audioResetKey
329
+ isPlaying: a.curAudioState.isPlaying ?? H.isPlaying,
330
+ volume: a.curAudioState.volume ?? H.volume,
331
+ muted: a.curAudioState.muted ?? H.muted,
332
+ repeatType: a.curAudioState.repeatType,
333
+ isLoadedMetaData: a.curAudioState.isLoadedMetaData,
334
+ audioResetKey: a.audioResetKey
305
335
  }),
306
336
  [
307
- r.curAudioState.isPlaying,
308
- r.curAudioState.isLoadedMetaData,
309
- r.curAudioState.volume,
310
- r.curAudioState.muted,
311
- r.curAudioState.repeatType,
312
- r.audioResetKey
337
+ a.curAudioState.isPlaying,
338
+ a.curAudioState.isLoadedMetaData,
339
+ a.curAudioState.volume,
340
+ a.curAudioState.muted,
341
+ a.curAudioState.repeatType,
342
+ a.audioResetKey
313
343
  ]
314
- ), c = D(
344
+ ), c = k(
315
345
  () => ({
316
- playList: r.playList,
317
- curPlayId: r.curPlayId,
318
- curIdx: r.curIdx
346
+ playList: a.playList,
347
+ curPlayId: a.curPlayId,
348
+ curIdx: a.curIdx
319
349
  }),
320
- [r.playList, r.curPlayId, r.curIdx]
321
- ), l = D(
350
+ [a.playList, a.curPlayId, a.curIdx]
351
+ ), { audioInitialState: u } = n, d = u == null ? void 0 : u.playListExpanded, l = k(
322
352
  () => ({
323
- activeUI: r.activeUI,
324
- playListPlacement: r.playListPlacement,
325
- playerPlacement: r.playerPlacement,
326
- interfacePlacement: r.interfacePlacement,
327
- volumeSliderPlacement: r.volumeSliderPlacement,
328
- colorScheme: t
353
+ activeUI: a.activeUI,
354
+ playListPlacement: a.playListPlacement,
355
+ playerPlacement: a.playerPlacement,
356
+ interfacePlacement: a.interfacePlacement,
357
+ volumeSliderPlacement: a.volumeSliderPlacement,
358
+ colorScheme: t,
359
+ playListExpanded: d
329
360
  }),
330
361
  [
331
- r.activeUI,
332
- r.playListPlacement,
333
- r.playerPlacement,
334
- r.interfacePlacement,
335
- r.volumeSliderPlacement,
336
- t
362
+ a.activeUI,
363
+ a.playListPlacement,
364
+ a.playerPlacement,
365
+ a.interfacePlacement,
366
+ a.volumeSliderPlacement,
367
+ t,
368
+ d
337
369
  ]
338
- ), { audioInitialState: u } = o, m = D(() => {
370
+ ), p = k(() => {
339
371
  if (!u) return {};
340
372
  const {
341
- isPlaying: h,
342
- repeatType: v,
343
- isLoadedMetaData: T,
344
- currentTime: L,
345
- duration: N,
346
- volume: B,
347
- muted: R,
348
- curPlayId: G,
349
- ...ae
373
+ isPlaying: v,
374
+ repeatType: T,
375
+ isLoadedMetaData: h,
376
+ currentTime: I,
377
+ duration: B,
378
+ volume: re,
379
+ muted: se,
380
+ curPlayId: D,
381
+ playListExpanded: ce,
382
+ ...q
350
383
  } = u;
351
- return ae;
352
- }, [u]), y = D(
384
+ return q;
385
+ }, [u]), m = k(
353
386
  () => ({
354
- elementRefs: r.elementRefs,
355
- customIcons: r.customIcons,
356
- coverImgsCss: r.coverImgsCss
387
+ elementRefs: a.elementRefs,
388
+ customIcons: a.customIcons,
389
+ coverImgsCss: a.coverImgsCss
357
390
  }),
358
391
  [
359
- (d = r.elementRefs) == null ? void 0 : d.audioEl,
360
- (p = r.elementRefs) == null ? void 0 : p.waveformInst,
361
- r.customIcons,
362
- r.coverImgsCss
392
+ (y = a.elementRefs) == null ? void 0 : y.audioEl,
393
+ (f = a.elementRefs) == null ? void 0 : f.waveformInst,
394
+ a.customIcons,
395
+ a.coverImgsCss
363
396
  ]
364
397
  );
365
- return /* @__PURE__ */ i(Ee.Provider, { value: s, children: /* @__PURE__ */ i(he.Provider, { value: n, children: /* @__PURE__ */ i(ge.Provider, { value: c, children: /* @__PURE__ */ i(fe.Provider, { value: l, children: /* @__PURE__ */ i(Ae.Provider, { value: y, children: /* @__PURE__ */ i(Te.Provider, { value: m, children: /* @__PURE__ */ i(w.Provider, { value: a, children: e }) }) }) }) }) }) });
366
- }, f = (e) => {
367
- const t = st(e);
368
- if (!t) {
369
- const o = e.displayName || "Context";
370
- throw new Error(`${o} is not provided`);
371
- }
372
- return t;
373
- }, O = () => f(fe), J = {
398
+ return /* @__PURE__ */ s(Ne.Provider, { value: i, children: /* @__PURE__ */ s(Ae.Provider, { value: o, children: /* @__PURE__ */ s(Se.Provider, { value: c, children: /* @__PURE__ */ s(we.Provider, { value: l, children: /* @__PURE__ */ s(Le.Provider, { value: m, children: /* @__PURE__ */ s(Ie.Provider, { value: p, children: /* @__PURE__ */ s(L.Provider, { value: r, children: e }) }) }) }) }) }) });
399
+ }, Q = {
374
400
  top: "auto",
375
401
  right: "auto",
376
402
  bottom: "auto",
377
403
  left: "auto"
378
- }, vt = {
379
- bottom: { ...J, bottom: 0 },
380
- top: { ...J, top: 0 },
381
- "bottom-left": { ...J, bottom: 0, left: 0 },
382
- "bottom-right": { ...J, bottom: 0, right: 0 },
383
- "top-left": { ...J, top: 0, left: 0 },
384
- "top-right": { ...J, top: 0, right: 0 }
385
- }, Ce = te.memo(({ children: e, rootContainerProps: t }) => {
386
- const { playerPlacement: o, colorScheme: r } = O(), a = D(
387
- () => o ? vt[o] : void 0,
388
- [o]
389
- ), n = {
404
+ }, Bt = {
405
+ bottom: { ...Q, bottom: 0 },
406
+ top: { ...Q, top: 0 },
407
+ "bottom-left": { ...Q, bottom: 0, left: 0 },
408
+ "bottom-right": { ...Q, bottom: 0, right: 0 },
409
+ "top-left": { ...Q, top: 0, left: 0 },
410
+ "top-right": { ...Q, top: 0, right: 0 }
411
+ }, He = ee.memo(({ children: e, rootContainerProps: t }) => {
412
+ const { playerPlacement: n, colorScheme: a } = x(), r = k(
413
+ () => n ? Bt[n] : void 0,
414
+ [n]
415
+ ), o = {
390
416
  width: "100%",
391
- position: o !== "static" && !!o ? "fixed" : "static",
392
- ...a,
417
+ position: n !== "static" && !!n ? "fixed" : "static",
418
+ ...r,
393
419
  ...(t == null ? void 0 : t.style) ?? {}
394
420
  };
395
- return /* @__PURE__ */ i(
421
+ return /* @__PURE__ */ s(
396
422
  "div",
397
423
  {
398
424
  ...t,
399
425
  className: `rmap-player-provider${t != null && t.className ? ` ${t.className}` : ""}`,
400
- "data-theme": r ?? void 0,
401
- style: n,
426
+ "data-theme": a ?? void 0,
427
+ style: o,
402
428
  children: e
403
429
  }
404
430
  );
405
431
  });
406
- Ce.displayName = "AudioPlayerContainer";
407
- const ht = ({
432
+ He.displayName = "AudioPlayerContainer";
433
+ const $t = ({
408
434
  areas: e,
409
435
  columns: t,
410
- alignItems: o,
411
- justifyContent: r,
412
- minHeight: a,
413
- UNSAFE_className: s,
414
- children: n
436
+ alignItems: n,
437
+ justifyContent: a,
438
+ minHeight: r,
439
+ UNSAFE_className: i,
440
+ children: o
415
441
  }) => {
416
442
  const c = {
417
443
  display: "grid",
418
- gridTemplateAreas: e == null ? void 0 : e.map((l) => `"${l}"`).join(" "),
444
+ gridTemplateAreas: e == null ? void 0 : e.map((u) => `"${u}"`).join(" "),
419
445
  gridTemplateColumns: t == null ? void 0 : t.join(" "),
420
- alignItems: o,
421
- justifyContent: r,
422
- minHeight: a
446
+ alignItems: n,
447
+ justifyContent: a,
448
+ minHeight: r
423
449
  };
424
- return /* @__PURE__ */ i("div", { className: s, style: c, children: n });
425
- }, Tt = ht, Me = ve(
450
+ return /* @__PURE__ */ s("div", { className: i, style: c, children: o });
451
+ }, Ft = $t, Re = Pe(
426
452
  ({
427
453
  children: e,
428
454
  visible: t = !0,
429
- gridArea: o,
430
- width: r,
431
- justifySelf: a = "center",
432
- padding: s,
433
- UNSAFE_className: n,
455
+ gridArea: n,
456
+ width: a,
457
+ justifySelf: r = "center",
458
+ padding: i,
459
+ UNSAFE_className: o,
434
460
  style: c,
435
- ...l
436
- }, u) => {
461
+ ...u
462
+ }, d) => {
437
463
  if (!t) return null;
438
- const m = {
439
- gridArea: o,
440
- width: r,
441
- justifySelf: a,
442
- padding: s ?? "0 5px",
464
+ const l = {
465
+ gridArea: n,
466
+ width: a,
467
+ justifySelf: r,
468
+ padding: i ?? "0 5px",
443
469
  ...c
444
470
  };
445
- return /* @__PURE__ */ i("div", { ref: u, className: n, style: m, ...l, children: e });
471
+ return /* @__PURE__ */ s("div", { ref: d, className: o, style: l, ...u, children: e });
446
472
  }
447
473
  );
448
- Me.displayName = "GridItem";
449
- const M = Tt;
450
- M.Item = Me;
451
- const C = () => f(he), re = () => f(Ee), V = () => f(ge), P = () => f(Ae), xe = ({
474
+ Re.displayName = "GridItem";
475
+ const _ = Ft;
476
+ _.Item = Re;
477
+ const Ht = ({
452
478
  children: e,
453
479
  id: t,
454
- ...o
480
+ ...n
455
481
  }) => {
456
- var m, y;
457
- const r = C(), a = re(), s = V(), n = O(), c = P(), l = {
482
+ var l, p;
483
+ const a = C(), r = te(), i = K(), o = x(), c = N(), u = {
458
484
  curAudioState: {
459
- isPlaying: r.isPlaying,
460
- volume: r.volume,
461
- muted: r.muted,
462
- repeatType: r.repeatType,
463
- isLoadedMetaData: r.isLoadedMetaData,
464
- currentTime: a.currentTime,
465
- duration: a.duration
485
+ isPlaying: a.isPlaying,
486
+ volume: a.volume,
487
+ muted: a.muted,
488
+ repeatType: a.repeatType,
489
+ isLoadedMetaData: a.isLoadedMetaData,
490
+ currentTime: r.currentTime,
491
+ duration: r.duration
466
492
  },
467
- audioResetKey: r.audioResetKey,
468
- ...a,
469
- ...s,
470
- ...n,
493
+ audioResetKey: a.audioResetKey,
494
+ ...r,
495
+ ...i,
496
+ ...o,
471
497
  ...c
472
- }, u = (y = (m = n.interfacePlacement) == null ? void 0 : m.customComponentsArea) == null ? void 0 : y[t];
473
- return /* @__PURE__ */ i(
474
- M.Item,
498
+ }, d = (p = (l = o.interfacePlacement) == null ? void 0 : l.customComponentsArea) == null ? void 0 : p[t];
499
+ return /* @__PURE__ */ s(
500
+ _.Item,
475
501
  {
476
502
  UNSAFE_className: "rmap-custom-component",
477
- gridArea: u,
478
- ...o,
479
- children: te.cloneElement(e, { audioPlayerState: l })
503
+ gridArea: d,
504
+ ...n,
505
+ children: ee.cloneElement(e, { audioPlayerState: u })
480
506
  }
481
507
  );
482
- }, gt = () => f(Te), ft = () => {
508
+ }, ze = "PlayListEmpty", Ge = () => null;
509
+ Ge.displayName = ze;
510
+ const Rt = () => {
483
511
  const {
484
512
  isPlaying: e,
485
513
  volume: t,
486
- repeatType: o,
487
- audioResetKey: r
488
- } = C(), { currentTime: a, seekRequestKey: s } = re(), { elementRefs: n } = P(), c = f(w), l = g(
489
- (p) => {
490
- if (p.currentTarget.readyState === 0) return;
491
- const h = p.currentTarget.currentTime;
514
+ repeatType: n,
515
+ audioResetKey: a
516
+ } = C(), { currentTime: r, seekRequestKey: i } = te(), { elementRefs: o } = N(), c = E(L), u = g(
517
+ (y) => {
518
+ if (y.currentTarget.readyState === 0) return;
519
+ const f = y.currentTarget.currentTime;
492
520
  c({
493
521
  type: "SET_AUDIO_STATE",
494
- audioState: { currentTime: h }
522
+ audioState: { currentTime: f }
495
523
  });
496
524
  },
497
525
  [c]
498
- ), u = g(() => {
499
- if (n != null && n.audioEl) {
500
- if (o === "ONE") {
501
- ut(() => {
526
+ ), d = g(() => {
527
+ if (o != null && o.audioEl) {
528
+ if (n === "ONE") {
529
+ $e(() => {
502
530
  c({ type: "SEEK", time: 0 });
503
- }), n.audioEl.play();
531
+ }), o.audioEl.play();
504
532
  return;
505
533
  }
506
534
  c({ type: "NEXT_AUDIO" });
507
535
  }
508
- }, [c, o, n == null ? void 0 : n.audioEl]), m = g(
509
- (p) => {
510
- const { duration: h } = p.currentTarget;
511
- t != null && (p.currentTarget.volume = t), c({
536
+ }, [c, n, o == null ? void 0 : o.audioEl]), l = g(
537
+ (y) => {
538
+ const { duration: f } = y.currentTarget;
539
+ t != null && (y.currentTarget.volume = t), c({
512
540
  type: "SET_AUDIO_STATE",
513
- audioState: { isLoadedMetaData: !0, duration: h }
541
+ audioState: { isLoadedMetaData: !0, duration: f }
514
542
  });
515
543
  },
516
544
  [c, t]
517
- ), y = A(!1);
518
- E(() => {
519
- if (n != null && n.audioEl) {
520
- if (!y.current) {
521
- y.current = !0;
545
+ ), p = A(!1);
546
+ P(() => {
547
+ if (o != null && o.audioEl) {
548
+ if (!p.current) {
549
+ p.current = !0;
522
550
  return;
523
551
  }
524
- n.audioEl.currentTime = 0;
552
+ o.audioEl.currentTime = 0;
525
553
  }
526
- }, [r, n == null ? void 0 : n.audioEl]), E(() => {
527
- n != null && n.audioEl && (e ? n.audioEl.play().catch(() => {
554
+ }, [a, o == null ? void 0 : o.audioEl]), P(() => {
555
+ o != null && o.audioEl && (e ? o.audioEl.play().catch(() => {
528
556
  c({
529
557
  type: "SET_AUDIO_STATE",
530
558
  audioState: { isPlaying: !1 }
531
559
  });
532
- }) : n.audioEl.pause());
533
- }, [n == null ? void 0 : n.audioEl, e, c]), E(() => {
534
- !(n != null && n.audioEl) || t == null || (n.audioEl.volume = t);
535
- }, [n == null ? void 0 : n.audioEl, t]);
536
- const d = A(0);
537
- return E(() => {
538
- if (s === d.current) return;
539
- d.current = s;
540
- const p = n == null ? void 0 : n.audioEl;
541
- if (!p || a == null) return;
542
- p.currentTime = a;
543
- const h = n == null ? void 0 : n.waveformInst, v = p.duration, T = Number.isFinite(v) && v > 0;
544
- if (!h || !T) return;
545
- const L = a / v, N = Math.min(1, Math.max(0, L));
546
- h.seekTo(N);
560
+ }) : o.audioEl.pause());
561
+ }, [o == null ? void 0 : o.audioEl, e, c]), P(() => {
562
+ !(o != null && o.audioEl) || t == null || (o.audioEl.volume = t);
563
+ }, [o == null ? void 0 : o.audioEl, t]);
564
+ const m = A(0);
565
+ return P(() => {
566
+ if (i === m.current) return;
567
+ m.current = i;
568
+ const y = o == null ? void 0 : o.audioEl;
569
+ if (!y || r == null) return;
570
+ y.currentTime = r;
571
+ const f = o == null ? void 0 : o.waveformInst, v = y.duration, T = Number.isFinite(v) && v > 0;
572
+ if (!f || !T) return;
573
+ const h = r / v, I = Math.min(1, Math.max(0, h));
574
+ f.seekTo(I);
547
575
  }, [
548
- s,
549
- a,
550
- n == null ? void 0 : n.audioEl,
551
- n == null ? void 0 : n.waveformInst
576
+ i,
577
+ r,
578
+ o == null ? void 0 : o.audioEl,
579
+ o == null ? void 0 : o.waveformInst
552
580
  ]), {
553
- onTimeUpdate: l,
554
- onEnded: u,
555
- onLoadedMetadata: m
581
+ onTimeUpdate: u,
582
+ onEnded: d,
583
+ onLoadedMetadata: l
556
584
  };
557
- }, _e = te.memo(({ audioRef: e }) => {
558
- const t = A(null), { muted: o } = C(), { curPlayId: r, playList: a } = V(), s = gt(), n = f(w), c = a.find(
559
- (u) => u.id === r
560
- ), l = ft();
561
- return E(() => {
562
- t.current && (n({
585
+ }, We = ee.memo(({ audioRef: e }) => {
586
+ const t = A(null), { muted: n } = C(), { curPlayId: a, playList: r } = K(), i = Ot(), o = E(L), c = r.find(
587
+ (d) => d.id === a
588
+ ), u = Rt();
589
+ return P(() => {
590
+ t.current && (o({
563
591
  type: "SET_ELEMENT_REFS",
564
592
  elementRefs: { audioEl: t.current }
565
593
  }), e && (e.current = t.current));
566
- }, [n, e]), /* @__PURE__ */ i(
594
+ }, [o, e]), /* @__PURE__ */ s(
567
595
  "audio",
568
596
  {
569
597
  id: "rm-audio-player-audio",
570
- ...s,
571
- muted: o,
598
+ ...i,
599
+ muted: n,
572
600
  ref: t,
573
601
  src: c == null ? void 0 : c.src,
574
- ...l
602
+ ...u
575
603
  }
576
604
  );
577
605
  });
578
- _e.displayName = "Audio";
579
- const Y = ve(({ className: e, type: t = "button", ...o }, r) => /* @__PURE__ */ i(
606
+ We.displayName = "Audio";
607
+ function z(e, t) {
608
+ var a, r;
609
+ const { interfacePlacement: n } = x();
610
+ return t ?? ((a = n == null ? void 0 : n.itemCustomArea) == null ? void 0 : a[e]) ?? ((r = n == null ? void 0 : n.templateArea) == null ? void 0 : r[e]) ?? de.templateArea[e];
611
+ }
612
+ const j = Pe(({ className: e, type: t = "button", ...n }, a) => /* @__PURE__ */ s(
580
613
  "button",
581
614
  {
582
- ref: r,
615
+ ref: a,
583
616
  type: t,
584
617
  className: `styled-btn${e ? ` ${e}` : ""}`,
585
- ...o
618
+ ...n
586
619
  }
587
620
  ));
588
- Y.displayName = "StyledBtn";
589
- const Ie = (e) => (
621
+ j.displayName = "StyledBtn";
622
+ const be = (e) => (
590
623
  // eslint-disable-next-line react/display-name
591
- ({ size: t = "1em", color: o, style: r, ...a }) => /* @__PURE__ */ i(
624
+ ({ size: t = "1em", color: n, style: a, ...r }) => /* @__PURE__ */ s(
592
625
  "svg",
593
626
  {
594
627
  "aria-hidden": "true",
@@ -599,16 +632,16 @@ const Ie = (e) => (
599
632
  viewBox: "0 0 24 24",
600
633
  height: t,
601
634
  width: t,
602
- color: o,
603
- style: o ? { color: o, ...r } : r,
635
+ color: n,
636
+ style: n ? { color: n, ...a } : a,
604
637
  xmlns: "http://www.w3.org/2000/svg",
605
- ...a,
638
+ ...r,
606
639
  dangerouslySetInnerHTML: { __html: e }
607
640
  }
608
641
  )
609
- ), q = (e) => (
642
+ ), Y = (e) => (
610
643
  // eslint-disable-next-line react/display-name
611
- ({ size: t = "1em", color: o, style: r, ...a }) => /* @__PURE__ */ i(
644
+ ({ size: t = "1em", color: n, style: a, ...r }) => /* @__PURE__ */ s(
612
645
  "svg",
613
646
  {
614
647
  "aria-hidden": "true",
@@ -621,16 +654,16 @@ const Ie = (e) => (
621
654
  strokeLinejoin: "round",
622
655
  height: t,
623
656
  width: t,
624
- color: o,
625
- style: o ? { color: o, ...r } : r,
657
+ color: n,
658
+ style: n ? { color: n, ...a } : a,
626
659
  xmlns: "http://www.w3.org/2000/svg",
627
- ...a,
660
+ ...r,
628
661
  dangerouslySetInnerHTML: { __html: e }
629
662
  }
630
663
  )
631
- ), De = (e, t = "0 0 16 16") => (
664
+ ), je = (e, t = "0 0 16 16") => (
632
665
  // eslint-disable-next-line react/display-name
633
- ({ size: o = "1em", color: r, style: a, ...s }) => /* @__PURE__ */ i(
666
+ ({ size: n = "1em", color: a, style: r, ...i }) => /* @__PURE__ */ s(
634
667
  "svg",
635
668
  {
636
669
  "aria-hidden": "true",
@@ -639,437 +672,506 @@ const Ie = (e) => (
639
672
  fill: "currentColor",
640
673
  strokeWidth: 0,
641
674
  viewBox: t,
642
- height: o,
643
- width: o,
644
- color: r,
645
- style: r ? { color: r, ...a } : a,
675
+ height: n,
676
+ width: n,
677
+ color: a,
678
+ style: a ? { color: a, ...r } : r,
646
679
  xmlns: "http://www.w3.org/2000/svg",
647
- ...s,
680
+ ...i,
648
681
  dangerouslySetInnerHTML: { __html: e }
649
682
  }
650
683
  )
651
- ), Oe = Ie(
684
+ ), Ye = be(
652
685
  '<path fill="none" d="M0 0h24v24H0z"/><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 14.5v-9l6 4.5-6 4.5z"/>'
653
686
  );
654
- Oe.displayName = "MdPlayCircleFilled";
655
- const Ue = Ie(
687
+ Ye.displayName = "MdPlayCircleFilled";
688
+ const qe = be(
656
689
  '<path fill="none" d="M0 0h24v24H0z"/><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 14H9V8h2v8zm4 0h-2V8h2v8z"/>'
657
690
  );
658
- Ue.displayName = "MdPauseCircleFilled";
659
- const Ve = Ie(
691
+ qe.displayName = "MdPauseCircleFilled";
692
+ const Xe = be(
660
693
  '<path fill="none" d="M0 0h24v24H0z"/><path d="M3 10h11v2H3zM3 6h11v2H3zM3 14h7v2H3zM16 13v8l6-4z"/>'
661
694
  );
662
- Ve.displayName = "MdPlaylistPlay";
663
- const Be = q(
695
+ Xe.displayName = "MdPlaylistPlay";
696
+ const Qe = Y(
664
697
  '<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 12v-3a3 3 0 0 1 3 -3h13m-3 -3l3 3l-3 3"/><path d="M20 12v3a3 3 0 0 1 -3 3h-13m3 3l-3 -3l3 -3"/>'
665
698
  );
666
- Be.displayName = "TbRepeat";
667
- const Ke = q(
699
+ Qe.displayName = "TbRepeat";
700
+ const Je = Y(
668
701
  '<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 12v-3a3 3 0 0 1 3 -3h13m-3 -3l3 3l-3 3"/><path d="M20 12v3a3 3 0 0 1 -3 3h-13m3 3l-3 -3l3 -3"/><path d="M11 11l1 -1v4"/>'
669
702
  );
670
- Ke.displayName = "TbRepeatOnce";
671
- const $e = q(
703
+ Je.displayName = "TbRepeatOnce";
704
+ const Ze = Y(
672
705
  '<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 12v-3c0 -1.336 .873 -2.468 2.08 -2.856m3.92 -.144h10m-3 -3l3 3l-3 3"/><path d="M20 12v3a3 3 0 0 1 -.133 .886m-1.99 1.984a3 3 0 0 1 -.877 .13h-13m3 3l-3 -3l3 -3"/><path d="M3 3l18 18"/>'
673
706
  );
674
- $e.displayName = "TbRepeatOff";
675
- const Fe = q(
707
+ Ze.displayName = "TbRepeatOff";
708
+ const et = Y(
676
709
  '<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M18 4l3 3l-3 3"/><path d="M18 20l3 -3l-3 -3"/><path d="M3 7h3a5 5 0 0 1 5 5a5 5 0 0 0 5 5h5"/><path d="M21 7h-5a4.978 4.978 0 0 0 -2.998 .998m-4.002 8.003a4.984 4.984 0 0 1 -3 .999h-3"/>'
677
710
  );
678
- Fe.displayName = "TbArrowsShuffle";
679
- const He = q(
711
+ et.displayName = "TbArrowsShuffle";
712
+ const tt = Y(
680
713
  '<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M15 8a5 5 0 0 1 0 8"/><path d="M17.7 5a9 9 0 0 1 0 14"/><path d="M6 15h-2a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h2l3.5 -4.5a0.8 .8 0 0 1 1.5 .5v14a0.8 .8 0 0 1 -1.5 .5l-3.5 -4.5"/>'
681
714
  );
682
- He.displayName = "TbVolume";
683
- const Re = q(
715
+ tt.displayName = "TbVolume";
716
+ const rt = Y(
684
717
  '<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M15 8a5 5 0 0 1 0 8"/><path d="M6 15h-2a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h2l3.5 -4.5a0.8 .8 0 0 1 1.5 .5v14a0.8 .8 0 0 1 -1.5 .5l-3.5 -4.5"/>'
685
718
  );
686
- Re.displayName = "TbVolume2";
687
- const ze = q(
719
+ rt.displayName = "TbVolume2";
720
+ const at = Y(
688
721
  '<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M6 15h-2a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h2l3.5 -4.5a0.8 .8 0 0 1 1.5 .5v14a0.8 .8 0 0 1 -1.5 .5l-3.5 -4.5"/><path d="M16 10l4 4m0 -4l-4 4"/>'
689
722
  );
690
- ze.displayName = "TbVolume3";
691
- const We = De(
723
+ at.displayName = "TbVolume3";
724
+ const nt = je(
692
725
  '<path d="M8 0c-4.418 0-8 3.582-8 8s3.582 8 8 8 8-3.582 8-8-3.582-8-8-8zM8 14.5c-3.59 0-6.5-2.91-6.5-6.5s2.91-6.5 6.5-6.5 6.5 2.91 6.5 6.5-2.91 6.5-6.5 6.5z"/><path d="M7 8l4-3v6z"/><path d="M5 5h2v6h-2v-6z"/>'
693
726
  );
694
- We.displayName = "ImPrevious";
695
- const Ge = De(
727
+ nt.displayName = "ImPrevious";
728
+ const ot = je(
696
729
  '<path d="M8 0c4.418 0 8 3.582 8 8s-3.582 8-8 8-8-3.582-8-8 3.582-8 8-8zM8 14.5c3.59 0 6.5-2.91 6.5-6.5s-2.91-6.5-6.5-6.5-6.5 2.91-6.5 6.5 2.91 6.5 6.5 6.5z"/><path d="M9 8l-4-3v6z"/><path d="M11 5h-2v6h2v-6z"/>'
697
730
  );
698
- Ge.displayName = "ImNext";
699
- const x = ({ render: e, customIcon: t }) => /* @__PURE__ */ i(z, { children: t ?? e }), At = W(function() {
700
- const { isPlaying: t } = C(), { customIcons: o } = P(), r = f(w);
701
- return /* @__PURE__ */ i(
702
- Y,
731
+ ot.displayName = "ImNext";
732
+ const M = ({ render: e, customIcon: t }) => /* @__PURE__ */ s(R, { children: t ?? e }), zt = G(function() {
733
+ const { isPlaying: t } = C(), { customIcons: n } = N(), a = E(L);
734
+ return /* @__PURE__ */ s(
735
+ j,
703
736
  {
704
737
  type: "button",
705
738
  "aria-label": t ? "Pause" : "Play",
706
- onClick: () => r({ type: "CHANGE_PLAYING_STATE" }),
739
+ onClick: () => a({ type: "CHANGE_PLAYING_STATE" }),
707
740
  className: "rmap-play-btn",
708
741
  "data-testid": "play-btn",
709
- children: t ? /* @__PURE__ */ i(
710
- x,
742
+ children: t ? /* @__PURE__ */ s(
743
+ M,
711
744
  {
712
- render: /* @__PURE__ */ i(Ue, {}),
713
- customIcon: o == null ? void 0 : o.pause
745
+ render: /* @__PURE__ */ s(qe, {}),
746
+ customIcon: n == null ? void 0 : n.pause
714
747
  }
715
- ) : /* @__PURE__ */ i(x, { render: /* @__PURE__ */ i(Oe, {}), customIcon: o == null ? void 0 : o.play })
748
+ ) : /* @__PURE__ */ s(M, { render: /* @__PURE__ */ s(Ye, {}), customIcon: n == null ? void 0 : n.play })
716
749
  }
717
750
  );
718
- }), Et = W(function({ isVisible: t }) {
719
- const { customIcons: o, elementRefs: r } = P(), a = f(w);
720
- return t ? /* @__PURE__ */ i(
721
- Y,
751
+ }), Gt = G(function({ isVisible: t }) {
752
+ const { customIcons: n, elementRefs: a } = N(), r = E(L);
753
+ return t ? /* @__PURE__ */ s(
754
+ j,
722
755
  {
723
756
  type: "button",
724
757
  "aria-label": "Previous track",
725
758
  onClick: () => {
726
759
  var c;
727
- const n = ((c = r == null ? void 0 : r.audioEl) == null ? void 0 : c.currentTime) ?? 0;
728
- a({ type: "PREV_AUDIO", currentTime: n });
760
+ const o = ((c = a == null ? void 0 : a.audioEl) == null ? void 0 : c.currentTime) ?? 0;
761
+ r({ type: "PREV_AUDIO", currentTime: o });
729
762
  },
730
763
  className: "rmap-prev-btn",
731
764
  "data-testid": "prev-btn",
732
- children: /* @__PURE__ */ i(x, { render: /* @__PURE__ */ i(We, {}), customIcon: o == null ? void 0 : o.prev })
765
+ children: /* @__PURE__ */ s(M, { render: /* @__PURE__ */ s(nt, {}), customIcon: n == null ? void 0 : n.prev })
733
766
  }
734
767
  ) : null;
735
- }), It = W(function({ isVisible: t }) {
736
- const { customIcons: o } = P(), r = f(w);
737
- return t ? /* @__PURE__ */ i(
738
- Y,
768
+ }), Wt = G(function({ isVisible: t }) {
769
+ const { customIcons: n } = N(), a = E(L);
770
+ return t ? /* @__PURE__ */ s(
771
+ j,
739
772
  {
740
773
  type: "button",
741
774
  "aria-label": "Next track",
742
775
  onClick: () => {
743
- r({ type: "NEXT_AUDIO" });
776
+ a({ type: "NEXT_AUDIO" });
744
777
  },
745
778
  className: "rmap-next-btn",
746
779
  "data-testid": "next-btn",
747
- children: /* @__PURE__ */ i(x, { render: /* @__PURE__ */ i(Ge, {}), customIcon: o == null ? void 0 : o.next })
780
+ children: /* @__PURE__ */ s(M, { render: /* @__PURE__ */ s(ot, {}), customIcon: n == null ? void 0 : n.next })
748
781
  }
749
782
  ) : null;
750
- }), St = {
783
+ }), it = ({
784
+ gridArea: e,
785
+ visible: t,
786
+ ...n
787
+ }) => {
788
+ const { activeUI: a } = x(), r = !!(a.prevNnext ?? a.all), i = z("playButton", e);
789
+ return /* @__PURE__ */ s(_.Item, { gridArea: i, visible: t ?? !0, ...n, children: /* @__PURE__ */ w(
790
+ "div",
791
+ {
792
+ className: "rmap-ctrl-btn-wrapper",
793
+ role: "group",
794
+ "aria-label": "Playback controls",
795
+ children: [
796
+ /* @__PURE__ */ s(Gt, { isVisible: r }),
797
+ /* @__PURE__ */ s(zt, {}),
798
+ /* @__PURE__ */ s(Wt, { isVisible: r })
799
+ ]
800
+ }
801
+ ) });
802
+ }, jt = {
751
803
  ALL: "Repeat: All tracks",
752
804
  ONE: "Repeat: One track",
753
805
  NONE: "Repeat: Off",
754
806
  SHUFFLE: "Shuffle"
755
- }, wt = {
807
+ }, Yt = {
756
808
  ALL: "ONE",
757
809
  ONE: "NONE",
758
810
  NONE: "SHUFFLE",
759
811
  SHUFFLE: "ALL"
760
- }, Pt = W(function() {
761
- const { repeatType: t } = C(), { customIcons: o } = P(), r = f(w), a = () => {
762
- r({
763
- type: "SET_REPEAT_TYPE",
764
- repeatType: wt[t]
765
- });
766
- };
767
- return /* @__PURE__ */ S(
768
- Y,
769
- {
770
- type: "button",
771
- "aria-label": St[t],
772
- onClick: a,
773
- className: "rmap-repeat-btn",
774
- "data-testid": "repeat-btn",
775
- "data-repeattype": t,
776
- children: [
777
- t === "ALL" && /* @__PURE__ */ i(x, { render: /* @__PURE__ */ i(Be, {}), customIcon: o == null ? void 0 : o.repeatAll }),
778
- t === "ONE" && /* @__PURE__ */ i(x, { render: /* @__PURE__ */ i(Ke, {}), customIcon: o == null ? void 0 : o.repeatOne }),
779
- t === "NONE" && /* @__PURE__ */ i(x, { render: /* @__PURE__ */ i($e, {}), customIcon: o == null ? void 0 : o.repeatNone }),
780
- t === "SHUFFLE" && /* @__PURE__ */ i(
781
- x,
782
- {
783
- render: /* @__PURE__ */ i(Fe, {}),
784
- customIcon: o == null ? void 0 : o.repeatShuffle
785
- }
786
- )
787
- ]
788
- }
789
- );
790
- }), me = { size: "100%" }, je = W(
791
- ve((e, t) => {
792
- var y;
793
- const { volume: o, muted: r } = C(), { customIcons: a, elementRefs: s } = P(), n = f(
794
- w
795
- ), c = g(
796
- () => n({ type: "SET_MUTED", muted: !r }),
797
- [n, r]
798
- ), l = o ?? ((y = s == null ? void 0 : s.audioEl) == null ? void 0 : y.volume) ?? 0, u = l > 0 && l <= 0.5, m = l > 0.5;
799
- return /* @__PURE__ */ i(
800
- Y,
812
+ }, st = G(
813
+ function({ gridArea: t, visible: n, ...a }) {
814
+ const { repeatType: r } = C(), { customIcons: i } = N(), o = E(
815
+ L
816
+ ), c = () => {
817
+ o({
818
+ type: "SET_REPEAT_TYPE",
819
+ repeatType: Yt[r]
820
+ });
821
+ }, u = z("repeatType", t);
822
+ return /* @__PURE__ */ s(
823
+ _.Item,
801
824
  {
802
- type: "button",
803
- "aria-label": r ? "Unmute" : "Mute",
804
- "aria-pressed": r,
805
- onClick: c,
806
- className: "rmap-volume-trigger",
807
- "data-testid": "volume-trigger-btn",
808
- "data-muted": String(r),
809
- ref: t,
810
- children: r || l === 0 ? /* @__PURE__ */ i(
811
- x,
812
- {
813
- render: /* @__PURE__ */ i(ze, { ...me }),
814
- customIcon: a == null ? void 0 : a.volumeMuted
815
- }
816
- ) : u ? /* @__PURE__ */ i(
817
- x,
818
- {
819
- render: /* @__PURE__ */ i(Re, { ...me }),
820
- customIcon: a == null ? void 0 : a.volumeHalf
821
- }
822
- ) : m ? /* @__PURE__ */ i(
823
- x,
825
+ gridArea: u,
826
+ visible: n ?? !0,
827
+ ...a,
828
+ children: /* @__PURE__ */ w(
829
+ j,
824
830
  {
825
- render: /* @__PURE__ */ i(He, { ...me }),
826
- customIcon: a == null ? void 0 : a.volumeFull
831
+ type: "button",
832
+ "aria-label": jt[r],
833
+ onClick: c,
834
+ className: "rmap-repeat-btn",
835
+ "data-testid": "repeat-btn",
836
+ "data-repeattype": r,
837
+ children: [
838
+ r === "ALL" && /* @__PURE__ */ s(M, { render: /* @__PURE__ */ s(Qe, {}), customIcon: i == null ? void 0 : i.repeatAll }),
839
+ r === "ONE" && /* @__PURE__ */ s(
840
+ M,
841
+ {
842
+ render: /* @__PURE__ */ s(Je, {}),
843
+ customIcon: i == null ? void 0 : i.repeatOne
844
+ }
845
+ ),
846
+ r === "NONE" && /* @__PURE__ */ s(
847
+ M,
848
+ {
849
+ render: /* @__PURE__ */ s(Ze, {}),
850
+ customIcon: i == null ? void 0 : i.repeatNone
851
+ }
852
+ ),
853
+ r === "SHUFFLE" && /* @__PURE__ */ s(
854
+ M,
855
+ {
856
+ render: /* @__PURE__ */ s(et, {}),
857
+ customIcon: i == null ? void 0 : i.repeatShuffle
858
+ }
859
+ )
860
+ ]
827
861
  }
828
- ) : null
862
+ )
829
863
  }
830
864
  );
831
- })
832
- );
833
- je.displayName = "VolumeTriggerBtn";
834
- const le = H(null);
835
- le.displayName = "DrawerContext";
836
- const Ye = (e, t) => {
837
- E(() => {
838
- const o = (r) => {
839
- const a = e.current, { target: s } = r;
840
- !r || !a || a.contains(s) || t(r);
865
+ }
866
+ ), fe = { size: "100%" }, ct = G(() => {
867
+ var o;
868
+ const { volume: e, muted: t } = C(), { customIcons: n, elementRefs: a } = N(), r = e ?? ((o = a == null ? void 0 : a.audioEl) == null ? void 0 : o.volume) ?? 0, i = r > 0 && r <= 0.5;
869
+ return t || r === 0 ? /* @__PURE__ */ s(
870
+ M,
871
+ {
872
+ render: /* @__PURE__ */ s(at, { ...fe }),
873
+ customIcon: n == null ? void 0 : n.volumeMuted
874
+ }
875
+ ) : i ? /* @__PURE__ */ s(
876
+ M,
877
+ {
878
+ render: /* @__PURE__ */ s(rt, { ...fe }),
879
+ customIcon: n == null ? void 0 : n.volumeHalf
880
+ }
881
+ ) : /* @__PURE__ */ s(
882
+ M,
883
+ {
884
+ render: /* @__PURE__ */ s(tt, { ...fe }),
885
+ customIcon: n == null ? void 0 : n.volumeFull
886
+ }
887
+ );
888
+ });
889
+ ct.displayName = "VolumeIcon";
890
+ const ie = O(null);
891
+ ie.displayName = "DrawerContext";
892
+ const lt = (e, t) => {
893
+ P(() => {
894
+ const n = (a) => {
895
+ const r = e.current, { target: i } = a;
896
+ !a || !r || r.contains(i) || t(a);
841
897
  };
842
- return document.addEventListener("click", o), () => document.removeEventListener("click", o);
898
+ return document.addEventListener("click", n), () => document.removeEventListener("click", n);
843
899
  }, [e, t]);
844
- }, se = ({
900
+ }, ne = ({
845
901
  outboundClickActive: e = !1,
846
902
  placement: t = "bottom",
847
- children: o,
848
- isOpen: r,
849
- onOpenChange: a
903
+ children: n,
904
+ isOpen: a,
905
+ onOpenChange: r,
906
+ initialOpen: i
850
907
  }) => {
851
- const s = A(null), [n, c] = te.Children.toArray(o), [l, u] = b(!1), m = ke();
852
- Ye(s, () => {
853
- e && (u(!1), a && a(!1));
854
- }), E(() => {
855
- r !== void 0 && u(r);
856
- }, [r]);
857
- const y = D(
858
- () => ({ isOpen: l, setIsOpen: u, onOpenChange: a, drawerId: m }),
859
- [l, u, a, m]
908
+ const o = A(null), [c, u] = ee.Children.toArray(n), [d, l] = b(
909
+ a !== void 0 ? a : i ?? !1
910
+ ), p = Be();
911
+ lt(o, () => {
912
+ e && (l(!1), r && r(!1));
913
+ }), P(() => {
914
+ a !== void 0 && l(a);
915
+ }, [a]);
916
+ const m = k(
917
+ () => ({ isOpen: d, setIsOpen: l, onOpenChange: r, drawerId: p }),
918
+ [d, l, r, p]
860
919
  );
861
- return /* @__PURE__ */ i("div", { className: "rmap-drawer-container", ref: s, children: /* @__PURE__ */ i(le.Provider, { value: y, children: /* @__PURE__ */ S(z, { children: [
862
- t === "top" && c,
863
- n,
864
- t === "bottom" && c
920
+ return /* @__PURE__ */ s("div", { className: "rmap-drawer-container", ref: o, children: /* @__PURE__ */ s(ie.Provider, { value: m, children: /* @__PURE__ */ w(R, { children: [
921
+ t === "top" && u,
922
+ c,
923
+ t === "bottom" && u
865
924
  ] }) }) });
866
- }, qe = typeof window < "u", pe = qe ? it : E, Se = ({
925
+ }, ut = typeof window < "u", Te = ut ? Ct : P, ke = ({
867
926
  visible: e,
868
927
  name: t,
869
- leaveTime: o,
870
- enterTime: r,
871
- clearTime: a,
872
- onExited: s,
873
- onEntered: n,
928
+ leaveTime: n,
929
+ enterTime: a,
930
+ clearTime: r,
931
+ onExited: i,
932
+ onEntered: o,
874
933
  children: c
875
934
  }) => {
876
- const [l, u] = b(""), [m, y] = b(!1), d = A(n), p = A(s), h = A(t), v = A(r), T = A(o), L = A(a);
877
- return pe(() => {
878
- d.current = n, p.current = s, h.current = t, v.current = r, T.current = o, L.current = a;
879
- }), pe(() => {
880
- const N = e ? "enter" : "leave", B = h.current, R = e ? v.current : T.current;
881
- e && !m && y(!0), u(`${B}-${N}`);
882
- const G = setTimeout(() => {
883
- var X, oe;
884
- u(
885
- `${B}-${N} ${B}-${N}-active`
886
- ), N === "leave" ? (X = p.current) == null || X.call(p) : (oe = d.current) == null || oe.call(d);
887
- }, R), ae = setTimeout(() => {
888
- e || (u(B), y(!1));
889
- }, R + L.current);
935
+ const [u, d] = b(""), [l, p] = b(!1), m = A(o), y = A(i), f = A(t), v = A(a), T = A(n), h = A(r);
936
+ return Te(() => {
937
+ m.current = o, y.current = i, f.current = t, v.current = a, T.current = n, h.current = r;
938
+ }), Te(() => {
939
+ const I = e ? "enter" : "leave", B = f.current, re = e ? v.current : T.current;
940
+ e && !l && p(!0), d(`${B}-${I}`);
941
+ const se = setTimeout(() => {
942
+ var ce, q;
943
+ d(
944
+ `${B}-${I} ${B}-${I}-active`
945
+ ), I === "leave" ? (ce = y.current) == null || ce.call(y) : (q = m.current) == null || q.call(m);
946
+ }, re), D = setTimeout(() => {
947
+ e || (d(B), p(!1));
948
+ }, re + h.current);
890
949
  return () => {
891
- clearTimeout(G), clearTimeout(ae);
950
+ clearTimeout(se), clearTimeout(D);
892
951
  };
893
- }, [e, m]), m ? lt(c, {
894
- className: `${c.props.className} ${l}`
952
+ }, [e, l]), l ? xt(c, {
953
+ className: `${c.props.className} ${u}`
895
954
  }) : null;
896
- }, Lt = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]), [role="button"]:not([aria-disabled="true"])', Nt = ({
955
+ }, qt = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]), [role="button"]:not([aria-disabled="true"])', Xt = ({
897
956
  children: e,
898
957
  isWithAnimation: t = !0,
899
- "aria-label": o = "Dialog"
958
+ "aria-label": n = "Dialog"
900
959
  }) => {
901
- const { isOpen: r, setIsOpen: a, onOpenChange: s, drawerId: n } = f(le), c = A(null), l = A(null), u = g(
960
+ const { isOpen: a, setIsOpen: r, onOpenChange: i, drawerId: o } = E(ie), c = A(null), u = A(null), d = g(
902
961
  () => {
903
962
  var v;
904
- return (v = c.current) == null ? void 0 : v.querySelectorAll(Lt);
963
+ return (v = c.current) == null ? void 0 : v.querySelectorAll(qt);
905
964
  },
906
965
  []
907
- ), m = g(() => {
966
+ ), l = g(() => {
908
967
  var v, T;
909
- (T = (v = u()) == null ? void 0 : v[0]) == null || T.focus();
910
- }, [u]), y = g(() => {
911
- l.current = document.activeElement, m();
912
- }, [m]), d = g(() => {
968
+ (T = (v = d()) == null ? void 0 : v[0]) == null || T.focus();
969
+ }, [d]), p = g(() => {
970
+ u.current = document.activeElement, l();
971
+ }, [l]), m = g(() => {
913
972
  var v;
914
- (v = l.current) == null || v.focus();
973
+ (v = u.current) == null || v.focus();
915
974
  }, []);
916
- E(() => {
975
+ P(() => {
917
976
  var v;
918
- r && !t ? (l.current = document.activeElement, m()) : !r && !t && ((v = l.current) == null || v.focus());
919
- }, [r, t, m]);
920
- const p = g(
977
+ a && !t ? (u.current = document.activeElement, l()) : !a && !t && ((v = u.current) == null || v.focus());
978
+ }, [a, t, l]);
979
+ const y = g(
921
980
  (v) => {
922
981
  if (v.key === "Escape") {
923
- a(!1), s && s(!1);
982
+ r(!1), i && i(!1);
924
983
  return;
925
984
  }
926
985
  if (v.key === "Tab") {
927
- const T = u();
986
+ const T = d();
928
987
  if (!T || T.length === 0) return;
929
- const L = T[0], N = T[T.length - 1];
930
- v.shiftKey ? document.activeElement === L && (v.preventDefault(), N.focus()) : document.activeElement === N && (v.preventDefault(), L.focus());
988
+ const h = T[0], I = T[T.length - 1];
989
+ v.shiftKey ? document.activeElement === h && (v.preventDefault(), I.focus()) : document.activeElement === I && (v.preventDefault(), h.focus());
931
990
  }
932
991
  },
933
- [a, s, u]
934
- ), h = /* @__PURE__ */ i(
992
+ [r, i, d]
993
+ ), f = /* @__PURE__ */ s(
935
994
  "div",
936
995
  {
937
996
  ref: c,
938
997
  className: "rmap-drawer-content-container",
939
998
  role: "dialog",
940
999
  "aria-modal": "true",
941
- "aria-label": o,
942
- id: n,
943
- onKeyDown: p,
1000
+ "aria-label": n,
1001
+ id: o,
1002
+ onKeyDown: y,
944
1003
  children: e
945
1004
  }
946
1005
  );
947
- return t ? /* @__PURE__ */ i(
948
- Se,
1006
+ return t ? /* @__PURE__ */ s(
1007
+ ke,
949
1008
  {
950
- visible: r,
1009
+ visible: a,
951
1010
  name: "rmap-drawer-content",
952
1011
  enterTime: 20,
953
1012
  leaveTime: 60,
954
1013
  clearTime: 300,
955
- onEntered: y,
956
- onExited: d,
957
- children: h
1014
+ onEntered: p,
1015
+ onExited: m,
1016
+ children: f
958
1017
  }
959
- ) : r ? h : null;
960
- }, kt = ({
1018
+ ) : a ? f : null;
1019
+ }, Qt = ({
961
1020
  children: e,
962
1021
  "aria-label": t,
963
- "data-testid": o
1022
+ "data-testid": n
964
1023
  }) => {
965
- const { isOpen: r, setIsOpen: a, onOpenChange: s, drawerId: n } = f(le), c = g(() => {
966
- const l = !r;
967
- a(l), s == null || s(l);
968
- }, [r, a, s]);
969
- return /* @__PURE__ */ i(
970
- Y,
1024
+ const { isOpen: a, setIsOpen: r, onOpenChange: i, drawerId: o } = E(ie), c = g(() => {
1025
+ const u = !a;
1026
+ r(u), i == null || i(u);
1027
+ }, [a, r, i]);
1028
+ return /* @__PURE__ */ s(
1029
+ j,
971
1030
  {
972
1031
  className: "rmap-drawer-trigger",
973
1032
  type: "button",
974
- "aria-expanded": r,
975
- "aria-controls": n,
1033
+ "aria-expanded": a,
1034
+ "aria-controls": o,
976
1035
  "aria-label": t,
977
- "data-testid": o,
1036
+ "data-testid": n,
978
1037
  onClick: c,
979
1038
  children: e
980
1039
  }
981
1040
  );
982
1041
  };
983
- se.Content = Nt;
984
- se.Trigger = kt;
985
- const ye = ({ children: e }) => /* @__PURE__ */ i("ul", { className: "rmap-sortable-list-container", "aria-label": "Sortable list", children: e }), bt = ({
1042
+ ne.Content = Xt;
1043
+ ne.Trigger = Qt;
1044
+ const ge = ({ children: e }) => /* @__PURE__ */ s("ul", { className: "rmap-sortable-list-container", "aria-label": "Sortable list", children: e }), Jt = ({
986
1045
  index: e,
987
1046
  dragStartIdx: t,
988
- listData: o,
989
- draggable: r = !0,
990
- onDragStart: a,
991
- onDragOver: s,
992
- onDrop: n,
993
- onClick: c
994
- }) => ({
995
- draggable: r,
996
- onDragStart: (l) => {
997
- l.stopPropagation(), l.currentTarget.classList.add("rmap-drag-start"), a == null || a(l);
998
- },
999
- onDragEnd: (l) => {
1000
- l.stopPropagation(), l.currentTarget.classList.remove("rmap-drag-start");
1001
- },
1002
- onDragEnter: (l) => {
1003
- l.stopPropagation(), l.currentTarget.classList.add("rmap-drag-over");
1004
- },
1005
- onDragLeave: (l) => {
1006
- l.stopPropagation(), l.currentTarget.classList.remove("rmap-drag-over");
1007
- },
1008
- onDragOver: (l) => {
1009
- l.preventDefault(), l.stopPropagation(), s == null || s(l);
1010
- },
1011
- onDrop: (l) => {
1012
- l.stopPropagation(), l.currentTarget.classList.remove("rmap-drag-over");
1013
- const u = [...o], m = o[t];
1014
- u.splice(t, 1);
1015
- const y = (t < e ? [
1016
- ...u.slice(0, e),
1017
- m,
1018
- ...u.slice(e, u.length)
1019
- ] : [
1020
- ...u.slice(0, e),
1021
- m,
1022
- ...u.slice(e, u.length)
1023
- ]).map((d, p) => ({ ...d, index: p }));
1024
- n == null || n(l, y);
1025
- },
1026
- onClick: (l) => {
1027
- l.stopPropagation(), c == null || c(l);
1028
- }
1029
- }), Ct = (e) => {
1030
- const { children: t, ...o } = e, r = bt(o);
1031
- return /* @__PURE__ */ i("li", { className: "rmap-sortable-item", ...r, children: /* @__PURE__ */ i("div", { className: "rmap-sortable-item-inner", children: t }) });
1047
+ listData: n,
1048
+ draggable: a = !0,
1049
+ onDragStart: r,
1050
+ onDragOver: i,
1051
+ onDrop: o,
1052
+ onReorder: c,
1053
+ onClick: u
1054
+ }) => {
1055
+ const d = (l, p) => {
1056
+ if (l < 0 || l >= n.length) return;
1057
+ const m = [...n], y = m.splice(e, 1)[0];
1058
+ m.splice(l, 0, y);
1059
+ const f = m.map((T, h) => ({
1060
+ ...T,
1061
+ index: h
1062
+ })), v = (p == null ? void 0 : p.parentElement) ?? null;
1063
+ if ($e(() => {
1064
+ c == null || c(f);
1065
+ }), v) {
1066
+ const T = v.children[l];
1067
+ T == null || T.focus();
1068
+ }
1069
+ };
1070
+ return {
1071
+ tabIndex: 0,
1072
+ draggable: a,
1073
+ onKeyDown: (l) => {
1074
+ switch (l.key) {
1075
+ case "Enter":
1076
+ case " ":
1077
+ l.preventDefault(), l.currentTarget.click();
1078
+ break;
1079
+ case "ArrowUp":
1080
+ if (l.preventDefault(), a && l.altKey)
1081
+ d(e - 1, l.currentTarget);
1082
+ else {
1083
+ const p = l.currentTarget.previousElementSibling;
1084
+ p == null || p.focus();
1085
+ }
1086
+ break;
1087
+ case "ArrowDown":
1088
+ if (l.preventDefault(), a && l.altKey)
1089
+ d(e + 1, l.currentTarget);
1090
+ else {
1091
+ const p = l.currentTarget.nextElementSibling;
1092
+ p == null || p.focus();
1093
+ }
1094
+ break;
1095
+ }
1096
+ },
1097
+ onDragStart: (l) => {
1098
+ l.stopPropagation(), l.currentTarget.classList.add("rmap-drag-start"), r == null || r(l);
1099
+ },
1100
+ onDragEnd: (l) => {
1101
+ l.stopPropagation(), l.currentTarget.classList.remove("rmap-drag-start");
1102
+ },
1103
+ onDragEnter: (l) => {
1104
+ l.stopPropagation(), l.currentTarget.classList.add("rmap-drag-over");
1105
+ },
1106
+ onDragLeave: (l) => {
1107
+ l.stopPropagation(), l.currentTarget.classList.remove("rmap-drag-over");
1108
+ },
1109
+ onDragOver: (l) => {
1110
+ l.preventDefault(), l.stopPropagation(), i == null || i(l);
1111
+ },
1112
+ onDrop: (l) => {
1113
+ l.stopPropagation(), l.currentTarget.classList.remove("rmap-drag-over");
1114
+ const p = [...n], m = n[t];
1115
+ p.splice(t, 1);
1116
+ const y = [
1117
+ ...p.slice(0, e),
1118
+ m,
1119
+ ...p.slice(e, p.length)
1120
+ ].map((f, v) => ({ ...f, index: v }));
1121
+ o == null || o(l, y);
1122
+ },
1123
+ onClick: (l) => {
1124
+ l.stopPropagation(), u == null || u(l);
1125
+ }
1126
+ };
1127
+ }, Zt = (e) => {
1128
+ const { children: t, ...n } = e, a = Jt(n);
1129
+ return /* @__PURE__ */ s("li", { className: "rmap-sortable-item", ...a, children: /* @__PURE__ */ s("div", { className: "rmap-sortable-item-inner", children: t }) });
1032
1130
  };
1033
- ye.Item = Ct;
1034
- const Mt = W(function({
1131
+ ge.Item = Zt;
1132
+ const Ce = O(null);
1133
+ Ce.displayName = "PlayListPortalContext";
1134
+ const xe = O(null);
1135
+ xe.displayName = "PlayListEmptyContext";
1136
+ const er = G(function({
1035
1137
  data: t
1036
1138
  }) {
1037
- const { curPlayId: o } = V(), { coverImgsCss: r } = P(), a = o === t.id;
1038
- return /* @__PURE__ */ i(
1139
+ const { curPlayId: n } = K(), { coverImgsCss: a } = N(), r = n === t.id;
1140
+ return /* @__PURE__ */ s(
1039
1141
  "div",
1040
1142
  {
1041
- className: `rmap-playlist-item${a ? " rmap-cur-played" : ""}`,
1143
+ className: `rmap-playlist-item${r ? " rmap-cur-played" : ""}`,
1042
1144
  "data-testid": "playlist-item",
1043
- "aria-current": a ? "true" : void 0,
1044
- children: /* @__PURE__ */ S("div", { className: "rmap-playlist-item-contents", children: [
1045
- /* @__PURE__ */ i("div", { className: "rmap-playlist-album-cover", children: t.img && /* @__PURE__ */ i(
1145
+ "aria-current": r ? "true" : void 0,
1146
+ children: /* @__PURE__ */ w("div", { className: "rmap-playlist-item-contents", children: [
1147
+ /* @__PURE__ */ s("div", { className: "rmap-playlist-album-cover", children: t.img && /* @__PURE__ */ s(
1046
1148
  "img",
1047
1149
  {
1048
1150
  src: t.img,
1049
1151
  alt: t.name || "Album thumbnail",
1050
- style: r == null ? void 0 : r.listThumbnail
1152
+ style: a == null ? void 0 : a.listThumbnail
1051
1153
  }
1052
1154
  ) }),
1053
- /* @__PURE__ */ S("div", { className: "rmap-playlist-album-info", children: [
1054
- t.writer && /* @__PURE__ */ i("span", { className: "rmap-playlist-writer", children: t.writer }),
1055
- t.name && /* @__PURE__ */ i("span", { className: "rmap-playlist-title", children: t.name }),
1056
- t.description && /* @__PURE__ */ i("div", { className: "rmap-playlist-description", children: t.description })
1155
+ /* @__PURE__ */ w("div", { className: "rmap-playlist-album-info", children: [
1156
+ t.writer && /* @__PURE__ */ s("span", { className: "rmap-playlist-writer", children: t.writer }),
1157
+ t.name && /* @__PURE__ */ s("span", { className: "rmap-playlist-title", children: t.name }),
1158
+ t.description && /* @__PURE__ */ s("div", { className: "rmap-playlist-description", children: t.description })
1057
1159
  ] })
1058
1160
  ] })
1059
1161
  }
1060
1162
  );
1061
- }), xt = ({
1163
+ }), tr = ({
1062
1164
  setIsOpen: e
1063
1165
  }) => {
1064
- const { playList: t } = V(), { activeUI: o } = O(), r = f(w), [a, s] = b(0), n = g(
1166
+ const { playList: t } = K(), { activeUI: n } = x(), a = E(L), [r, i] = b(0), o = g(
1065
1167
  (c) => {
1066
- r({
1168
+ a({
1067
1169
  type: "SET_CURRENT_AUDIO",
1068
1170
  currentIndex: c,
1069
1171
  currentAudioId: t[c].id
1070
1172
  });
1071
1173
  },
1072
- [r, t]
1174
+ [a, t]
1073
1175
  );
1074
1176
  return {
1075
1177
  cssTransitionEventProps: {
@@ -1077,134 +1179,155 @@ const Mt = W(function({
1077
1179
  onEntered: () => e(!0)
1078
1180
  },
1079
1181
  sortableItemEventProps: {
1080
- draggable: o.playList !== "unSortable",
1081
- dragStartIdx: a,
1082
- onDragStart: (c) => s(c),
1083
- onDrop: (c, l) => r({
1182
+ draggable: n.playList !== "unSortable",
1183
+ dragStartIdx: r,
1184
+ onDragStart: (c) => i(c),
1185
+ onDrop: (c, u) => a({
1084
1186
  type: "UPDATE_PLAY_LIST",
1085
- playList: l
1187
+ playList: u
1086
1188
  }),
1087
- onClick: (c) => n(c)
1189
+ onReorder: (c) => a({
1190
+ type: "UPDATE_PLAY_LIST",
1191
+ playList: c
1192
+ }),
1193
+ onClick: (c) => o(c)
1088
1194
  }
1089
1195
  };
1090
- }, _t = () => {
1091
- const { playList: e } = V(), { isOpen: t, setIsOpen: o } = f(le), { cssTransitionEventProps: r, sortableItemEventProps: a } = xt({
1092
- setIsOpen: o
1196
+ }, rr = () => {
1197
+ const { playList: e } = K(), { isOpen: t, setIsOpen: n } = E(ie), a = he(Ce), r = he(xe), { cssTransitionEventProps: i, sortableItemEventProps: o } = tr({
1198
+ setIsOpen: n
1093
1199
  }), {
1094
- onClick: s,
1095
- onDragStart: n,
1096
- ...c
1097
- } = a;
1098
- return e.length !== 0 ? ct.createPortal(
1099
- /* @__PURE__ */ i(
1100
- Se,
1200
+ onClick: c,
1201
+ onDragStart: u,
1202
+ ...d
1203
+ } = o;
1204
+ if (!a) return /* @__PURE__ */ s(R, {});
1205
+ const l = e.length === 0;
1206
+ return l && !r ? /* @__PURE__ */ s(R, {}) : _t.createPortal(
1207
+ /* @__PURE__ */ s(
1208
+ ke,
1101
1209
  {
1102
1210
  visible: t,
1103
1211
  name: "rmap-playlist-content",
1104
1212
  enterTime: 20,
1105
1213
  leaveTime: 20,
1106
1214
  clearTime: 300,
1107
- ...r,
1108
- children: /* @__PURE__ */ i("div", { className: "rmap-playlist-container", children: /* @__PURE__ */ i(ye, { children: e.map((l, u) => /* @__PURE__ */ i(
1109
- ye.Item,
1215
+ ...i,
1216
+ children: /* @__PURE__ */ s("div", { className: "rmap-playlist-container", children: l ? r : /* @__PURE__ */ s(ge, { children: e.map((p, m) => /* @__PURE__ */ s(
1217
+ ge.Item,
1110
1218
  {
1111
- index: u,
1219
+ index: m,
1112
1220
  listData: e,
1113
- onClick: () => s(u),
1114
- onDragStart: () => n(u),
1115
- ...c,
1116
- children: /* @__PURE__ */ i(Mt, { data: l })
1221
+ onClick: () => c(m),
1222
+ onDragStart: () => u(m),
1223
+ ...d,
1224
+ children: /* @__PURE__ */ s(er, { data: p })
1117
1225
  },
1118
- `sortable-item-${u}`
1226
+ p.id
1119
1227
  )) }) })
1120
1228
  }
1121
1229
  ),
1122
- document.querySelector(".rmap-sortable-playlist") ?? document.body
1123
- ) : /* @__PURE__ */ i(z, {});
1124
- }, Dt = () => {
1125
- const { customIcons: e } = P();
1126
- return /* @__PURE__ */ i(
1127
- x,
1230
+ a
1231
+ );
1232
+ }, ar = () => {
1233
+ const { customIcons: e } = N();
1234
+ return /* @__PURE__ */ s(
1235
+ M,
1128
1236
  {
1129
- render: /* @__PURE__ */ i(Ve, { size: "100%" }),
1237
+ render: /* @__PURE__ */ s(Xe, { size: "100%" }),
1130
1238
  customIcon: e == null ? void 0 : e.playList
1131
1239
  }
1132
1240
  );
1133
- }, Ot = () => /* @__PURE__ */ S(se, { children: [
1134
- /* @__PURE__ */ i(se.Trigger, { "aria-label": "Playlist", "data-testid": "playlist-trigger-btn", children: /* @__PURE__ */ i(Dt, {}) }),
1135
- /* @__PURE__ */ i(se.Content, { "aria-label": "Playlist", children: /* @__PURE__ */ i(_t, {}) })
1136
- ] }), ee = (e) => {
1137
- const t = `${Math.floor(e / 60)}`.padStart(2, "0"), o = `${Math.floor(e % 60)}`.padStart(2, "0");
1138
- return `${t}:${o}`;
1139
- }, ce = (e, t, o = 0) => {
1140
- if (!t) return o;
1141
- const r = e / t;
1142
- return isFinite(r) ? r : o;
1143
- }, Xe = () => {
1144
- const { isLoadedMetaData: e } = C(), { elementRefs: t } = P(), [o, r] = b(!1), a = g(
1145
- (s) => {
1241
+ }, dt = ({
1242
+ initialExpanded: e,
1243
+ gridArea: t,
1244
+ visible: n,
1245
+ ...a
1246
+ }) => {
1247
+ const { playListExpanded: r } = x(), i = e ?? r, o = z("playList", t);
1248
+ return /* @__PURE__ */ s(_.Item, { gridArea: o, visible: n ?? !0, ...a, children: /* @__PURE__ */ w(ne, { initialOpen: i, children: [
1249
+ /* @__PURE__ */ s(
1250
+ ne.Trigger,
1251
+ {
1252
+ "aria-label": "Playlist",
1253
+ "data-testid": "playlist-trigger-btn",
1254
+ children: /* @__PURE__ */ s(ar, {})
1255
+ }
1256
+ ),
1257
+ /* @__PURE__ */ s(ne.Content, { "aria-label": "Playlist", children: /* @__PURE__ */ s(rr, {}) })
1258
+ ] }) });
1259
+ }, Z = (e) => {
1260
+ const t = `${Math.floor(e / 60)}`.padStart(2, "0"), n = `${Math.floor(e % 60)}`.padStart(2, "0");
1261
+ return `${t}:${n}`;
1262
+ }, me = (e, t, n = 0) => {
1263
+ if (!t) return n;
1264
+ const a = e / t;
1265
+ return isFinite(a) ? a : n;
1266
+ }, mt = () => {
1267
+ const { isLoadedMetaData: e } = C(), { elementRefs: t } = N(), [n, a] = b(!1), r = g(
1268
+ (i) => {
1146
1269
  if (!(t != null && t.audioEl) || !e) return;
1147
- const { clientX: n } = s, { clientWidth: c } = s.currentTarget, l = s.currentTarget.getBoundingClientRect(), u = n - l.x, m = ce(u, c) * t.audioEl.duration;
1148
- t.audioEl.currentTime = m;
1270
+ const { clientX: o } = i, { clientWidth: c } = i.currentTarget, u = i.currentTarget.getBoundingClientRect(), d = o - u.x, l = me(d, c) * t.audioEl.duration;
1271
+ t.audioEl.currentTime = l;
1149
1272
  },
1150
1273
  [e, t == null ? void 0 : t.audioEl]
1151
1274
  );
1152
- return E(() => {
1153
- if (!o) return;
1154
- const s = (n) => n.preventDefault();
1155
- return document.addEventListener("selectstart", s), () => {
1156
- document.removeEventListener("selectstart", s);
1275
+ return P(() => {
1276
+ if (!n) return;
1277
+ const i = (o) => o.preventDefault();
1278
+ return document.addEventListener("selectstart", i), () => {
1279
+ document.removeEventListener("selectstart", i);
1157
1280
  };
1158
- }, [o]), {
1159
- onMouseDown: () => r(!0),
1160
- onMouseUp: () => r(!1),
1161
- onMouseLeave: () => r(!1),
1162
- onMouseMove: o ? a : void 0,
1163
- onClick: a
1281
+ }, [n]), {
1282
+ onMouseDown: () => a(!0),
1283
+ onMouseUp: () => a(!1),
1284
+ onMouseLeave: () => a(!1),
1285
+ onMouseMove: n ? r : void 0,
1286
+ onClick: r
1164
1287
  };
1165
- }, Qe = (e) => {
1166
- const { isLoadedMetaData: t } = C(), { elementRefs: o } = P();
1288
+ }, pt = (e) => {
1289
+ const { isLoadedMetaData: t } = C(), { elementRefs: n } = N();
1167
1290
  return g(
1168
- (r) => {
1169
- if (!(o != null && o.audioEl) || !t) return;
1170
- const a = o.audioEl;
1171
- let s = null;
1172
- switch (r.key) {
1291
+ (a) => {
1292
+ if (!(n != null && n.audioEl) || !t) return;
1293
+ const r = n.audioEl;
1294
+ let i = null;
1295
+ switch (a.key) {
1173
1296
  case "ArrowRight":
1174
1297
  case "ArrowUp":
1175
- r.preventDefault(), s = Math.min(a.currentTime + 5, a.duration);
1298
+ a.preventDefault(), i = Math.min(r.currentTime + 5, r.duration);
1176
1299
  break;
1177
1300
  case "ArrowLeft":
1178
1301
  case "ArrowDown":
1179
- r.preventDefault(), s = Math.max(a.currentTime - 5, 0);
1302
+ a.preventDefault(), i = Math.max(r.currentTime - 5, 0);
1180
1303
  break;
1181
1304
  case "Home":
1182
- r.preventDefault(), s = 0;
1305
+ a.preventDefault(), i = 0;
1183
1306
  break;
1184
1307
  case "End":
1185
- r.preventDefault(), s = a.duration;
1308
+ a.preventDefault(), i = r.duration;
1186
1309
  break;
1187
1310
  }
1188
- s !== null && isFinite(a.duration) && (a.currentTime = s, e == null || e(s, a.duration));
1311
+ i !== null && isFinite(r.duration) && (r.currentTime = i, e == null || e(i, r.duration));
1189
1312
  },
1190
- [o == null ? void 0 : o.audioEl, t, e]
1313
+ [n == null ? void 0 : n.audioEl, t, e]
1191
1314
  );
1192
- }, Ut = () => {
1193
- const { currentTime: e, duration: t } = re(), o = A(null), [r, a] = b(0);
1194
- E(() => {
1195
- const u = o.current;
1196
- if (!u) return;
1197
- a(u.offsetWidth);
1198
- const m = new ResizeObserver(([y]) => {
1199
- a(y.contentBoxSize[0].inlineSize);
1315
+ }, nr = () => {
1316
+ const { currentTime: e, duration: t } = te(), n = A(null), [a, r] = b(0);
1317
+ P(() => {
1318
+ const d = n.current;
1319
+ if (!d) return;
1320
+ r(d.offsetWidth);
1321
+ const l = new ResizeObserver(([p]) => {
1322
+ r(p.contentBoxSize[0].inlineSize);
1200
1323
  });
1201
- return m.observe(u), () => m.disconnect();
1324
+ return l.observe(d), () => l.disconnect();
1202
1325
  }, []);
1203
- const s = ce(e, t), n = Xe(), c = Qe(), l = s * r;
1204
- return /* @__PURE__ */ S(
1326
+ const i = me(e, t), o = mt(), c = pt(), u = i * a;
1327
+ return /* @__PURE__ */ w(
1205
1328
  "div",
1206
1329
  {
1207
- ref: o,
1330
+ ref: n,
1208
1331
  className: "rmap-bar-progress-wrapper",
1209
1332
  "data-testid": "progress-bar",
1210
1333
  role: "slider",
@@ -1212,70 +1335,70 @@ const Mt = W(function({
1212
1335
  "aria-label": "Seek",
1213
1336
  "aria-valuemin": 0,
1214
1337
  "aria-valuemax": 100,
1215
- "aria-valuenow": Math.round(s * 100),
1216
- "aria-valuetext": `${ee(
1338
+ "aria-valuenow": Math.round(i * 100),
1339
+ "aria-valuetext": `${Z(
1217
1340
  e
1218
- )} of ${ee(t)}`,
1341
+ )} of ${Z(t)}`,
1219
1342
  onKeyDown: c,
1220
- ...n,
1343
+ ...o,
1221
1344
  children: [
1222
- /* @__PURE__ */ i("div", { className: "rmap-progress-bar", children: /* @__PURE__ */ i(
1345
+ /* @__PURE__ */ s("div", { className: "rmap-progress-bar", children: /* @__PURE__ */ s(
1223
1346
  "div",
1224
1347
  {
1225
1348
  className: "rmap-progress-fill",
1226
- style: { transform: `scaleX(${s})` }
1349
+ style: { transform: `scaleX(${i})` }
1227
1350
  }
1228
1351
  ) }),
1229
- /* @__PURE__ */ i(
1352
+ /* @__PURE__ */ s(
1230
1353
  "div",
1231
1354
  {
1232
1355
  className: "rmap-progress-handle",
1233
1356
  style: {
1234
- transform: `translateX(${l}px)`
1357
+ transform: `translateX(${u}px)`
1235
1358
  }
1236
1359
  }
1237
1360
  )
1238
1361
  ]
1239
1362
  }
1240
1363
  );
1241
- }, Vt = (e, t) => {
1242
- const o = A(), r = g(() => {
1243
- const a = document.getElementsByClassName("rmap-player-provider")[0];
1244
- if (!a) return;
1245
- const s = Object.entries(
1364
+ }, or = (e, t) => {
1365
+ const n = A(), a = g(() => {
1366
+ const r = document.getElementsByClassName("rmap-player-provider")[0];
1367
+ if (!r) return;
1368
+ const i = Object.entries(
1246
1369
  e
1247
1370
  ).reduce(
1248
- (n, [c, l]) => ({
1249
- ...n,
1250
- [c]: window.getComputedStyle(a).getPropertyValue(`${l}`)
1371
+ (o, [c, u]) => ({
1372
+ ...o,
1373
+ [c]: window.getComputedStyle(r).getPropertyValue(`${u}`)
1251
1374
  }),
1252
1375
  {}
1253
1376
  );
1254
- o.current = s;
1377
+ n.current = i;
1255
1378
  }, [e]);
1256
- return pe(() => {
1257
- r();
1258
- const a = window.matchMedia("(prefers-color-scheme: dark)");
1259
- return a.addEventListener("change", r), () => a.removeEventListener("change", r);
1260
- }, [r, t]), o;
1261
- }, Bt = {
1379
+ return Te(() => {
1380
+ a();
1381
+ const r = window.matchMedia("(prefers-color-scheme: dark)");
1382
+ return r.addEventListener("change", a), () => r.removeEventListener("change", a);
1383
+ }, [a, t]), n;
1384
+ }, ir = {
1262
1385
  progressColor: "--rm-audio-player-waveform-bar",
1263
1386
  waveColor: "--rm-audio-player-waveform-background"
1264
- }, Kt = (e) => {
1387
+ }, sr = (e) => {
1265
1388
  const t = e.backend;
1266
1389
  if (!(!(t != null && t.media) || !t.mediaListeners))
1267
- for (const [o, r] of Object.entries(t.mediaListeners))
1268
- t.media.removeEventListener(o, r);
1269
- }, $t = (e) => {
1270
- const t = f(w), { isPlaying: o } = C(), { curPlayId: r } = V(), { elementRefs: a } = P(), { colorScheme: s } = O(), n = Vt(Bt, s), c = A(a == null ? void 0 : a.waveformInst);
1271
- c.current = a == null ? void 0 : a.waveformInst, E(() => {
1272
- var p, h;
1273
- if (a != null && a.waveformInst || !((p = n.current) != null && p.progressColor) || !((h = n.current) != null && h.waveColor))
1390
+ for (const [n, a] of Object.entries(t.mediaListeners))
1391
+ t.media.removeEventListener(n, a);
1392
+ }, cr = (e) => {
1393
+ const t = E(L), { isPlaying: n } = C(), { curPlayId: a } = K(), { elementRefs: r } = N(), { colorScheme: i } = x(), o = or(ir, i), c = A(r == null ? void 0 : r.waveformInst);
1394
+ c.current = r == null ? void 0 : r.waveformInst, P(() => {
1395
+ var y, f;
1396
+ if (r != null && r.waveformInst || !((y = o.current) != null && y.progressColor) || !((f = o.current) != null && f.waveColor))
1274
1397
  return;
1275
- let d = !1;
1398
+ let m = !1;
1276
1399
  return import("./wavesurfer-_j5aw4gZ.mjs").then((v) => v.w).then(({ default: v }) => {
1277
- var L, N;
1278
- if (d || !e.current || !((L = n.current) != null && L.progressColor) || !((N = n.current) != null && N.waveColor)) {
1400
+ var h, I;
1401
+ if (m || !e.current || !((h = o.current) != null && h.progressColor) || !((I = o.current) != null && I.waveColor)) {
1279
1402
  console.error("[useWaveSurfer] missing required dependencies");
1280
1403
  return;
1281
1404
  }
@@ -1286,9 +1409,9 @@ const Mt = W(function({
1286
1409
  cursorWidth: 2,
1287
1410
  container: e.current,
1288
1411
  height: 80,
1289
- progressColor: n.current.progressColor,
1412
+ progressColor: o.current.progressColor,
1290
1413
  responsive: !0,
1291
- waveColor: n.current.waveColor,
1414
+ waveColor: o.current.waveColor,
1292
1415
  cursorColor: "var(--rm-audio-player-waveform-cursor)",
1293
1416
  backend: "MediaElement",
1294
1417
  removeMediaElementOnDestroy: !1
@@ -1307,36 +1430,38 @@ const Mt = W(function({
1307
1430
  }).catch((v) => {
1308
1431
  console.error("[useWaveSurfer] failed to load wavesurfer.js", v);
1309
1432
  }), () => {
1310
- d = !0;
1433
+ m = !0;
1311
1434
  };
1312
- }, [a == null ? void 0 : a.waveformInst, t, n]);
1313
- const l = A(r);
1314
- E(() => {
1315
- if (!(a != null && a.audioEl) || !(a != null && a.waveformInst)) return;
1316
- const d = a.audioEl, p = a.waveformInst, h = l.current !== r;
1317
- l.current = r;
1318
- const v = h ? 0 : d.currentTime, T = o;
1319
- Kt(p), p.load(d);
1320
- const L = () => {
1321
- !h && v > 0 && d.duration && (d.currentTime = v, p.seekTo(v / d.duration)), T && d.play();
1435
+ }, [r == null ? void 0 : r.waveformInst, t, o]);
1436
+ const u = A(a);
1437
+ P(() => {
1438
+ if (!(r != null && r.audioEl) || !(r != null && r.waveformInst)) return;
1439
+ const m = r.audioEl;
1440
+ if (!m.getAttribute("src")) return;
1441
+ const y = r.waveformInst, f = u.current !== a;
1442
+ u.current = a;
1443
+ const v = f ? 0 : m.currentTime, T = n;
1444
+ sr(y), y.load(m);
1445
+ const h = () => {
1446
+ !f && v > 0 && m.duration && (m.currentTime = v, y.seekTo(v / m.duration)), T && m.play();
1322
1447
  };
1323
- return p.on("ready", L), () => {
1324
- p.un("ready", L);
1448
+ return y.on("ready", h), () => {
1449
+ y.un("ready", h);
1325
1450
  };
1326
- }, [r, a == null ? void 0 : a.audioEl, a == null ? void 0 : a.waveformInst]), E(() => {
1327
- if (!e.current || !(a != null && a.waveformInst)) return;
1328
- const d = () => {
1329
- var h, v;
1330
- (v = (h = a.waveformInst) == null ? void 0 : h.drawer) == null || v.fireEvent("redraw");
1331
- }, p = new ResizeObserver(d);
1332
- return p.observe(e.current), () => {
1333
- p.disconnect();
1451
+ }, [a, r == null ? void 0 : r.audioEl, r == null ? void 0 : r.waveformInst]), P(() => {
1452
+ if (!e.current || !(r != null && r.waveformInst)) return;
1453
+ const m = () => {
1454
+ var f, v;
1455
+ (v = (f = r.waveformInst) == null ? void 0 : f.drawer) == null || v.fireEvent("redraw");
1456
+ }, y = new ResizeObserver(m);
1457
+ return y.observe(e.current), () => {
1458
+ y.disconnect();
1334
1459
  };
1335
- }, [a == null ? void 0 : a.waveformInst, e]), E(
1460
+ }, [r == null ? void 0 : r.waveformInst, e]), P(
1336
1461
  () => () => {
1337
- var p, h;
1338
- const d = (p = e.current) == null ? void 0 : p.querySelector("wave");
1339
- d && d.remove(), (h = c.current) == null || h.destroy(), t({
1462
+ var y, f;
1463
+ const m = (y = e.current) == null ? void 0 : y.querySelector("wave");
1464
+ m && m.remove(), (f = c.current) == null || f.destroy(), t({
1340
1465
  type: "SET_ELEMENT_REFS",
1341
1466
  elementRefs: { waveformInst: void 0 }
1342
1467
  });
@@ -1344,47 +1469,47 @@ const Mt = W(function({
1344
1469
  // eslint-disable-next-line react-hooks/exhaustive-deps
1345
1470
  [t]
1346
1471
  );
1347
- const u = () => {
1472
+ const d = () => {
1348
1473
  var v, T;
1349
- const d = c.current;
1350
- if (!(d != null && d.isReady)) return;
1351
- const p = (v = n.current) == null ? void 0 : v.waveColor, h = (T = n.current) == null ? void 0 : T.progressColor;
1352
- p && d.setWaveColor(p), h && d.setProgressColor(h);
1353
- }, m = A(u);
1354
- m.current = u;
1355
- const y = A(s);
1356
- E(() => {
1357
- y.current !== s && (y.current = s, m.current());
1358
- }, [s, a == null ? void 0 : a.waveformInst]), E(() => {
1359
- const d = () => m.current(), p = window.matchMedia("(prefers-color-scheme: dark)");
1360
- return p.addEventListener("change", d), () => p.removeEventListener("change", d);
1474
+ const m = c.current;
1475
+ if (!(m != null && m.isReady)) return;
1476
+ const y = (v = o.current) == null ? void 0 : v.waveColor, f = (T = o.current) == null ? void 0 : T.progressColor;
1477
+ y && m.setWaveColor(y), f && m.setProgressColor(f);
1478
+ }, l = A(d);
1479
+ l.current = d;
1480
+ const p = A(i);
1481
+ P(() => {
1482
+ p.current !== i && (p.current = i, l.current());
1483
+ }, [i, r == null ? void 0 : r.waveformInst]), P(() => {
1484
+ const m = () => l.current(), y = window.matchMedia("(prefers-color-scheme: dark)");
1485
+ return y.addEventListener("change", m), () => y.removeEventListener("change", m);
1361
1486
  }, []);
1362
- }, Ft = ({ isActive: e }) => {
1363
- var l, u, m, y;
1364
- const t = A(null), { isLoadedMetaData: o, isPlaying: r } = C(), { elementRefs: a } = P();
1365
- $t(t), E(() => {
1366
- if (!e || !(a != null && a.waveformInst) || !(a != null && a.audioEl) || !o || r)
1487
+ }, lr = ({ isActive: e }) => {
1488
+ var u, d, l, p;
1489
+ const t = A(null), { isLoadedMetaData: n, isPlaying: a } = C(), { elementRefs: r } = N();
1490
+ cr(t), P(() => {
1491
+ if (!e || !(r != null && r.waveformInst) || !(r != null && r.audioEl) || !n || a)
1367
1492
  return;
1368
- const d = ce(
1369
- a.audioEl.currentTime,
1370
- a.audioEl.duration
1493
+ const m = me(
1494
+ r.audioEl.currentTime,
1495
+ r.audioEl.duration
1371
1496
  );
1372
- a.waveformInst.seekTo(d);
1497
+ r.waveformInst.seekTo(m);
1373
1498
  }, [
1374
1499
  e,
1375
- o,
1376
- a == null ? void 0 : a.waveformInst,
1377
- a == null ? void 0 : a.audioEl,
1378
- r
1500
+ n,
1501
+ r == null ? void 0 : r.waveformInst,
1502
+ r == null ? void 0 : r.audioEl,
1503
+ a
1379
1504
  ]);
1380
- const s = Xe(), n = g(
1381
- (d, p) => {
1382
- var h;
1383
- p && ((h = a == null ? void 0 : a.waveformInst) == null || h.seekTo(ce(d, p)));
1505
+ const i = mt(), o = g(
1506
+ (m, y) => {
1507
+ var f;
1508
+ y && ((f = r == null ? void 0 : r.waveformInst) == null || f.seekTo(me(m, y)));
1384
1509
  },
1385
- [a == null ? void 0 : a.waveformInst]
1386
- ), c = Qe(n);
1387
- return /* @__PURE__ */ i("div", { className: "rmap-waveform-wrapper", "data-active": e, children: /* @__PURE__ */ i(
1510
+ [r == null ? void 0 : r.waveformInst]
1511
+ ), c = pt(o);
1512
+ return /* @__PURE__ */ s("div", { className: "rmap-waveform-wrapper", "data-active": e, children: /* @__PURE__ */ s(
1388
1513
  "div",
1389
1514
  {
1390
1515
  id: "rm-waveform",
@@ -1395,96 +1520,113 @@ const Mt = W(function({
1395
1520
  "aria-valuemin": 0,
1396
1521
  "aria-valuemax": 100,
1397
1522
  "aria-valuenow": Math.round(
1398
- (((l = a == null ? void 0 : a.audioEl) == null ? void 0 : l.currentTime) ?? 0) / (((u = a == null ? void 0 : a.audioEl) == null ? void 0 : u.duration) || 1) * 100
1523
+ (((u = r == null ? void 0 : r.audioEl) == null ? void 0 : u.currentTime) ?? 0) / (((d = r == null ? void 0 : r.audioEl) == null ? void 0 : d.duration) || 1) * 100
1399
1524
  ),
1400
- "aria-valuetext": `${ee(
1401
- ((m = a == null ? void 0 : a.audioEl) == null ? void 0 : m.currentTime) ?? 0
1402
- )} of ${ee(((y = a == null ? void 0 : a.audioEl) == null ? void 0 : y.duration) ?? 0)}`,
1525
+ "aria-valuetext": `${Z(
1526
+ ((l = r == null ? void 0 : r.audioEl) == null ? void 0 : l.currentTime) ?? 0
1527
+ )} of ${Z(((p = r == null ? void 0 : r.audioEl) == null ? void 0 : p.duration) ?? 0)}`,
1403
1528
  onKeyDown: c,
1404
- ...s
1529
+ ...i
1405
1530
  }
1406
1531
  ) });
1407
- }, Ht = () => {
1408
- const { activeUI: e } = O(), t = e.progress ?? (e.all ? "bar" : !1), o = t === "waveform", r = t === "bar", [a, s] = b(o);
1409
- return E(() => {
1410
- o && !a && s(!0);
1411
- }, [o, a]), /* @__PURE__ */ S("div", { className: "rmap-progress-container", children: [
1412
- a && /* @__PURE__ */ i(Ft, { isActive: o }),
1413
- r && /* @__PURE__ */ i(Ut, {})
1414
- ] });
1415
- }, Rt = ({
1532
+ }, yt = ({
1533
+ gridArea: e,
1534
+ visible: t,
1535
+ type: n,
1536
+ width: a,
1537
+ ...r
1538
+ }) => {
1539
+ const { activeUI: i } = x(), o = n ?? (i.progress === "waveform" ? "waveform" : "bar"), c = o === "waveform", u = o === "bar", [d, l] = b(c);
1540
+ P(() => {
1541
+ c && !d && l(!0);
1542
+ }, [c, d]);
1543
+ const p = z("progress", e);
1544
+ return /* @__PURE__ */ s(
1545
+ _.Item,
1546
+ {
1547
+ gridArea: p,
1548
+ width: a ?? "100%",
1549
+ visible: t ?? !0,
1550
+ ...r,
1551
+ children: /* @__PURE__ */ w("div", { className: "rmap-progress-container", children: [
1552
+ d && /* @__PURE__ */ s(lr, { isActive: c }),
1553
+ u && /* @__PURE__ */ s(nr, {})
1554
+ ] })
1555
+ }
1556
+ );
1557
+ }, ur = ({
1416
1558
  placement: e
1417
1559
  }) => {
1418
- var y;
1419
- const t = A(null), { volume: o, muted: r } = C(), { elementRefs: a } = P(), s = f(w), n = g(
1420
- (d) => {
1421
- d.stopPropagation(), d.preventDefault(), r && s({ type: "SET_MUTED", muted: !1 });
1422
- const { value: p } = d.target, h = parseFloat(p);
1423
- s({
1560
+ var p;
1561
+ const t = A(null), { volume: n, muted: a } = C(), { elementRefs: r } = N(), i = E(L), o = g(
1562
+ (m) => {
1563
+ m.stopPropagation(), m.preventDefault(), a && i({ type: "SET_MUTED", muted: !1 });
1564
+ const { value: y } = m.target, f = parseFloat(y);
1565
+ i({
1424
1566
  type: "SET_VOLUME",
1425
- volume: h
1567
+ volume: f
1426
1568
  });
1427
1569
  },
1428
- [r, s]
1429
- ), c = o ?? ((y = a == null ? void 0 : a.audioEl) == null ? void 0 : y.volume) ?? 0, l = c * 100, u = Math.round(l), m = D(
1570
+ [a, i]
1571
+ ), c = n ?? ((p = r == null ? void 0 : r.audioEl) == null ? void 0 : p.volume) ?? 0, u = c * 100, d = Math.round(u), l = k(
1430
1572
  () => ({
1431
- "--rm-audio-player-volume-value": `${l}%`
1573
+ "--rm-audio-player-volume-value": `${u}%`
1432
1574
  }),
1433
- [l]
1575
+ [u]
1434
1576
  );
1435
- return /* @__PURE__ */ i(
1577
+ return /* @__PURE__ */ s(
1436
1578
  "div",
1437
1579
  {
1438
1580
  ref: t,
1439
1581
  className: "rmap-volume-container",
1440
1582
  "data-placement": e,
1441
1583
  "data-testid": "volume-slider",
1442
- style: m,
1443
- children: /* @__PURE__ */ i("div", { className: "rmap-volume-panel", children: /* @__PURE__ */ i(
1584
+ style: l,
1585
+ children: /* @__PURE__ */ s("div", { className: "rmap-volume-panel", children: /* @__PURE__ */ s(
1444
1586
  "input",
1445
1587
  {
1446
1588
  className: "rmap-volume-slider",
1447
1589
  type: "range",
1448
1590
  style: { cursor: "pointer" },
1449
1591
  value: c,
1450
- onChange: n,
1592
+ onChange: o,
1451
1593
  min: "0",
1452
1594
  max: "1",
1453
1595
  step: "0.01",
1454
- "aria-label": r ? "Volume (muted)" : "Volume",
1455
- "aria-valuetext": `${u} percent`
1596
+ "aria-label": a ? "Volume (muted)" : "Volume",
1597
+ "aria-valuetext": `${d} percent`
1456
1598
  }
1457
1599
  ) })
1458
1600
  }
1459
1601
  );
1460
- }, ue = H(null);
1461
- ue.displayName = "DropdownContext";
1462
- const Je = ({
1602
+ }, pe = O(null);
1603
+ pe.displayName = "DropdownContext";
1604
+ const vt = ({
1463
1605
  clickArea: e,
1464
1606
  triggerType: t,
1465
- isOpen: o,
1466
- setIsOpen: r,
1467
- onOpenChange: a
1607
+ isOpen: n,
1608
+ setIsOpen: a,
1609
+ onOpenChange: r
1468
1610
  }) => {
1469
- const s = A(), n = (m) => {
1470
- const y = () => {
1471
- clearTimeout(s.current), s.current = void 0;
1472
- }, d = (p) => {
1473
- r(p), a && a(p), y();
1611
+ const i = A(), o = (l) => {
1612
+ const p = () => {
1613
+ clearTimeout(i.current), i.current = void 0;
1614
+ }, m = (y) => {
1615
+ a(y), r && r(y), p();
1474
1616
  };
1475
- if (y(), m) {
1476
- s.current = window.setTimeout(() => d(!0), 100);
1617
+ if (p(), l) {
1618
+ i.current = window.setTimeout(() => m(!0), 100);
1477
1619
  return;
1478
1620
  }
1479
- s.current = window.setTimeout(() => d(!1), 100);
1480
- }, c = (m) => {
1481
- t === "hover" && n(m);
1621
+ i.current = window.setTimeout(() => m(!1), 100);
1622
+ }, c = (l) => {
1623
+ t === "hover" && o(l);
1482
1624
  };
1483
1625
  return {
1484
- onClick: e === "content" ? (m) => {
1485
- m.stopPropagation(), m.nativeEvent.stopImmediatePropagation();
1626
+ onClick: e === "content" ? (l) => {
1627
+ l.stopPropagation(), l.nativeEvent.stopImmediatePropagation();
1486
1628
  } : () => {
1487
- t === "click" && (r(!o), a && a(!o));
1629
+ t === "click" && (a(!n), r && r(!n));
1488
1630
  },
1489
1631
  onKeyUp: () => c(!0),
1490
1632
  onMouseEnter: () => c(!0),
@@ -1492,50 +1634,50 @@ const Je = ({
1492
1634
  onFocus: () => c(!0),
1493
1635
  onBlur: () => c(!1)
1494
1636
  };
1495
- }, ie = ({
1637
+ }, oe = ({
1496
1638
  triggerType: e = "click",
1497
1639
  outboundClickActive: t = !0,
1498
- children: o,
1499
- isOpen: r,
1500
- placement: a = "bottom",
1501
- disabled: s = !1,
1502
- onOpenChange: n,
1640
+ children: n,
1641
+ isOpen: a,
1642
+ placement: r = "bottom",
1643
+ disabled: i = !1,
1644
+ onOpenChange: o,
1503
1645
  "data-testid": c
1504
1646
  }) => {
1505
- const l = A(null), [u, m] = te.Children.toArray(o), [y, d] = b(!1), p = Je({
1506
- setIsOpen: d,
1507
- isOpen: y,
1647
+ const u = A(null), [d, l] = ee.Children.toArray(n), [p, m] = b(!1), y = vt({
1648
+ setIsOpen: m,
1649
+ isOpen: p,
1508
1650
  triggerType: e,
1509
1651
  clickArea: "root"
1510
- }), h = ke();
1511
- Ye(l, () => t && d(!1)), E(() => {
1512
- r !== void 0 && d(r);
1513
- }, [r]);
1514
- const v = D(
1652
+ }), f = Be();
1653
+ lt(u, () => t && m(!1)), P(() => {
1654
+ a !== void 0 && m(a);
1655
+ }, [a]);
1656
+ const v = k(
1515
1657
  () => ({
1516
- dropdownRef: l,
1517
- placement: a,
1518
- isOpen: y,
1519
- setIsOpen: d,
1520
- onOpenChange: n,
1521
- dropdownId: h
1658
+ dropdownRef: u,
1659
+ placement: r,
1660
+ isOpen: p,
1661
+ setIsOpen: m,
1662
+ onOpenChange: o,
1663
+ dropdownId: f
1522
1664
  }),
1523
- [a, y, n, h]
1665
+ [r, p, o, f]
1524
1666
  );
1525
- return /* @__PURE__ */ i(ue.Provider, { value: v, children: /* @__PURE__ */ i(
1667
+ return /* @__PURE__ */ s(pe.Provider, { value: v, children: /* @__PURE__ */ s(
1526
1668
  "div",
1527
1669
  {
1528
1670
  className: "rmap-dropdown-container",
1529
- ref: l,
1671
+ ref: u,
1530
1672
  "data-testid": c,
1531
- ...p,
1532
- children: /* @__PURE__ */ S(z, { children: [
1533
- u,
1534
- !s && m
1673
+ ...y,
1674
+ children: /* @__PURE__ */ w(R, { children: [
1675
+ d,
1676
+ !i && l
1535
1677
  ] })
1536
1678
  }
1537
1679
  ) });
1538
- }, zt = (e, t) => D(() => {
1680
+ }, dr = (e, t) => k(() => {
1539
1681
  if (t)
1540
1682
  return {
1541
1683
  position: "absolute",
@@ -1546,213 +1688,192 @@ const Je = ({
1546
1688
  left: e === "right" ? `${t.width}px` : void 0,
1547
1689
  right: e === "left" ? `${t.width}px` : void 0
1548
1690
  };
1549
- }, [t, e]), Wt = ({
1691
+ }, [t, e]), mr = ({
1550
1692
  children: e,
1551
1693
  isWithAnimation: t = !0,
1552
- ...o
1694
+ ...n
1553
1695
  }) => {
1554
- const { dropdownRef: r, placement: a, isOpen: s, setIsOpen: n, dropdownId: c } = f(ue), [l, u] = b(), { onClick: m } = Je({
1555
- setIsOpen: n,
1556
- isOpen: s,
1696
+ const { dropdownRef: a, placement: r, isOpen: i, setIsOpen: o, dropdownId: c } = E(pe), [u, d] = b(), { onClick: l } = vt({
1697
+ setIsOpen: o,
1698
+ isOpen: i,
1557
1699
  clickArea: "content"
1558
- }), y = () => n(!1), d = () => n(!0);
1559
- E(() => {
1560
- r.current && u({
1561
- width: r.current.offsetWidth,
1562
- height: r.current.offsetHeight
1700
+ }), p = () => o(!1), m = () => o(!0);
1701
+ P(() => {
1702
+ a.current && d({
1703
+ width: a.current.offsetWidth,
1704
+ height: a.current.offsetHeight
1563
1705
  });
1564
- }, [r]);
1565
- const p = zt(a, l), h = l ? /* @__PURE__ */ i(
1706
+ }, [a]);
1707
+ const y = dr(r, u), f = u ? /* @__PURE__ */ s(
1566
1708
  "div",
1567
1709
  {
1568
- ...o,
1710
+ ...n,
1569
1711
  id: c,
1570
- style: { ...p, ...o.style },
1571
- onClick: m,
1712
+ style: { ...y, ...n.style },
1713
+ onClick: l,
1572
1714
  children: e
1573
1715
  }
1574
1716
  ) : null;
1575
- return t ? /* @__PURE__ */ i(
1576
- Se,
1717
+ return t ? /* @__PURE__ */ s(
1718
+ ke,
1577
1719
  {
1578
- visible: s,
1720
+ visible: i,
1579
1721
  name: "rmap-dropdown-content",
1580
1722
  enterTime: 20,
1581
1723
  leaveTime: 60,
1582
1724
  clearTime: 300,
1583
- onExited: y,
1584
- onEntered: d,
1585
- children: h
1725
+ onExited: p,
1726
+ onEntered: m,
1727
+ children: f
1586
1728
  }
1587
- ) : s ? h : null;
1588
- }, Gt = ({ children: e }) => {
1589
- const { isOpen: t, setIsOpen: o, dropdownId: r } = f(ue);
1590
- return /* @__PURE__ */ i(
1591
- "div",
1729
+ ) : i ? f : null;
1730
+ }, ft = Pe(({ children: e, className: t, ...n }, a) => {
1731
+ const { isOpen: r, dropdownId: i } = E(pe), o = t ? `rmap-dropdown-trigger ${t}` : "rmap-dropdown-trigger";
1732
+ return /* @__PURE__ */ s(
1733
+ j,
1592
1734
  {
1593
- className: "rmap-dropdown-trigger",
1594
- role: "button",
1595
- tabIndex: 0,
1596
- "aria-expanded": t,
1597
- "aria-controls": r,
1598
- onKeyDown: (s) => {
1599
- (s.key === "Enter" || s.key === " ") && (s.preventDefault(), o((n) => !n));
1600
- },
1735
+ className: o,
1736
+ type: "button",
1737
+ ...n,
1738
+ "aria-haspopup": "true",
1739
+ "aria-expanded": r,
1740
+ "aria-controls": i,
1741
+ ref: a,
1601
1742
  children: e
1602
1743
  }
1603
1744
  );
1604
- };
1605
- ie.Content = Wt;
1606
- ie.Trigger = Gt;
1607
- const jt = ({
1745
+ });
1746
+ ft.displayName = "DropdownTrigger";
1747
+ oe.Content = mr;
1748
+ oe.Trigger = ft;
1749
+ const pr = ({
1608
1750
  triggerRef: e,
1609
1751
  initialState: t
1610
1752
  }) => {
1611
- const { playerPlacement: o } = O(), [r, a] = b(t);
1612
- return E(() => {
1753
+ const { playerPlacement: n } = x(), [a, r] = b(t);
1754
+ return P(() => {
1613
1755
  if (e.current) {
1614
- const s = () => e.current.getBoundingClientRect().top < window.innerHeight / 2 ? "bottom" : "top", n = setTimeout(() => {
1615
- a(s());
1756
+ const i = () => e.current.getBoundingClientRect().top < window.innerHeight / 2 ? "bottom" : "top", o = setTimeout(() => {
1757
+ r(i());
1616
1758
  }, 0);
1617
1759
  return () => {
1618
- clearTimeout(n);
1760
+ clearTimeout(o);
1619
1761
  };
1620
1762
  }
1621
- }, [o, e]), r;
1622
- }, Yt = () => {
1623
- const e = A(null), {
1624
- activeUI: { volumeSlider: t },
1625
- volumeSliderPlacement: o
1626
- } = O(), r = jt({
1627
- triggerRef: e,
1763
+ }, [n, e]), a;
1764
+ }, ht = ({ gridArea: e, visible: t, ...n }) => {
1765
+ const a = A(null), { muted: r } = C(), i = E(L), o = g(
1766
+ () => i({ type: "SET_MUTED", muted: !r }),
1767
+ [i, r]
1768
+ ), {
1769
+ activeUI: { volumeSlider: c },
1770
+ volumeSliderPlacement: u
1771
+ } = x(), d = pr({
1772
+ triggerRef: a,
1628
1773
  initialState: "bottom"
1629
- });
1630
- return /* @__PURE__ */ S(
1631
- ie,
1774
+ }), l = z("volume", e);
1775
+ return /* @__PURE__ */ s(_.Item, { gridArea: l, visible: t ?? !0, ...n, children: /* @__PURE__ */ w(
1776
+ oe,
1632
1777
  {
1633
- placement: o || r,
1778
+ placement: u || d,
1634
1779
  triggerType: "hover",
1635
- disabled: t === !1,
1780
+ disabled: c === !1,
1636
1781
  "data-testid": "volume-dropdown",
1637
1782
  children: [
1638
- /* @__PURE__ */ i(ie.Trigger, { children: /* @__PURE__ */ i(je, { ref: e }) }),
1639
- /* @__PURE__ */ i(ie.Content, { role: "tooltip", children: /* @__PURE__ */ i(
1640
- Rt,
1783
+ /* @__PURE__ */ s(
1784
+ oe.Trigger,
1641
1785
  {
1642
- placement: o || r
1786
+ ref: a,
1787
+ "aria-label": r ? "Unmute" : "Mute",
1788
+ "aria-pressed": r,
1789
+ onClick: o,
1790
+ className: "rmap-volume-trigger",
1791
+ "data-testid": "volume-trigger-btn",
1792
+ "data-muted": String(r),
1793
+ children: /* @__PURE__ */ s(ct, {})
1794
+ }
1795
+ ),
1796
+ /* @__PURE__ */ s(oe.Content, { role: "tooltip", children: /* @__PURE__ */ s(
1797
+ ur,
1798
+ {
1799
+ placement: u || d
1643
1800
  }
1644
1801
  ) })
1645
1802
  ]
1646
1803
  }
1647
- );
1648
- }, qt = () => {
1649
- var r, a, s, n, c, l, u, m, y, d;
1650
- const { interfacePlacement: e, activeUI: t } = O(), o = !!(t.prevNnext ?? t.all);
1651
- return /* @__PURE__ */ S(z, { children: [
1652
- /* @__PURE__ */ i(
1653
- M.Item,
1654
- {
1655
- gridArea: ((r = e == null ? void 0 : e.itemCustomArea) == null ? void 0 : r.progress) || ((a = e == null ? void 0 : e.templateArea) == null ? void 0 : a.progress) || k.templateArea.progress,
1656
- width: "100%",
1657
- visible: !!(t.progress !== void 0 ? t.progress : t.all),
1658
- children: /* @__PURE__ */ i(Ht, {})
1659
- }
1660
- ),
1661
- /* @__PURE__ */ i(
1662
- M.Item,
1663
- {
1664
- gridArea: ((s = e == null ? void 0 : e.itemCustomArea) == null ? void 0 : s.repeatType) || ((n = e == null ? void 0 : e.templateArea) == null ? void 0 : n.repeatType) || k.templateArea.repeatType,
1665
- visible: !!(t.repeatType ?? t.all),
1666
- children: /* @__PURE__ */ i(Pt, {})
1667
- }
1668
- ),
1669
- /* @__PURE__ */ i(
1670
- M.Item,
1671
- {
1672
- gridArea: ((c = e == null ? void 0 : e.itemCustomArea) == null ? void 0 : c.playButton) || ((l = e == null ? void 0 : e.templateArea) == null ? void 0 : l.playButton) || k.templateArea.playButton,
1673
- visible: !!(t.playButton ?? t.all),
1674
- children: /* @__PURE__ */ S("div", { className: "rmap-ctrl-btn-wrapper", children: [
1675
- /* @__PURE__ */ i(Et, { isVisible: o }),
1676
- /* @__PURE__ */ i(At, {}),
1677
- /* @__PURE__ */ i(It, { isVisible: o })
1678
- ] })
1679
- }
1680
- ),
1681
- /* @__PURE__ */ i(
1682
- M.Item,
1683
- {
1684
- gridArea: ((u = e == null ? void 0 : e.itemCustomArea) == null ? void 0 : u.volume) || ((m = e == null ? void 0 : e.templateArea) == null ? void 0 : m.volume) || k.templateArea.volume,
1685
- visible: !!(t.volume ?? t.all),
1686
- children: /* @__PURE__ */ i(Yt, {})
1687
- }
1688
- ),
1689
- /* @__PURE__ */ i(
1690
- M.Item,
1691
- {
1692
- gridArea: ((y = e == null ? void 0 : e.itemCustomArea) == null ? void 0 : y.playList) || ((d = e == null ? void 0 : e.templateArea) == null ? void 0 : d.playList) || k.templateArea.playList,
1693
- visible: !!(t.playList ?? t.all),
1694
- children: /* @__PURE__ */ i(Ot, {})
1695
- }
1696
- )
1804
+ ) });
1805
+ }, yr = () => {
1806
+ const { activeUI: e } = x(), t = (n) => !!(e[n] ?? e.all);
1807
+ return /* @__PURE__ */ w(R, { children: [
1808
+ /* @__PURE__ */ s(yt, { visible: t("progress") }),
1809
+ /* @__PURE__ */ s(st, { visible: t("repeatType") }),
1810
+ /* @__PURE__ */ s(it, { visible: t("playButton") }),
1811
+ /* @__PURE__ */ s(ht, { visible: t("volume") }),
1812
+ /* @__PURE__ */ s(dt, { visible: t("playList") })
1697
1813
  ] });
1698
- }, Xt = W(function() {
1699
- const { playList: t, curIdx: o } = V(), { coverImgsCss: r } = P(), a = t[o], s = [a == null ? void 0 : a.writer, a == null ? void 0 : a.name].filter(Boolean).join(" - ") || "Album artwork";
1700
- return /* @__PURE__ */ i("div", { className: "rmap-artwork-container", children: a != null && a.img ? /* @__PURE__ */ i("img", { src: a.img, alt: s, style: r == null ? void 0 : r.artwork }) : /* @__PURE__ */ i(
1814
+ }, Tt = G(function({
1815
+ gridArea: t,
1816
+ visible: n,
1817
+ ...a
1818
+ }) {
1819
+ const { playList: r, curIdx: i } = K(), { coverImgsCss: o } = N(), c = r[i], u = [c == null ? void 0 : c.writer, c == null ? void 0 : c.name].filter(Boolean).join(" - ") || "Album artwork", d = z("artwork", t);
1820
+ return /* @__PURE__ */ s(_.Item, { gridArea: d, visible: n ?? !0, ...a, children: /* @__PURE__ */ s("div", { className: "rmap-artwork-container", children: c != null && c.img ? /* @__PURE__ */ s("img", { src: c.img, alt: u, style: o == null ? void 0 : o.artwork }) : /* @__PURE__ */ s(
1701
1821
  "div",
1702
1822
  {
1703
1823
  className: "rmap-artwork-fallback",
1704
1824
  role: "img",
1705
- "aria-label": s,
1706
- style: r == null ? void 0 : r.artwork,
1707
- children: (a == null ? void 0 : a.name) || "♪"
1825
+ "aria-label": u,
1826
+ style: o == null ? void 0 : o.artwork,
1827
+ children: (c == null ? void 0 : c.name) || "♪"
1708
1828
  }
1709
- ) });
1710
- }), Qt = W(function() {
1711
- const { playList: t, curIdx: o } = V(), r = t[o];
1712
- return /* @__PURE__ */ i("div", { className: "rmap-track-info-container", children: r != null && r.customTrackInfo ? r.customTrackInfo : /* @__PURE__ */ S(z, { children: [
1713
- (r == null ? void 0 : r.name) && /* @__PURE__ */ i("span", { className: "title", "data-testid": "track-title", children: r.name }),
1714
- (r == null ? void 0 : r.writer) && /* @__PURE__ */ i("span", { className: "writer", children: r.writer })
1715
- ] }) });
1716
- }), Ze = ({ position: e, className: t, children: o, ...r }) => /* @__PURE__ */ i(
1829
+ ) }) });
1830
+ }), Me = G(function({
1831
+ gridArea: t,
1832
+ visible: n,
1833
+ ...a
1834
+ }) {
1835
+ const { playList: r, curIdx: i } = K(), o = r[i], c = z("trackInfo", t);
1836
+ return /* @__PURE__ */ s(_.Item, { gridArea: c, visible: n ?? !0, ...a, children: /* @__PURE__ */ s("div", { className: "rmap-track-info-container", children: o != null && o.customTrackInfo ? o.customTrackInfo : /* @__PURE__ */ w(R, { children: [
1837
+ (o == null ? void 0 : o.name) && /* @__PURE__ */ s("span", { className: "title", "data-testid": "track-title", children: o.name }),
1838
+ (o == null ? void 0 : o.writer) && /* @__PURE__ */ s("span", { className: "writer", children: o.writer })
1839
+ ] }) }) });
1840
+ });
1841
+ Me.displayName = "TrackInfo";
1842
+ const gt = ({ position: e, className: t, children: n, ...a }) => /* @__PURE__ */ s(
1717
1843
  "div",
1718
1844
  {
1719
1845
  className: `rmap-track-time-container${t ? ` ${t}` : ""}`,
1720
1846
  "data-position": e,
1721
- ...r,
1722
- children: o
1847
+ ...a,
1848
+ children: n
1723
1849
  }
1724
- ), Jt = ({ position: e }) => {
1725
- const { currentTime: t } = re();
1726
- return /* @__PURE__ */ i(Ze, { position: e, className: "rmap-track-time-current", children: /* @__PURE__ */ i(
1850
+ ), vr = ({ position: e }) => {
1851
+ const { currentTime: t } = te();
1852
+ return /* @__PURE__ */ s(gt, { position: e, className: "rmap-track-time-current", children: /* @__PURE__ */ s(
1727
1853
  "span",
1728
1854
  {
1729
1855
  className: "rmap-track-current-time",
1730
1856
  "data-testid": "track-current-time",
1731
- children: ee(t)
1857
+ children: Z(t)
1732
1858
  }
1733
1859
  ) });
1734
- }, Zt = ({ position: e }) => {
1735
- const { duration: t } = re();
1736
- return /* @__PURE__ */ i(
1737
- Ze,
1860
+ }, fr = ({ position: e }) => {
1861
+ const { duration: t } = te();
1862
+ return /* @__PURE__ */ s(
1863
+ gt,
1738
1864
  {
1739
1865
  position: e,
1740
1866
  className: "rmap-track-time-duration",
1741
- children: /* @__PURE__ */ i("span", { className: "rmap-track-duration", children: ee(t) })
1867
+ children: /* @__PURE__ */ s("span", { className: "rmap-track-duration", children: Z(t) })
1742
1868
  }
1743
1869
  );
1744
- }, er = () => {
1745
- var c, l, u, m, y, d, p, h;
1746
- const { interfacePlacement: e, activeUI: t } = O(), o = g(
1747
- (v) => +v.split(/[^\d]/).join(""),
1870
+ }, Et = ({ visible: e }) => {
1871
+ const t = z("trackTimeCurrent"), n = z("trackTimeDuration"), a = g(
1872
+ (d) => +d.split(/[^\d]/).join(""),
1748
1873
  []
1749
- ), r = o(
1750
- ((c = e == null ? void 0 : e.itemCustomArea) == null ? void 0 : c.trackTimeCurrent) || ((l = e == null ? void 0 : e.templateArea) == null ? void 0 : l.trackTimeCurrent) || k.templateArea.trackTimeCurrent
1751
- ), a = o(
1752
- ((u = e == null ? void 0 : e.itemCustomArea) == null ? void 0 : u.trackTimeDuration) || ((m = e == null ? void 0 : e.templateArea) == null ? void 0 : m.trackTimeDuration) || k.templateArea.trackTimeDuration
1753
- ), s = g(
1754
- (v) => {
1755
- switch (v) {
1874
+ ), r = a(t), i = a(n), o = g(
1875
+ (d) => {
1876
+ switch (d) {
1756
1877
  case 1:
1757
1878
  return "right";
1758
1879
  case -1:
@@ -1762,296 +1883,357 @@ const jt = ({
1762
1883
  }
1763
1884
  },
1764
1885
  []
1765
- ), n = {
1766
- current: s(r - a),
1767
- duration: s(a - r)
1768
- };
1769
- return /* @__PURE__ */ S(z, { children: [
1770
- /* @__PURE__ */ i(
1771
- M.Item,
1772
- {
1773
- gridArea: ((y = e == null ? void 0 : e.itemCustomArea) == null ? void 0 : y.trackTimeCurrent) || ((d = e == null ? void 0 : e.templateArea) == null ? void 0 : d.trackTimeCurrent) || k.templateArea.trackTimeCurrent,
1774
- visible: !!(t.trackTime ?? t.all),
1775
- children: /* @__PURE__ */ i(Jt, { position: n.current })
1776
- }
1777
- ),
1778
- /* @__PURE__ */ i(
1779
- M.Item,
1780
- {
1781
- gridArea: ((p = e == null ? void 0 : e.itemCustomArea) == null ? void 0 : p.trackTimeDuration) || ((h = e == null ? void 0 : e.templateArea) == null ? void 0 : h.trackTimeDuration) || k.templateArea.trackTimeDuration,
1782
- visible: !!(t.trackTime ?? t.all),
1783
- children: /* @__PURE__ */ i(Zt, { position: n.duration })
1784
- }
1785
- )
1886
+ ), c = {
1887
+ current: o(r - i),
1888
+ duration: o(i - r)
1889
+ }, u = e ?? !0;
1890
+ return /* @__PURE__ */ w(R, { children: [
1891
+ /* @__PURE__ */ s(_.Item, { gridArea: t, visible: u, children: /* @__PURE__ */ s(vr, { position: c.current }) }),
1892
+ /* @__PURE__ */ s(_.Item, { gridArea: n, visible: u, children: /* @__PURE__ */ s(fr, { position: c.duration }) })
1786
1893
  ] });
1787
- }, tr = () => {
1788
- var s, n, c, l, u, m, y, d;
1789
- const { playList: e, curIdx: t } = V(), { interfacePlacement: o, activeUI: r } = O(), a = !!(((s = e[t]) == null ? void 0 : s.customTrackInfo) ?? ((n = e[t]) == null ? void 0 : n.writer) ?? ((c = e[t]) == null ? void 0 : c.name)) && !!(r.trackInfo ?? r.all);
1790
- return /* @__PURE__ */ S(z, { children: [
1791
- /* @__PURE__ */ i(
1792
- M.Item,
1793
- {
1794
- gridArea: ((l = o == null ? void 0 : o.itemCustomArea) == null ? void 0 : l.artwork) || ((u = o == null ? void 0 : o.templateArea) == null ? void 0 : u.artwork) || k.templateArea.artwork,
1795
- visible: !!((m = e[t]) != null && m.img && (r.artwork ?? r.all)),
1796
- children: /* @__PURE__ */ i(Xt, {})
1797
- }
1798
- ),
1799
- /* @__PURE__ */ i(
1800
- M.Item,
1894
+ }, hr = () => {
1895
+ var r, i, o, c;
1896
+ const { playList: e, curIdx: t } = K(), { activeUI: n } = x(), a = !!(((r = e[t]) == null ? void 0 : r.customTrackInfo) ?? ((i = e[t]) == null ? void 0 : i.writer) ?? ((o = e[t]) == null ? void 0 : o.name)) && !!(n.trackInfo ?? n.all);
1897
+ return /* @__PURE__ */ w(R, { children: [
1898
+ /* @__PURE__ */ s(
1899
+ Tt,
1801
1900
  {
1802
- gridArea: ((y = o == null ? void 0 : o.itemCustomArea) == null ? void 0 : y.trackInfo) || ((d = o == null ? void 0 : o.templateArea) == null ? void 0 : d.trackInfo) || k.templateArea.trackInfo,
1803
- visible: a,
1804
- children: /* @__PURE__ */ i(Qt, {})
1901
+ visible: !!((c = e[t]) != null && c.img && (n.artwork ?? n.all))
1805
1902
  }
1806
1903
  ),
1807
- /* @__PURE__ */ i(er, {})
1904
+ /* @__PURE__ */ s(Me, { visible: a }),
1905
+ /* @__PURE__ */ s(Et, { visible: !!(n.trackTime ?? n.all) })
1808
1906
  ] });
1809
- }, rr = (e, t, o) => {
1810
- const r = g(
1811
- (d, p, h) => {
1812
- const v = Object.keys(
1813
- k.templateArea
1814
- ).filter((I) => (I === "trackTimeCurrent" || I === "trackTimeDuration") && d.trackTime === !1 ? !1 : d[I] !== void 0 ? d[I] : !0), T = d.all ? v : Object.entries(d).filter(([, I]) => I).map(([I]) => I);
1907
+ }, Ee = {
1908
+ Progress: { displayName: "Progress", activeUIKey: "progress" },
1909
+ Volume: { displayName: "Volume", activeUIKey: "volume" },
1910
+ SortablePlayList: { displayName: "PlayList", activeUIKey: "playList" },
1911
+ TransportControls: { displayName: "PlayButton", activeUIKey: "playButton" },
1912
+ RepeatTypeBtn: { displayName: "RepeatButton", activeUIKey: "repeatType" },
1913
+ Artwork: { displayName: "Artwork", activeUIKey: "artwork" },
1914
+ TrackInfo: { displayName: "TrackInfo", activeUIKey: "trackInfo" },
1915
+ TrackTime: { displayName: "TrackTime", activeUIKey: "trackTime" }
1916
+ };
1917
+ function Tr(e, t) {
1918
+ const n = e[t];
1919
+ return n === !1 ? !1 : n !== void 0 ? !0 : !!e.all;
1920
+ }
1921
+ function _e(e) {
1922
+ const t = e.type;
1923
+ if (!t) return;
1924
+ const n = t.type ?? t;
1925
+ return n.displayName || n.name || void 0;
1926
+ }
1927
+ const gr = (e, t, n, a) => {
1928
+ const r = k(
1929
+ () => (a ?? []).map(_e).map(
1930
+ (h) => {
1931
+ var I;
1932
+ return h ? (I = Ee[h]) == null ? void 0 : I.activeUIKey : void 0;
1933
+ }
1934
+ ).filter((h) => h !== void 0),
1935
+ [a]
1936
+ ), i = k(
1937
+ () => [...r].sort().join(","),
1938
+ [r]
1939
+ ), o = g(
1940
+ (h, I, B, re) => {
1941
+ const se = Object.keys(
1942
+ de.templateArea
1943
+ ).filter((S) => (S === "trackTimeCurrent" || S === "trackTimeDuration") && h.trackTime === !1 ? !1 : h[S] !== void 0 ? h[S] : !0), D = h.all ? se : Object.entries(h).filter(([, S]) => S).map(([S]) => S);
1944
+ for (const S of re)
1945
+ D.includes(S) || D.push(S);
1815
1946
  (() => {
1816
- T.find((I) => I === "trackTime") && (T.splice(T.indexOf("trackTime"), 1), T.push("trackTimeCurrent"), T.push("trackTimeDuration"));
1947
+ D.find((S) => S === "trackTime") && (D.splice(D.indexOf("trackTime"), 1), D.push("trackTimeCurrent"), D.push("trackTimeDuration"));
1817
1948
  })();
1818
- const N = {
1819
- ...k.templateArea,
1820
- ...p
1821
- }, B = Object.entries(
1822
- N
1823
- ).filter(([I]) => T.includes(I));
1824
- let R = 1;
1825
- const G = {}, ae = [
1826
- ...B,
1827
- ...Object.entries(h || {})
1828
- ].flatMap(([I, _]) => {
1829
- if (_ == null) return [];
1830
- const [K, $] = _.split("-"), j = +K.split("row")[1];
1831
- return R = Math.max(R, j), G[j] = G[j] ? G[j] + 1 : 1, [
1949
+ const q = {
1950
+ ...de.templateArea,
1951
+ ...I
1952
+ }, At = Object.entries(
1953
+ q
1954
+ ).filter(([S]) => D.includes(S));
1955
+ let le = 1;
1956
+ const ue = {}, It = [
1957
+ ...At,
1958
+ ...Object.entries(B || {})
1959
+ ].flatMap(([S, U]) => {
1960
+ if (U == null) return [];
1961
+ const [$, F] = U.split("-"), W = +$.split("row")[1];
1962
+ return le = Math.max(le, W), ue[W] = ue[W] ? ue[W] + 1 : 1, [
1832
1963
  {
1833
- key: I,
1834
- row: j,
1835
- col: +$
1964
+ key: S,
1965
+ row: W,
1966
+ col: +F
1836
1967
  }
1837
1968
  ];
1838
- }).sort((I, _) => I.col - _.col), X = Math.max(...Object.values(G));
1839
- let oe;
1840
- const et = new Array(R).fill("").map((I, _) => {
1841
- let K = "", $;
1842
- const j = ae.filter((U) => U.row !== _ + 1 ? !1 : (U.key === "progress" && ($ = U), !0));
1843
- if ($) {
1844
- const U = /* @__PURE__ */ new Map();
1845
- j.forEach((Q) => U.set(Q.col, Q));
1846
- const de = `row${_ + 1}-${$.col}`, ne = [];
1847
- for (let Q = 0; Q < X; Q++) {
1848
- const Pe = Q + 1;
1849
- U.has(Pe) ? ne.push(`row${_ + 1}-${Pe}`) : ne.push(de);
1969
+ }).sort((S, U) => S.col - U.col), ye = Math.max(...Object.values(ue));
1970
+ let De;
1971
+ const St = new Array(le).fill("").map((S, U) => {
1972
+ let $ = "", F;
1973
+ const W = It.filter((V) => V.row !== U + 1 ? !1 : (V.key === "progress" && (F = V), !0));
1974
+ if (F) {
1975
+ const V = /* @__PURE__ */ new Map();
1976
+ W.forEach((X) => V.set(X.col, X));
1977
+ const ve = `row${U + 1}-${F.col}`, ae = [];
1978
+ for (let X = 0; X < ye; X++) {
1979
+ const Ue = X + 1;
1980
+ V.has(Ue) ? ae.push(`row${U + 1}-${Ue}`) : ae.push(ve);
1850
1981
  }
1851
- const at = ne.indexOf(de), ot = ne.lastIndexOf(de);
1852
- oe = Math.floor((at + ot) / 2), K = " " + ne.join(" ");
1982
+ const Nt = ae.indexOf(ve), bt = ae.lastIndexOf(ve);
1983
+ De = Math.floor((Nt + bt) / 2), $ = " " + ae.join(" ");
1853
1984
  } else
1854
- for (let U = 0; U < X; U++)
1855
- K += ` row${_ + 1}-${U + 1}`;
1856
- return K.trimStart();
1857
- }), tt = qe ? window.innerWidth - 100 : 1500, rt = new Array(R).fill("").map((I, _) => {
1858
- let K = "";
1859
- for (let $ = 0; $ < X; $++) {
1860
- if (oe === $ && _ === 0) {
1861
- K += " 1fr";
1985
+ for (let V = 0; V < ye; V++)
1986
+ $ += ` row${U + 1}-${V + 1}`;
1987
+ return $.trimStart();
1988
+ }), wt = ut ? window.innerWidth - 100 : 1500, Lt = new Array(le).fill("").map((S, U) => {
1989
+ let $ = "";
1990
+ for (let F = 0; F < ye; F++) {
1991
+ if (De === F && U === 0) {
1992
+ $ += " 1fr";
1862
1993
  continue;
1863
1994
  }
1864
- K += ` fit-content(${tt}px)`;
1995
+ $ += ` fit-content(${wt}px)`;
1865
1996
  }
1866
- return K.trimStart();
1997
+ return $.trimStart();
1867
1998
  });
1868
- return { gridAreas: et, gridColumns: rt };
1999
+ return { gridAreas: St, gridColumns: Lt };
1869
2000
  },
1870
2001
  []
1871
- ), [a, s] = b(e), [n, c] = b({
2002
+ ), [c, u] = b(e), [d, l] = b(i), [p, m] = b({
1872
2003
  templateArea: t,
1873
- customComponentsArea: o
1874
- }), [l, u] = b();
1875
- if (!l) {
1876
- const { gridAreas: d, gridColumns: p } = r(
1877
- a,
1878
- n.templateArea,
1879
- n.customComponentsArea
2004
+ customComponentsArea: n
2005
+ }), [y, f] = b();
2006
+ if (!y) {
2007
+ const { gridAreas: h, gridColumns: I } = o(
2008
+ c,
2009
+ p.templateArea,
2010
+ p.customComponentsArea,
2011
+ r
1880
2012
  );
1881
- return u({ gridAreas: d, gridColumns: p }), [d, p];
2013
+ return f({ gridAreas: h, gridColumns: I }), [h, I];
1882
2014
  }
1883
- if (a !== e || n.templateArea !== t || n.customComponentsArea !== o) {
1884
- s(e), c({ templateArea: t, customComponentsArea: o });
1885
- const { gridAreas: d, gridColumns: p } = r(
2015
+ if (c !== e || d !== i || p.templateArea !== t || p.customComponentsArea !== n) {
2016
+ u(e), l(i), m({ templateArea: t, customComponentsArea: n });
2017
+ const { gridAreas: h, gridColumns: I } = o(
1886
2018
  e,
1887
2019
  t,
1888
- o
2020
+ n,
2021
+ r
1889
2022
  );
1890
- u({ gridAreas: d, gridColumns: p });
2023
+ f({ gridAreas: h, gridColumns: I });
1891
2024
  }
1892
- const { gridAreas: m, gridColumns: y } = l;
1893
- return [m, y];
1894
- }, ar = ({ children: e }) => {
1895
- const { interfacePlacement: t, activeUI: o, playListPlacement: r } = O(), a = te.Children.toArray(e), [s, n] = rr(
1896
- o,
2025
+ const { gridAreas: v, gridColumns: T } = y;
2026
+ return [v, T];
2027
+ };
2028
+ function Er(e) {
2029
+ return k(() => {
2030
+ const t = ee.Children.toArray(e).filter(Mt), n = t.find(Ke);
2031
+ return {
2032
+ compoundChildren: t.filter(
2033
+ (a) => !Ke(a)
2034
+ ),
2035
+ playListEmptyNode: Pr(n)
2036
+ };
2037
+ }, [e]);
2038
+ }
2039
+ function Ke(e) {
2040
+ return _e(e) === ze;
2041
+ }
2042
+ function Pr(e) {
2043
+ if (!e) return null;
2044
+ const t = e.props;
2045
+ return (t == null ? void 0 : t.children) ?? null;
2046
+ }
2047
+ function Ar({
2048
+ compoundChildren: e,
2049
+ activeUI: t
2050
+ }) {
2051
+ const n = e.map(_e).filter((a) => !!(a && Ee[a])).sort().join(",");
2052
+ P(() => {
2053
+ if (process.env.NODE_ENV === "production" || !n) return;
2054
+ const a = /* @__PURE__ */ new Set();
2055
+ for (const r of n.split(",")) {
2056
+ const i = Ee[r];
2057
+ i && (a.has(i.displayName) || Tr(t, i.activeUIKey) && (a.add(i.displayName), console.warn(
2058
+ `[react-modern-audio-player] Both preset and compound '${i.displayName}' are rendered. Set \`activeUI.${i.activeUIKey}=false\` to replace the preset control.`
2059
+ )));
2060
+ }
2061
+ }, [n, t]);
2062
+ }
2063
+ const Ir = ({ children: e }) => {
2064
+ const { interfacePlacement: t, activeUI: n, playListPlacement: a } = x(), { compoundChildren: r, playListEmptyNode: i } = Er(e);
2065
+ Ar({ compoundChildren: r, activeUI: n });
2066
+ const [o, c] = gr(
2067
+ n,
1897
2068
  t == null ? void 0 : t.templateArea,
1898
- t == null ? void 0 : t.customComponentsArea
1899
- );
1900
- return /* @__PURE__ */ S(
2069
+ t == null ? void 0 : t.customComponentsArea,
2070
+ r
2071
+ ), [u, d] = b(null);
2072
+ return /* @__PURE__ */ s(
1901
2073
  "div",
1902
2074
  {
1903
2075
  className: "rmap-interface-container",
1904
2076
  "data-testid": "audio-player",
1905
2077
  role: "region",
1906
2078
  "aria-label": "Audio player",
1907
- children: [
1908
- r === "top" && /* @__PURE__ */ i("div", { className: "rmap-sortable-playlist" }),
1909
- /* @__PURE__ */ S(
1910
- M,
2079
+ children: /* @__PURE__ */ s(Ce.Provider, { value: u, children: /* @__PURE__ */ w(xe.Provider, { value: i, children: [
2080
+ a === "top" && /* @__PURE__ */ s("div", { ref: d, className: "rmap-sortable-playlist" }),
2081
+ /* @__PURE__ */ w(
2082
+ _,
1911
2083
  {
1912
2084
  alignItems: "center",
1913
2085
  justifyContent: "center",
1914
- areas: s,
2086
+ areas: o,
1915
2087
  minHeight: "30px",
1916
- columns: n,
2088
+ columns: c,
1917
2089
  UNSAFE_className: "rmap-interface-grid",
1918
2090
  children: [
1919
- /* @__PURE__ */ i(tr, {}),
1920
- /* @__PURE__ */ i(qt, {}),
1921
- a
2091
+ /* @__PURE__ */ s(hr, {}),
2092
+ /* @__PURE__ */ s(yr, {}),
2093
+ r
1922
2094
  ]
1923
2095
  }
1924
2096
  ),
1925
- r === "bottom" && /* @__PURE__ */ i("div", { className: "rmap-sortable-playlist" })
1926
- ]
2097
+ a === "bottom" && /* @__PURE__ */ s("div", { ref: d, className: "rmap-sortable-playlist" })
2098
+ ] }) })
1927
2099
  }
1928
2100
  );
1929
- }, Z = (e, t) => {
1930
- const o = A(!1);
1931
- E(() => {
1932
- if (o.current)
2101
+ }, J = (e, t) => {
2102
+ const n = A(!1);
2103
+ P(() => {
2104
+ if (n.current)
1933
2105
  return e();
1934
- }, t), E(() => (o.current = !0, () => {
1935
- o.current = !1;
2106
+ }, t), P(() => (n.current = !0, () => {
2107
+ n.current = !1;
1936
2108
  }), []);
1937
- }, or = ({
2109
+ }, Sr = ({
1938
2110
  placement: e = {},
1939
2111
  activeUI: t,
1940
- coverImgsCss: o,
1941
- audioInitialState: r,
1942
- playList: a,
1943
- customIcons: s
2112
+ coverImgsCss: n,
2113
+ audioInitialState: a,
2114
+ playList: r,
2115
+ customIcons: i
1944
2116
  }) => {
1945
- const n = f(w);
1946
- Z(() => {
2117
+ const o = E(L);
2118
+ J(() => {
1947
2119
  const {
1948
2120
  player: c,
1949
- playList: l,
1950
- interface: u,
1951
- volumeSlider: m
2121
+ playList: u,
2122
+ interface: d,
2123
+ volumeSlider: l
1952
2124
  } = e;
1953
- n({
2125
+ o({
1954
2126
  type: "SET_PLACEMENTS",
1955
2127
  playerPlacement: c,
1956
- playListPlacement: l,
1957
- interfacePlacement: u,
1958
- volumeSliderPlacement: m
2128
+ playListPlacement: u,
2129
+ interfacePlacement: d,
2130
+ volumeSliderPlacement: l
1959
2131
  });
1960
- }, [n, e]), Z(() => {
1961
- t && n({ type: "SET_ACTIVE_UI", activeUI: t });
1962
- }, [t, n]), Z(() => {
1963
- o && n({ type: "SET_COVER_IMGS_CSS", coverImgsCss: o });
1964
- }, [n, o]), Z(() => {
1965
- r && n({
2132
+ }, [o, e]), J(() => {
2133
+ t && o({ type: "SET_ACTIVE_UI", activeUI: t });
2134
+ }, [t, o]), J(() => {
2135
+ n && o({ type: "SET_COVER_IMGS_CSS", coverImgsCss: n });
2136
+ }, [o, n]), J(() => {
2137
+ a && o({
1966
2138
  type: "SET_INITIAL_STATES",
1967
- audioState: r,
1968
- curPlayId: r.curPlayId
2139
+ audioState: a,
2140
+ curPlayId: a.curPlayId
1969
2141
  });
1970
- }, [r, n]), Z(() => {
1971
- n({ type: "UPDATE_PLAY_LIST", playList: a });
1972
- }, [n, a]), Z(() => {
1973
- s && n({ type: "SET_CUSTOM_ICONS", customIcons: s });
1974
- }, [s, n]);
1975
- }, nr = ({
2142
+ }, [a, o]), J(() => {
2143
+ o({ type: "UPDATE_PLAY_LIST", playList: r });
2144
+ }, [o, r]), J(() => {
2145
+ i && o({ type: "SET_CUSTOM_ICONS", customIcons: i });
2146
+ }, [i, o]);
2147
+ }, wr = ({
1976
2148
  audioRef: e,
1977
2149
  children: t,
1978
- ...o
1979
- }) => (or(o), /* @__PURE__ */ S("div", { id: "rm-audio-player", className: "rmap-player-container", children: [
1980
- /* @__PURE__ */ i(_e, { audioRef: e }),
1981
- /* @__PURE__ */ i(ar, { children: t })
2150
+ ...n
2151
+ }) => (Sr(n), /* @__PURE__ */ w("div", { id: "rm-audio-player", className: "rmap-player-container", children: [
2152
+ /* @__PURE__ */ s(We, { audioRef: e }),
2153
+ /* @__PURE__ */ s(Ir, { children: t })
1982
2154
  ] }));
1983
- function we({
2155
+ function Pt({
1984
2156
  rootContainerProps: e,
1985
2157
  ...t
1986
2158
  }) {
1987
- return /* @__PURE__ */ i(yt, { ...t, children: /* @__PURE__ */ i(Ce, { rootContainerProps: e, children: /* @__PURE__ */ i(nr, { ...t }) }) });
2159
+ return /* @__PURE__ */ s(Kt, { ...t, children: /* @__PURE__ */ s(He, { rootContainerProps: e, children: /* @__PURE__ */ s(wr, { ...t }) }) });
1988
2160
  }
1989
- we.displayName = "AudioPlayerWithProviders";
1990
- we.CustomComponent = xe;
1991
- const sr = () => {
1992
- const e = f(w), { isPlaying: t, repeatType: o } = C(), r = g(() => {
2161
+ Pt.displayName = "AudioPlayerWithProviders";
2162
+ const Dr = Object.assign(Pt, {
2163
+ Progress: yt,
2164
+ Volume: ht,
2165
+ PlayList: dt,
2166
+ PlayListEmpty: Ge,
2167
+ PlayButton: it,
2168
+ RepeatButton: st,
2169
+ Artwork: Tt,
2170
+ TrackInfo: Me,
2171
+ TrackTime: Et,
2172
+ CustomComponent: Ht
2173
+ }), Lr = () => {
2174
+ const e = E(L), { isPlaying: t, repeatType: n } = C(), a = g(() => {
1993
2175
  e({ type: "CHANGE_PLAYING_STATE", state: !0 });
1994
- }, [e]), a = g(() => {
2176
+ }, [e]), r = g(() => {
1995
2177
  e({ type: "CHANGE_PLAYING_STATE", state: !1 });
1996
- }, [e]), s = g(() => {
2178
+ }, [e]), i = g(() => {
1997
2179
  e({ type: "CHANGE_PLAYING_STATE" });
1998
2180
  }, [e]);
1999
- return { isPlaying: t, repeatType: o, play: r, pause: a, togglePlay: s };
2000
- }, ir = () => {
2001
- const e = f(w), { playList: t, curIdx: o, curPlayId: r } = V(), { elementRefs: a } = P(), s = g(
2002
- (l) => {
2003
- const u = t[l];
2004
- u && e({
2181
+ return { isPlaying: t, repeatType: n, play: a, pause: r, togglePlay: i };
2182
+ }, Nr = () => {
2183
+ const e = E(L), { playList: t, curIdx: n, curPlayId: a } = K(), { elementRefs: r } = N(), i = g(
2184
+ (u) => {
2185
+ const d = t[u];
2186
+ d && e({
2005
2187
  type: "SET_CURRENT_AUDIO",
2006
- currentIndex: l,
2007
- currentAudioId: u.id
2188
+ currentIndex: u,
2189
+ currentAudioId: d.id
2008
2190
  });
2009
2191
  },
2010
2192
  [e, t]
2011
- ), n = g(() => {
2193
+ ), o = g(() => {
2012
2194
  t.length !== 0 && e({ type: "NEXT_AUDIO" });
2013
2195
  }, [e, t.length]), c = g(() => {
2014
- var u;
2196
+ var d;
2015
2197
  if (t.length === 0) return;
2016
- const l = ((u = a == null ? void 0 : a.audioEl) == null ? void 0 : u.currentTime) ?? 0;
2017
- e({ type: "PREV_AUDIO", currentTime: l });
2018
- }, [e, t.length, a == null ? void 0 : a.audioEl]);
2198
+ const u = ((d = r == null ? void 0 : r.audioEl) == null ? void 0 : d.currentTime) ?? 0;
2199
+ e({ type: "PREV_AUDIO", currentTime: u });
2200
+ }, [e, t.length, r == null ? void 0 : r.audioEl]);
2019
2201
  return {
2020
- currentPlayId: r,
2021
- currentIndex: o,
2202
+ currentPlayId: a,
2203
+ currentIndex: n,
2022
2204
  playList: t,
2023
- currentTrack: t[o] ?? null,
2024
- setTrack: s,
2025
- next: n,
2205
+ currentTrack: t[n] ?? null,
2206
+ setTrack: i,
2207
+ next: o,
2026
2208
  prev: c
2027
2209
  };
2028
- }, lr = () => {
2029
- const e = f(w), { volume: t, muted: o } = C(), r = g(
2030
- (s) => {
2031
- e({ type: "SET_VOLUME", volume: s });
2210
+ }, br = () => {
2211
+ const e = E(L), { volume: t, muted: n } = C(), a = g(
2212
+ (i) => {
2213
+ e({ type: "SET_VOLUME", volume: i });
2032
2214
  },
2033
2215
  [e]
2034
- ), a = g(() => {
2035
- e({ type: "SET_MUTED", muted: !o });
2036
- }, [e, o]);
2037
- return { volume: t, muted: o, setVolume: r, toggleMute: a };
2038
- }, cr = () => {
2039
- const e = f(w), { currentTime: t, duration: o } = re(), r = g(
2040
- (a) => {
2041
- e({ type: "SEEK", time: a });
2216
+ ), r = g(() => {
2217
+ e({ type: "SET_MUTED", muted: !n });
2218
+ }, [e, n]);
2219
+ return { volume: t, muted: n, setVolume: a, toggleMute: r };
2220
+ }, kr = () => {
2221
+ const e = E(L), { currentTime: t, duration: n } = te(), a = g(
2222
+ (r) => {
2223
+ e({ type: "SEEK", time: r });
2042
2224
  },
2043
2225
  [e]
2044
2226
  );
2045
- return { currentTime: t, duration: o, seek: r };
2046
- }, yr = () => {
2047
- const e = sr(), t = ir(), o = lr(), r = cr();
2227
+ return { currentTime: t, duration: n, seek: a };
2228
+ }, Ur = () => {
2229
+ const e = Lr(), t = Nr(), n = br(), a = kr();
2048
2230
  return {
2049
2231
  isPlaying: e.isPlaying,
2050
- volume: o.volume,
2051
- currentTime: r.currentTime,
2052
- duration: r.duration,
2232
+ volume: n.volume,
2233
+ currentTime: a.currentTime,
2234
+ duration: a.duration,
2053
2235
  repeatType: e.repeatType,
2054
- muted: o.muted,
2236
+ muted: n.muted,
2055
2237
  currentTrack: t.currentTrack,
2056
2238
  currentIndex: t.currentIndex,
2057
2239
  playList: t.playList,
@@ -2060,39 +2242,44 @@ const sr = () => {
2060
2242
  togglePlay: e.togglePlay,
2061
2243
  next: t.next,
2062
2244
  prev: t.prev,
2063
- seek: r.seek,
2064
- setVolume: o.setVolume,
2065
- toggleMute: o.toggleMute,
2245
+ seek: a.seek,
2246
+ setVolume: n.setVolume,
2247
+ toggleMute: n.toggleMute,
2066
2248
  setTrack: t.setTrack
2067
2249
  };
2068
- }, vr = () => {
2069
- const { elementRefs: e } = P();
2250
+ }, Or = () => {
2251
+ const { elementRefs: e } = N();
2070
2252
  return {
2071
2253
  audioEl: e == null ? void 0 : e.audioEl,
2072
2254
  waveformInst: e == null ? void 0 : e.waveformInst
2073
2255
  };
2074
2256
  };
2075
- we.CustomComponent = xe;
2076
2257
  export {
2077
- nr as AudioPlayer,
2078
- Ce as AudioPlayerContainer,
2079
- yt as AudioPlayerStateProvider,
2080
- F as DEFAULT_AUDIO_STATE,
2081
- Te as audioAttrsContext,
2082
- w as audioPlayerDispatchContext,
2083
- mt as audioPlayerReducer,
2084
- we as default,
2085
- k as defaultInterfacePlacement,
2086
- pr as defaultInterfacePlacementMaxLength,
2087
- he as playbackContext,
2088
- Ae as resourceContext,
2089
- Ee as timeContext,
2090
- ge as trackContext,
2091
- fe as uiContext,
2092
- yr as useAudioPlayer,
2093
- vr as useAudioPlayerElement,
2094
- sr as useAudioPlayerPlayback,
2095
- cr as useAudioPlayerTime,
2096
- ir as useAudioPlayerTrack,
2097
- lr as useAudioPlayerVolume
2258
+ wr as AudioPlayer,
2259
+ He as AudioPlayerContainer,
2260
+ Kt as AudioPlayerStateProvider,
2261
+ H as DEFAULT_AUDIO_STATE,
2262
+ Ie as audioAttrsContext,
2263
+ L as audioPlayerDispatchContext,
2264
+ Ut as audioPlayerReducer,
2265
+ Dr as default,
2266
+ de as defaultInterfacePlacement,
2267
+ _r as defaultInterfacePlacementMaxLength,
2268
+ Ae as playbackContext,
2269
+ Le as resourceContext,
2270
+ Ne as timeContext,
2271
+ Se as trackContext,
2272
+ we as uiContext,
2273
+ Ot as useAudioAttrsContext,
2274
+ Ur as useAudioPlayer,
2275
+ Or as useAudioPlayerElement,
2276
+ Lr as useAudioPlayerPlayback,
2277
+ kr as useAudioPlayerTime,
2278
+ Nr as useAudioPlayerTrack,
2279
+ br as useAudioPlayerVolume,
2280
+ C as usePlaybackContext,
2281
+ N as useResourceContext,
2282
+ te as useTimeContext,
2283
+ K as useTrackContext,
2284
+ x as useUIContext
2098
2285
  };