markdown-flow-ui 0.1.128 → 0.1.129

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 (68) hide show
  1. package/dist/_virtual/index.cjs8.js +1 -1
  2. package/dist/_virtual/index.cjs9.js +1 -1
  3. package/dist/_virtual/index.es8.js +2 -2
  4. package/dist/_virtual/index.es9.js +2 -2
  5. package/dist/components/MarkdownFlowEditor/components/EditorToolbar.cjs.js.map +1 -1
  6. package/dist/components/MarkdownFlowEditor/components/EditorToolbar.es.js.map +1 -1
  7. package/dist/components/Slide/Player.cjs.js +1 -1
  8. package/dist/components/Slide/Player.cjs.js.map +1 -1
  9. package/dist/components/Slide/Player.d.ts +17 -1
  10. package/dist/components/Slide/Player.es.js +614 -543
  11. package/dist/components/Slide/Player.es.js.map +1 -1
  12. package/dist/components/Slide/Slide.cjs.js +1 -1
  13. package/dist/components/Slide/Slide.cjs.js.map +1 -1
  14. package/dist/components/Slide/Slide.es.js +673 -595
  15. package/dist/components/Slide/Slide.es.js.map +1 -1
  16. package/dist/components/Slide/constants.cjs.js +1 -1
  17. package/dist/components/Slide/constants.cjs.js.map +1 -1
  18. package/dist/components/Slide/constants.d.ts +2 -2
  19. package/dist/components/Slide/constants.es.js +2 -2
  20. package/dist/components/Slide/constants.es.js.map +1 -1
  21. package/dist/components/Slide/useSlide.cjs.js +1 -1
  22. package/dist/components/Slide/useSlide.cjs.js.map +1 -1
  23. package/dist/components/Slide/useSlide.d.ts +2 -0
  24. package/dist/components/Slide/useSlide.es.js +124 -105
  25. package/dist/components/Slide/useSlide.es.js.map +1 -1
  26. package/dist/components/Slide/utils/audioSegments.cjs.js +2 -0
  27. package/dist/components/Slide/utils/audioSegments.cjs.js.map +1 -0
  28. package/dist/components/Slide/utils/audioSegments.d.ts +2 -0
  29. package/dist/components/Slide/utils/audioSegments.es.js +21 -0
  30. package/dist/components/Slide/utils/audioSegments.es.js.map +1 -0
  31. package/dist/components/Slide/utils/audioSegments.test.d.ts +1 -0
  32. package/dist/components/Slide/utils/playbackSequence.cjs.js +1 -1
  33. package/dist/components/Slide/utils/playbackSequence.cjs.js.map +1 -1
  34. package/dist/components/Slide/utils/playbackSequence.d.ts +10 -0
  35. package/dist/components/Slide/utils/playbackSequence.es.js +15 -6
  36. package/dist/components/Slide/utils/playbackSequence.es.js.map +1 -1
  37. package/dist/components/Slide/utils/subtitleCue.cjs.js +2 -2
  38. package/dist/components/Slide/utils/subtitleCue.cjs.js.map +1 -1
  39. package/dist/components/Slide/utils/subtitleCue.d.ts +21 -0
  40. package/dist/components/Slide/utils/subtitleCue.es.js +146 -49
  41. package/dist/components/Slide/utils/subtitleCue.es.js.map +1 -1
  42. package/dist/components/Slide/utils/subtitleJumpNavigation.cjs.js +2 -0
  43. package/dist/components/Slide/utils/subtitleJumpNavigation.cjs.js.map +1 -0
  44. package/dist/components/Slide/utils/subtitleJumpNavigation.d.ts +10 -0
  45. package/dist/components/Slide/utils/subtitleJumpNavigation.es.js +22 -0
  46. package/dist/components/Slide/utils/subtitleJumpNavigation.es.js.map +1 -0
  47. package/dist/components/Slide/utils/subtitleJumpNavigation.test.d.ts +1 -0
  48. package/dist/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
  49. package/dist/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
  50. package/dist/node_modules/classnames/index.cjs.js +1 -1
  51. package/dist/node_modules/classnames/index.es.js +1 -1
  52. package/dist/node_modules/lucide-react/dist/esm/icons/fast-forward.cjs.js +7 -0
  53. package/dist/node_modules/lucide-react/dist/esm/icons/fast-forward.cjs.js.map +1 -0
  54. package/dist/node_modules/lucide-react/dist/esm/icons/fast-forward.es.js +16 -0
  55. package/dist/node_modules/lucide-react/dist/esm/icons/fast-forward.es.js.map +1 -0
  56. package/dist/node_modules/lucide-react/dist/esm/icons/rewind.cjs.js +7 -0
  57. package/dist/node_modules/lucide-react/dist/esm/icons/rewind.cjs.js.map +1 -0
  58. package/dist/node_modules/lucide-react/dist/esm/icons/rewind.es.js +16 -0
  59. package/dist/node_modules/lucide-react/dist/esm/icons/rewind.es.js.map +1 -0
  60. package/package.json +1 -1
  61. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js +0 -7
  62. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js.map +0 -1
  63. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-ccw.es.js +0 -16
  64. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-ccw.es.js.map +0 -1
  65. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js +0 -7
  66. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js.map +0 -1
  67. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-cw.es.js +0 -16
  68. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-cw.es.js.map +0 -1
@@ -1,36 +1,54 @@
1
1
  import { j as n } from "../../_virtual/jsx-runtime.es.js";
2
- import Ht, { memo as $t, useId as Zt, useContext as qt, useRef as c, useState as Re, useMemo as Y, useCallback as r, useEffect as y } from "react";
3
- import { cn as bt } from "../../lib/utils.es.js";
4
- import zt from "./MobilePlayerSettingsSheet.es.js";
5
- import { DEFAULT_SLIDE_PLAYER_TEXTS as It } from "./constants.es.js";
6
- import { DEFAULT_MOBILE_VIEW_MODE as Yt } from "./utils/mobileScreenMode.es.js";
7
- import { hasReachedAudioEnd as Dt } from "./utils/audioCompletion.es.js";
8
- import { PlayerKeyboardShortcutContext as Xt } from "./utils/playerKeyboardShortcutContext.es.js";
9
- import { activatePlayerKeyboardShortcutOwner as Gt, registerPlayerKeyboardShortcutOwner as Qt, isActivePlayerKeyboardShortcutOwner as er, getPlayerKeyboardShortcutAction as tr, shouldIgnorePlayerKeyboardShortcutEvent as rr } from "./utils/playerKeyboardShortcuts.es.js";
10
- import { resolveAudioPlaybackSourceType as nr } from "./utils/playbackSource.es.js";
11
- import { shouldKeepPlayingAfterNavigation as ur } from "./utils/playbackPreference.es.js";
12
- import { toPlayerCustomActionList as sr } from "./utils/playerCustomActions.es.js";
13
- import { suppressPlayerControlsWakeAfterNavigation as St } from "./utils/playerNavigationContext.es.js";
14
- import { isPlaybackTimeCoveredBySegments as gt, resolveSegmentSeekTarget as lr } from "./utils/segmentSeek.es.js";
15
- import { getSubtitleCueJumpTime as ar } from "./utils/subtitleCue.es.js";
2
+ import qt, { memo as er, useId as tr, useContext as rr, useRef as o, useState as Fe, useMemo as te, useCallback as r, useEffect as S } from "react";
3
+ import { cn as Tt } from "../../lib/utils.es.js";
4
+ import nr from "./MobilePlayerSettingsSheet.es.js";
5
+ import { DEFAULT_SLIDE_PLAYER_TEXTS as ur } from "./constants.es.js";
6
+ import { DEFAULT_MOBILE_VIEW_MODE as sr } from "./utils/mobileScreenMode.es.js";
7
+ import { hasReachedAudioEnd as lr } from "./utils/audioCompletion.es.js";
8
+ import { PlayerKeyboardShortcutContext as ar } from "./utils/playerKeyboardShortcutContext.es.js";
9
+ import { activatePlayerKeyboardShortcutOwner as cr, registerPlayerKeyboardShortcutOwner as ir, isActivePlayerKeyboardShortcutOwner as or, getPlayerKeyboardShortcutAction as fr, shouldIgnorePlayerKeyboardShortcutEvent as dr } from "./utils/playerKeyboardShortcuts.es.js";
10
+ import { resolveAudioPlaybackSourceType as mr } from "./utils/playbackSource.es.js";
11
+ import { shouldKeepPlayingAfterNavigation as pr } from "./utils/playbackPreference.es.js";
12
+ import { toPlayerCustomActionList as hr } from "./utils/playerCustomActions.es.js";
13
+ import { suppressPlayerControlsWakeAfterNavigation as We } from "./utils/playerNavigationContext.es.js";
14
+ import { isPlaybackTimeCoveredBySegments as Lt, resolveSegmentSeekTarget as yr } from "./utils/segmentSeek.es.js";
15
+ import { getSortedAudioSegments as vt } from "./utils/audioSegments.es.js";
16
+ import { getSubtitleCueJumpTarget as br, shouldClearSubtitleCueJumpTarget as Sr } from "./utils/subtitleCue.es.js";
16
17
  /* empty css */
17
- import ir from "../../node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.es.js";
18
- import cr from "../../node_modules/lucide-react/dist/esm/icons/volume-2.es.js";
19
- import or from "../../node_modules/lucide-react/dist/esm/icons/captions.es.js";
20
- import fr from "../../node_modules/lucide-react/dist/esm/icons/captions-off.es.js";
21
- import dr from "../../node_modules/lucide-react/dist/esm/icons/skip-back.es.js";
22
- import mr from "../../node_modules/lucide-react/dist/esm/icons/rotate-ccw.es.js";
23
- import pr from "../../node_modules/lucide-react/dist/esm/icons/rotate-cw.es.js";
24
- import hr from "../../node_modules/lucide-react/dist/esm/icons/skip-forward.es.js";
25
- import yr from "../../node_modules/lucide-react/dist/esm/icons/scan-line.es.js";
26
- import br from "../../node_modules/lucide-react/dist/esm/icons/maximize.es.js";
27
- import Sr from "../../node_modules/lucide-react/dist/esm/icons/file-pen-line.es.js";
28
- const _t = /* @__PURE__ */ new Map(), xt = (R) => {
29
- if (typeof window > "u" || !R || _t.has(R))
18
+ import gr from "../../node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.es.js";
19
+ import _r from "../../node_modules/lucide-react/dist/esm/icons/volume-2.es.js";
20
+ import xr from "../../node_modules/lucide-react/dist/esm/icons/skip-back.es.js";
21
+ import kr from "../../node_modules/lucide-react/dist/esm/icons/skip-forward.es.js";
22
+ import wr from "../../node_modules/lucide-react/dist/esm/icons/rewind.es.js";
23
+ import Mr from "../../node_modules/lucide-react/dist/esm/icons/fast-forward.es.js";
24
+ import Cr from "../../node_modules/lucide-react/dist/esm/icons/captions.es.js";
25
+ import Tr from "../../node_modules/lucide-react/dist/esm/icons/captions-off.es.js";
26
+ import Lr from "../../node_modules/lucide-react/dist/esm/icons/scan-line.es.js";
27
+ import vr from "../../node_modules/lucide-react/dist/esm/icons/maximize.es.js";
28
+ import Ar from "../../node_modules/lucide-react/dist/esm/icons/file-pen-line.es.js";
29
+ const At = /* @__PURE__ */ new Map(), jt = (f) => {
30
+ if (typeof window > "u" || !f || At.has(f))
30
31
  return;
31
- const N = window.document.createElement("audio");
32
- N.preload = "auto", N.setAttribute("playsinline", "true"), N.src = R, N.load(), _t.set(R, N);
33
- }, gr = () => /* @__PURE__ */ n.jsxs(
32
+ const d = window.document.createElement("audio");
33
+ d.preload = "auto", d.setAttribute("playsinline", "true"), d.src = f, d.load(), At.set(f, d);
34
+ }, jr = (f, d) => d !== null && d.audioList === f && d.subtitleCueLists.length === f.length && f.every((a, _) => {
35
+ const x = a.element?.subtitle_cues;
36
+ return d.subtitleCueLists[_] === x && d.subtitleCueLengths[_] === (x?.length ?? 0);
37
+ }), Nr = (f) => {
38
+ const d = f.map(
39
+ (a) => a.element?.subtitle_cues
40
+ );
41
+ return {
42
+ audioList: f,
43
+ subtitleCueLists: d,
44
+ subtitleCueLengths: d.map(
45
+ (a) => a?.length ?? 0
46
+ ),
47
+ tracks: d.map((a) => ({
48
+ subtitleCues: a ?? []
49
+ }))
50
+ };
51
+ }, Er = () => /* @__PURE__ */ n.jsxs(
34
52
  "svg",
35
53
  {
36
54
  xmlns: "http://www.w3.org/2000/svg",
@@ -49,7 +67,7 @@ const _t = /* @__PURE__ */ new Map(), xt = (R) => {
49
67
  /* @__PURE__ */ n.jsx("path", { d: "M12 10H16V24H12V10ZM18 10H22V24H18V10Z", fill: "white" })
50
68
  ]
51
69
  }
52
- ), _r = () => /* @__PURE__ */ n.jsxs(
70
+ ), Rr = () => /* @__PURE__ */ n.jsxs(
53
71
  "svg",
54
72
  {
55
73
  xmlns: "http://www.w3.org/2000/svg",
@@ -68,7 +86,7 @@ const _t = /* @__PURE__ */ new Map(), xt = (R) => {
68
86
  /* @__PURE__ */ n.jsx("path", { d: "M13.3333 10L23.3333 16.6667L13.3333 23.3333V10Z", fill: "white" })
69
87
  ]
70
88
  }
71
- ), H = {
89
+ ), J = {
72
90
  fullscreen: "F",
73
91
  next: "→",
74
92
  nextSubtitle: "Shift+→",
@@ -77,386 +95,422 @@ const _t = /* @__PURE__ */ new Map(), xt = (R) => {
77
95
  previous: "←",
78
96
  previousSubtitle: "Shift+←",
79
97
  subtitle: "C"
80
- }, xr = 250, kr = (R, N) => R ? `${R} (${N})` : N, wr = ({
81
- audioList: R = [],
82
- className: N,
83
- currentAudioIndex: k = -1,
84
- defaultPlaying: L = !0,
85
- isPlaybackPaused: T = !1,
86
- isAutoAdvanceEnabled: $ = !0,
98
+ }, Kr = 250, Ur = (f, d) => f ? `${f} (${d})` : d, Fr = ({
99
+ audioList: f = [],
100
+ className: d,
101
+ currentAudioIndex: a = -1,
102
+ defaultPlaying: _ = !0,
103
+ isPlaybackPaused: x = !1,
104
+ isAutoAdvanceEnabled: Z = !0,
87
105
  useAutoAdvanceToggle: F = !1,
88
- onLoadingChange: je,
89
- onPlaybackPreferenceChange: Ce,
90
- onPlaybackStarted: Ne,
91
- onPlaybackTimeChange: ie,
92
- onSubtitleToggle: ee,
93
- onPrev: ce,
94
- onNext: oe,
95
- onFullscreen: te,
96
- isFullscreen: Ee = !1,
97
- mobileViewMode: kt = Yt,
98
- settingsPortalContainer: wt,
99
- onMobileViewModeChange: Ke,
100
- onEnded: Ue,
101
- onAutoAdvanceToggle: Fe,
102
- onInteractionToggle: fe,
103
- hasInteraction: _e = !1,
104
- isInteractionOpen: re = !1,
105
- isSubtitleEnabled: xe = !0,
106
- prevDisabled: ke = !1,
107
- nextDisabled: we = !1,
108
- showControls: Me = !0,
109
- enableKeyboardShortcuts: Mt = !0,
110
- customActions: We,
111
- customActionContext: Pe,
112
- texts: Be,
113
- onFocusCapture: Oe,
114
- onPointerDown: Ve,
115
- ...Lt
106
+ onLoadingChange: Pe,
107
+ onPlaybackPreferenceChange: Be,
108
+ onPlaybackStarted: Oe,
109
+ onPlaybackTimeChange: oe,
110
+ onSubtitleToggle: re,
111
+ onPrev: fe,
112
+ onNext: de,
113
+ onSubtitleJump: me,
114
+ canJumpToSubtitleTarget: Te,
115
+ onFullscreen: ne,
116
+ isFullscreen: Ve = !1,
117
+ mobileViewMode: Nt = sr,
118
+ settingsPortalContainer: Et,
119
+ onMobileViewModeChange: He,
120
+ onEnded: $e,
121
+ onAutoAdvanceToggle: Je,
122
+ onInteractionToggle: pe,
123
+ hasInteraction: Le = !1,
124
+ isInteractionOpen: ue = !1,
125
+ isSubtitleEnabled: ve = !0,
126
+ prevDisabled: Ae = !1,
127
+ nextDisabled: je = !1,
128
+ showControls: Ne = !0,
129
+ enableKeyboardShortcuts: Rt = !0,
130
+ subtitleSeekRequest: O = null,
131
+ customActions: Ze,
132
+ customActionContext: ze,
133
+ texts: Ye,
134
+ onFocusCapture: De,
135
+ onPointerDown: Xe,
136
+ ...Kt
116
137
  }) => {
117
- const Tt = Zt(), Je = qt(Xt), _ = c(null), He = c(re), E = c(null), $e = c(null), K = c(0), f = c(null), de = c(void 0), j = c([]), ne = c(
118
- F ? $ : L
119
- ), ue = c(!1), Ze = c(!1), b = c(!1), U = c(null), Z = c(null), A = c(!1), l = c(!1), S = c(null), C = c(!1), q = c(null), me = c(0), qe = c(() => {
120
- }), pe = c(null), W = c("unknown"), [he, d] = Re(L), [ze, D] = Re(!1), [X, At] = Re({
138
+ const Ut = tr(), Ge = rr(ar), M = o(null), Qe = o(ue), R = o(null), Ie = o(null), K = o(0), m = o(null), he = o(void 0), j = o([]), se = o(
139
+ F ? Z : _
140
+ ), le = o(!1), qe = o(!1), k = o(!1), U = o(null), z = o(null), v = o(!1), c = o(!1), w = o(null), N = o(!1), Y = o(null), ye = o(0), et = o(() => {
141
+ }), be = o(null), ae = o(null), tt = o(null), rt = o(null), W = o("unknown"), [Se, h] = Fe(_), [nt, Q] = Fe(!1), [I, Ft] = Fe({
121
142
  next: !1,
122
143
  previous: !1
123
- }), z = Je?.ownerId ?? Tt, P = Mt && (Je?.enabled ?? !0), o = k >= 0 ? R[k] : void 0, g = o?.audioUrl, w = Y(
124
- () => [...o?.audioSegments ?? []].sort(
125
- (e, t) => e.segment_index - t.segment_index
126
- ),
127
- [o?.audioSegments]
128
- ), Ie = Y(
129
- () => o?.element?.subtitle_cues ?? [],
130
- [o?.element?.subtitle_cues]
131
- ), Ye = Y(
132
- () => sr(We, Pe),
133
- [Pe, We]
134
- ), De = Ye.length + 7, vt = Y(
144
+ }), D = Ge?.ownerId ?? Ut, P = Rt && (Ge?.enabled ?? !0), p = a >= 0 ? f[a] : void 0, T = p?.audioUrl, ut = p?.audioSegments, Wt = ut?.length ?? 0, E = te(
145
+ () => vt(p),
146
+ [p, Wt, ut]
147
+ );
148
+ let ge = rt.current;
149
+ jr(f, ge) || (ge = Nr(f), rt.current = ge);
150
+ const st = ge.tracks, lt = te(
151
+ () => hr(Ze, ze),
152
+ [ze, Ze]
153
+ ), at = lt.length + 7, Pt = te(
135
154
  () => ({
136
- "--slide-player-mobile-control-count": String(De)
155
+ "--slide-player-mobile-control-count": String(at)
137
156
  }),
138
- [De]
139
- ), a = Y(
157
+ [at]
158
+ ), i = te(
140
159
  () => ({
141
- ...It,
142
- ...Be
160
+ ...ur,
161
+ ...Ye
143
162
  }),
144
- [Be]
145
- ), Le = Y(() => o ? o.audioKey ?? `${String(o.sequenceNumber ?? "none")}:${String(o.audioUrl ?? "")}` : "none", [o]), Rt = F ? $ : he, Xe = F ? $ ? a.pauseAutoplayLabel : a.playAutoplayLabel : he ? a.pauseLabel : a.playLabel, Ge = Ee ? a.exitFullscreenLabel : a.enterFullscreenLabel, O = r(
163
+ [Ye]
164
+ ), Ee = te(() => p ? p.audioKey ?? `${String(p.sequenceNumber ?? "none")}:${String(p.audioUrl ?? "")}` : "none", [p]), Bt = F ? Z : Se, ct = F ? Z ? i.pauseAutoplayLabel : i.playAutoplayLabel : Se ? i.pauseLabel : i.playLabel, it = Ve ? i.exitFullscreenLabel : i.enterFullscreenLabel, V = r(
146
165
  (e, t, s) => ({
147
166
  ariaKeyShortcuts: P ? s : void 0,
148
- title: P ? kr(e, t) : e
167
+ title: P ? Ur(e, t) : e
149
168
  }),
150
169
  [P]
151
- ), Qe = O(
152
- a.subtitleToggleAriaLabel,
153
- H.subtitle,
170
+ ), ot = V(
171
+ i.subtitleToggleAriaLabel,
172
+ J.subtitle,
154
173
  "c"
155
- ), et = O(
156
- a.previousLabel,
157
- H.previous,
174
+ ), ft = V(
175
+ i.previousLabel,
176
+ J.previous,
158
177
  "ArrowLeft"
159
- ), tt = O(
160
- a.previousSubtitleLabel,
161
- H.previousSubtitle,
178
+ ), dt = V(
179
+ i.previousSubtitleLabel,
180
+ J.previousSubtitle,
162
181
  "Shift+ArrowLeft"
163
- ), rt = O(
164
- Xe,
165
- H.playback,
182
+ ), mt = V(
183
+ ct,
184
+ J.playback,
166
185
  "Space"
167
- ), nt = O(
168
- a.nextLabel,
169
- H.next,
186
+ ), pt = V(
187
+ i.nextLabel,
188
+ J.next,
170
189
  "ArrowRight"
171
- ), ut = O(
172
- a.nextSubtitleLabel,
173
- H.nextSubtitle,
190
+ ), ht = V(
191
+ i.nextSubtitleLabel,
192
+ J.nextSubtitle,
174
193
  "Shift+ArrowRight"
175
- ), st = O(
176
- Ge,
177
- H.fullscreen,
194
+ ), yt = V(
195
+ it,
196
+ J.fullscreen,
178
197
  "f"
179
- ), lt = O(
180
- a.notesLabel,
181
- H.notes,
198
+ ), bt = V(
199
+ i.notesLabel,
200
+ J.notes,
182
201
  "n"
183
- ), ye = r(() => {
184
- P && Gt(z);
185
- }, [z, P]), jt = r(
202
+ ), _e = r(() => {
203
+ P && cr(D);
204
+ }, [D, P]), Ot = r(
186
205
  (e) => {
187
- ye(), Ve?.(e);
206
+ _e(), Xe?.(e);
188
207
  },
189
- [ye, Ve]
190
- ), Ct = r(
208
+ [_e, Xe]
209
+ ), Vt = r(
191
210
  (e) => {
192
- ye(), Oe?.(e);
211
+ _e(), De?.(e);
193
212
  },
194
- [ye, Oe]
213
+ [_e, De]
195
214
  );
196
- y(() => {
197
- de.current = o;
198
- }, [o]), y(() => {
199
- ne.current = F ? $ : L;
200
- }, [L, $, F]), y(() => {
201
- Me || D(!1);
202
- }, [Me]), y(() => {
203
- !He.current && re && D(!1), He.current = re;
204
- }, [re]), y(() => {
205
- j.current = w;
206
- }, [w]), y(() => {
207
- const e = o?.audioUrl, t = k >= 0 ? R[k + 1]?.audioUrl : void 0;
208
- xt(e), xt(t);
209
- }, [R, o?.audioUrl, k]);
210
- const u = r(
215
+ S(() => {
216
+ he.current = p;
217
+ }, [p]), S(() => {
218
+ se.current = F ? Z : _;
219
+ }, [_, Z, F]), S(() => {
220
+ Ne || Q(!1);
221
+ }, [Ne]), S(() => {
222
+ !Qe.current && ue && Q(!1), Qe.current = ue;
223
+ }, [ue]), S(() => {
224
+ j.current = E;
225
+ }, [E]), S(() => {
226
+ const e = p?.audioUrl, t = a >= 0 ? f[a + 1]?.audioUrl : void 0;
227
+ jt(e), jt(t);
228
+ }, [f, p?.audioUrl, a]);
229
+ const l = r(
211
230
  (e, t = null) => {
212
- Ze.current === e && (!e || t === null) || (Ze.current = e, je?.({
231
+ qe.current === e && (!e || t === null) || (qe.current = e, Pe?.({
213
232
  loading: e,
214
233
  reason: e ? t : null
215
234
  }));
216
235
  },
217
- [je]
236
+ [Pe]
218
237
  ), B = r(
219
238
  (e) => {
220
- ne.current = e, Ce?.(e);
239
+ se.current = e, Be?.(e);
221
240
  },
222
- [Ce]
223
- ), se = r(() => F ? {
224
- shouldContinuePlayback: ne.current
241
+ [Be]
242
+ ), X = r(() => F ? {
243
+ shouldContinuePlayback: se.current
225
244
  } : {
226
- shouldContinuePlayback: ur({
227
- defaultPlaying: ne.current,
228
- isPausedByUser: b.current
245
+ shouldContinuePlayback: pr({
246
+ defaultPlaying: se.current,
247
+ isPausedByUser: k.current
229
248
  })
230
- }, [F]), at = r((e) => e instanceof DOMException ? e.name === "NotAllowedError" || e.name === "SecurityError" : !1, []), V = r(() => L && !T && !b.current && W.current !== "blocked", [L, T]), it = r((e) => e ? e.startsWith("data:") ? e : `data:audio/mpeg;base64,${e}` : "", []), ct = r(() => {
231
- const e = f.current;
249
+ }, [F]), St = r((e) => e instanceof DOMException ? e.name === "NotAllowedError" || e.name === "SecurityError" : !1, []), H = r(() => _ && !x && !k.current && W.current !== "blocked", [_, x]), gt = r((e) => e ? e.startsWith("data:") ? e : `data:audio/mpeg;base64,${e}` : "", []), _t = r(() => {
250
+ const e = m.current;
232
251
  return e == null || e <= 0 ? 0 : j.current.slice(0, e).reduce(
233
252
  (t, s) => t + Math.max(Number(s.duration_ms ?? 0), 0),
234
253
  0
235
254
  ) / 1e3;
236
- }, []), I = r((e) => e <= 0 ? 0 : j.current.slice(0, e).reduce(
255
+ }, []), G = r((e) => e <= 0 ? 0 : j.current.slice(0, e).reduce(
237
256
  (t, s) => t + Math.max(Number(s.duration_ms ?? 0), 0),
238
257
  0
239
- ), []), ot = r(
240
- (e) => !o || T ? !1 : g ? !0 : gt(w, e),
241
- [o, w, g, T]
242
- ), le = r(
243
- (e, t) => {
244
- const s = ar({
258
+ ), []), xe = r(
259
+ (e, t) => !e || x ? !1 : e.audioUrl ? !0 : Lt(
260
+ vt(e),
261
+ t
262
+ ),
263
+ [x]
264
+ ), ce = r(
265
+ (e, t, s = {}) => {
266
+ const u = br({
267
+ currentAudioIndex: a,
245
268
  currentTimeMs: t,
246
269
  direction: e,
247
- subtitleCues: Ie
270
+ excludeTarget: s.excludeTarget,
271
+ tracks: st
248
272
  });
249
- return s === null || !ot(s) ? null : s;
273
+ return !u || !xe(
274
+ f[u.audioIndex],
275
+ u.timeMs
276
+ ) || u.audioIndex !== a && (!me || Te && !Te(u)) ? null : u;
250
277
  },
251
- [ot, Ie]
252
- ), Te = r(
278
+ [
279
+ f,
280
+ Te,
281
+ xe,
282
+ a,
283
+ me,
284
+ st
285
+ ]
286
+ ), Re = r(
253
287
  (e, t = !1) => {
254
288
  const s = Math.max(Number(e), 0);
255
- if (!t && pe.current !== null && Math.abs(
256
- s - pe.current
257
- ) < xr)
289
+ if (!t && be.current !== null && Math.abs(
290
+ s - be.current
291
+ ) < Kr)
258
292
  return;
259
- pe.current = s;
260
- const i = {
261
- previous: le("previous", s) !== null,
262
- next: le("next", s) !== null
293
+ be.current = s;
294
+ const u = {
295
+ previous: ce("previous", s) !== null,
296
+ next: ce("next", s) !== null
263
297
  };
264
- At((p) => p.previous === i.previous && p.next === i.next ? p : i);
298
+ Ft((b) => b.previous === u.previous && b.next === u.next ? b : u);
265
299
  },
266
- [le]
300
+ [ce]
267
301
  );
268
- y(() => {
269
- qe.current = Te, Te(me.current, !0);
270
- }, [Te]);
271
- const be = r(() => {
272
- const e = _.current;
273
- return e ? U.current === "segment" ? I(K.current) + Math.max(e.currentTime, 0) * 1e3 : S.current !== null && e.readyState === 0 ? S.current * 1e3 : Math.max(e.currentTime, 0) * 1e3 : f.current != null ? I(f.current) : 0;
274
- }, [I]), x = r(
302
+ S(() => {
303
+ et.current = Re, Re(ye.current, !0);
304
+ }, [Re]);
305
+ const ke = r(() => {
306
+ const e = M.current;
307
+ return e ? U.current === "segment" ? G(K.current) + Math.max(e.currentTime, 0) * 1e3 : w.current !== null && e.readyState === 0 ? w.current * 1e3 : Math.max(e.currentTime, 0) * 1e3 : m.current != null ? G(m.current) : 0;
308
+ }, [G]), C = r(
275
309
  (e) => {
276
310
  const t = Math.max(e, 0);
277
- me.current !== t && (me.current = t, ie?.(t), qe.current(t));
311
+ ye.current !== t && (ye.current = t, Sr({
312
+ currentAudioIndex: a,
313
+ currentTimeMs: t,
314
+ target: ae.current
315
+ }) && (ae.current = null), oe?.(t), et.current(t));
278
316
  },
279
- [ie]
280
- ), m = r(() => {
281
- x(be());
282
- }, [be, x]), h = r(() => {
283
- typeof window > "u" || q.current === null || (window.cancelAnimationFrame(q.current), q.current = null);
284
- }, []), ft = r(() => {
285
- if (typeof window > "u" || q.current !== null)
317
+ [a, oe]
318
+ ), y = r(() => {
319
+ C(ke());
320
+ }, [ke, C]), g = r(() => {
321
+ typeof window > "u" || Y.current === null || (window.cancelAnimationFrame(Y.current), Y.current = null);
322
+ }, []), xt = r(() => {
323
+ if (typeof window > "u" || Y.current !== null)
286
324
  return;
287
325
  const e = () => {
288
- m();
289
- const t = _.current;
326
+ y();
327
+ const t = M.current;
290
328
  if (!t || t.paused || t.ended) {
291
- q.current = null;
329
+ Y.current = null;
292
330
  return;
293
331
  }
294
- q.current = window.requestAnimationFrame(e);
332
+ Y.current = window.requestAnimationFrame(e);
295
333
  };
296
- q.current = window.requestAnimationFrame(e);
297
- }, [m]), G = r(() => {
298
- const e = _.current;
299
- e && (h(), l.current = !1, b.current = !1, ue.current = !1, U.current = null, S.current = null, A.current = !1, C.current = !1, Z.current = null, e.pause(), e.removeAttribute("src"), e.load(), E.current = null, K.current = 0, f.current = null, x(0), d(!1), u(!1));
300
- }, [x, h, u]), M = r(
334
+ Y.current = window.requestAnimationFrame(e);
335
+ }, [y]), q = r(() => {
336
+ const e = M.current;
337
+ e && (g(), c.current = !1, k.current = !1, le.current = !1, U.current = null, w.current = null, v.current = !1, N.current = !1, z.current = null, e.pause(), e.removeAttribute("src"), e.load(), R.current = null, K.current = 0, m.current = null, C(0), h(!1), l(!1));
338
+ }, [C, g, l]), L = r(
301
339
  (e) => {
302
- const t = _.current;
340
+ const t = M.current;
303
341
  if (!t)
304
342
  return !1;
305
343
  const s = t.play();
306
344
  return s && typeof s.then == "function" && s.then(() => {
307
- W.current === "unknown" && (W.current = "auto"), l.current = !1, C.current = !1;
308
- }).catch((i) => {
309
- W.current === "unknown" && at(i) && (W.current = "blocked", l.current = !1, u(!1)), C.current = !1, d(!1);
345
+ W.current === "unknown" && (W.current = "auto"), c.current = !1, N.current = !1;
346
+ }).catch((u) => {
347
+ W.current === "unknown" && St(u) && (W.current = "blocked", c.current = !1, l(!1)), N.current = !1, h(!1);
310
348
  }), !0;
311
349
  },
312
- [at, u]
313
- ), v = r(
350
+ [St, l]
351
+ ), A = r(
314
352
  (e, t, s = {}) => {
315
- const i = _.current, p = j.current[e];
316
- if (!i || !p)
353
+ const u = M.current, b = j.current[e];
354
+ if (!u || !b)
317
355
  return !1;
318
- const J = it(p.audio_data), ge = Math.max(
356
+ const $ = gt(b.audio_data), Ce = Math.max(
319
357
  Number(s.seekTimeSeconds ?? 0),
320
358
  0
321
359
  );
322
- K.current = e, f.current = null, A.current = !1, C.current = !0, Z.current = "segment", x(
323
- I(e) + ge * 1e3
360
+ K.current = e, m.current = null, v.current = !1, N.current = !0, z.current = "segment", C(
361
+ G(e) + Ce * 1e3
324
362
  );
325
- const yt = s.shouldResume ?? V();
326
- l.current = yt, u(!1);
327
- const Jt = E.current !== J;
328
- return U.current = "segment", Jt && (i.pause(), i.removeAttribute("src"), i.load(), E.current = J, i.src = J, i.load()), S.current = ge, i.readyState > 0 && (i.currentTime = ge, S.current = null), yt ? M(`start-segment:${t}`) : (l.current = !1, C.current = !1, i.pause(), d(!1), !0);
363
+ const Ct = s.shouldResume ?? H();
364
+ c.current = Ct, l(!1);
365
+ const It = R.current !== $;
366
+ return U.current = "segment", It && (u.pause(), u.removeAttribute("src"), u.load(), R.current = $, u.src = $, u.load()), w.current = Ce, u.readyState > 0 && (u.currentTime = Ce, w.current = null), Ct ? L(`start-segment:${t}`) : (c.current = !1, N.current = !1, u.pause(), h(!1), !0);
329
367
  },
330
368
  [
331
- V,
332
- it,
333
- I,
334
- x,
335
- M,
336
- u
369
+ H,
370
+ gt,
371
+ G,
372
+ C,
373
+ L,
374
+ l
337
375
  ]
338
- ), dt = r(
376
+ ), we = r(
339
377
  (e) => {
340
- const t = _.current;
341
- if (!t || !o || T)
378
+ const t = M.current;
379
+ if (!t || !p || x)
342
380
  return !1;
343
- const s = Math.max(Number(e), 0), i = !t.paused && !t.ended || l.current || C.current || f.current !== null && ne.current && !b.current, p = gt(
381
+ const s = Math.max(Number(e), 0), u = !t.paused && !t.ended || c.current || N.current || m.current !== null && se.current && !k.current, b = Lt(
344
382
  j.current,
345
383
  s
346
- ) ? lr(
384
+ ) ? yr(
347
385
  j.current,
348
386
  s
349
387
  ) : null;
350
- if (pe.current = null, h(), l.current = i, u(!1), i && (W.current = "manual", b.current = !1, B(!0)), p && (U.current === "segment" || !g))
351
- return v(
352
- p.segmentIndex,
388
+ if (be.current = null, g(), c.current = u, l(!1), u && (W.current = "manual", k.current = !1, B(!0)), b && (U.current === "segment" || !T))
389
+ return A(
390
+ b.segmentIndex,
353
391
  "subtitle-seek-segment",
354
392
  {
355
- seekTimeSeconds: p.segmentTimeSeconds,
356
- shouldResume: i
393
+ seekTimeSeconds: b.segmentTimeSeconds,
394
+ shouldResume: u
357
395
  }
358
396
  );
359
- if (g) {
360
- const J = s / 1e3;
361
- return E.current !== g && (t.pause(), t.removeAttribute("src"), t.load(), E.current = g, U.current = "url", Z.current = "url", t.src = g, t.load()), S.current = J, x(s), t.readyState > 0 && (t.currentTime = J, S.current = null), i ? M("subtitle-seek-url") : (l.current = !1, t.pause(), d(!1), !0);
397
+ if (T) {
398
+ const $ = s / 1e3;
399
+ return R.current !== T && (t.pause(), t.removeAttribute("src"), t.load(), R.current = T, U.current = "url", z.current = "url", t.src = T, t.load()), w.current = $, C(s), t.readyState > 0 && (t.currentTime = $, w.current = null), u ? L("subtitle-seek-url") : (c.current = !1, t.pause(), h(!1), !0);
362
400
  }
363
401
  return !1;
364
402
  },
365
403
  [
366
- o,
367
- g,
404
+ p,
368
405
  T,
369
406
  x,
370
- v,
371
- h,
372
- M,
373
- u,
407
+ C,
408
+ A,
409
+ g,
410
+ L,
411
+ l,
374
412
  B
375
413
  ]
376
- ), ae = r(
414
+ ), ie = r(
377
415
  (e) => {
378
- const t = le(
416
+ const t = ce(
379
417
  e,
380
- be()
418
+ ke(),
419
+ {
420
+ excludeTarget: e === "previous" ? ae.current : null
421
+ }
422
+ );
423
+ if (t === null)
424
+ return !1;
425
+ if (t.audioIndex === a) {
426
+ const u = we(t.timeMs);
427
+ return u && (ae.current = t), u;
428
+ }
429
+ const s = !!me?.(
430
+ t,
431
+ We(X())
381
432
  );
382
- return t === null ? !1 : dt(t);
433
+ return s && (ae.current = t), s;
383
434
  },
384
435
  [
385
- be,
386
- le,
387
- dt
436
+ a,
437
+ ke,
438
+ X,
439
+ ce,
440
+ me,
441
+ we
388
442
  ]
389
- ), Q = r(
443
+ ), ee = r(
390
444
  (e) => {
391
- h(), l.current = !1, A.current = !1, C.current = !1, m(), d(!1), u(!1), k >= 0 && Ue?.(k);
445
+ g(), c.current = !1, v.current = !1, N.current = !1, y(), h(!1), l(!1), a >= 0 && $e?.(a);
392
446
  },
393
447
  [
394
- k,
395
- Ue,
396
- h,
397
- m,
398
- u
448
+ a,
449
+ $e,
450
+ g,
451
+ y,
452
+ l
399
453
  ]
400
- ), Se = r(
454
+ ), Me = r(
401
455
  (e) => {
402
- const t = _.current;
403
- return !t || U.current !== "url" || !Dt({
456
+ const t = M.current;
457
+ return !t || U.current !== "url" || !lr({
404
458
  currentTimeSeconds: Math.max(t.currentTime, 0),
405
459
  durationSeconds: t.duration
406
- }) ? !1 : (l.current = !1, t.pause(), Q(e), !0);
460
+ }) ? !1 : (c.current = !1, t.pause(), ee(e), !0);
407
461
  },
408
- [Q]
409
- ), mt = r(() => {
410
- const e = K.current + 1, t = j.current, s = t[e], i = de.current, p = t.some((J) => J.is_final);
462
+ [ee]
463
+ ), kt = r(() => {
464
+ const e = K.current + 1, t = j.current, s = t[e], u = he.current, b = t.some(($) => $.is_final);
411
465
  if (s) {
412
- v(e, "ended");
466
+ A(e, "ended");
413
467
  return;
414
468
  }
415
- if (i?.isAudioStreaming || !p) {
416
- K.current = e, f.current = e, A.current = !0, l.current = L, x(I(e)), d(!1), u(!0, "waitingForMoreAudio");
469
+ if (u?.isAudioStreaming || !b) {
470
+ K.current = e, m.current = e, v.current = !0, c.current = _, C(G(e)), h(!1), l(!0, "waitingForMoreAudio");
417
471
  return;
418
472
  }
419
- Q("segments-completed");
473
+ ee("segments-completed");
420
474
  }, [
421
- L,
422
- Q,
423
- I,
424
- x,
425
- v,
426
- u
475
+ _,
476
+ ee,
477
+ G,
478
+ C,
479
+ A,
480
+ l
427
481
  ]);
428
- y(() => {
429
- if ($e.current === Le)
482
+ S(() => {
483
+ if (Ie.current === Ee)
430
484
  return;
431
- $e.current = Le, K.current = 0, f.current = null, A.current = !1, b.current = !1, ue.current = !1, l.current = !1, C.current = !1, U.current = null, Z.current = null, E.current = null, h(), x(0), u(!1);
432
- const e = _.current;
433
- e && (e.pause(), e.removeAttribute("src"), e.load(), d(!1));
485
+ Ie.current = Ee, K.current = 0, m.current = null, v.current = !1, k.current = !1, le.current = !1, c.current = !1, N.current = !1, U.current = null, z.current = null, R.current = null, g(), C(0), l(!1);
486
+ const e = M.current;
487
+ e && (e.pause(), e.removeAttribute("src"), e.load(), h(!1));
434
488
  }, [
435
- k,
436
- Le,
437
- w.length,
489
+ a,
490
+ Ee,
491
+ E.length,
492
+ T,
493
+ C,
438
494
  g,
439
- x,
440
- h,
441
- u
442
- ]), y(() => {
443
- const e = _.current;
495
+ l
496
+ ]), S(() => {
497
+ const e = M.current;
444
498
  if (e) {
445
- if (T) {
446
- ue.current = !!(de.current && !b.current && (!e.paused || l.current || f.current !== null)), l.current = !1, u(!1), e.pause(), d(!1);
499
+ if (x) {
500
+ le.current = !!(he.current && !k.current && (!e.paused || c.current || m.current !== null)), c.current = !1, l(!1), e.pause(), h(!1);
447
501
  return;
448
502
  }
449
- if (!(!ue.current || !de.current || b.current)) {
450
- if (ue.current = !1, f.current !== null) {
451
- if (f.current < j.current.length) {
452
- v(f.current, "external-resume");
503
+ if (!(!le.current || !he.current || k.current)) {
504
+ if (le.current = !1, m.current !== null) {
505
+ if (m.current < j.current.length) {
506
+ A(m.current, "external-resume");
453
507
  return;
454
508
  }
455
- l.current = !0, u(!0, "waitingForMoreAudio");
509
+ c.current = !0, l(!0, "waitingForMoreAudio");
456
510
  return;
457
511
  }
458
- if (!E.current && j.current.length > 0) {
459
- v(
512
+ if (!R.current && j.current.length > 0) {
513
+ A(
460
514
  Math.min(
461
515
  K.current,
462
516
  j.current.length - 1
@@ -465,296 +519,307 @@ const _t = /* @__PURE__ */ new Map(), xt = (R) => {
465
519
  );
466
520
  return;
467
521
  }
468
- e.paused && (l.current = !0, M("external-resume"));
522
+ e.paused && (c.current = !0, L("external-resume"));
469
523
  }
470
524
  }
471
525
  }, [
472
- T,
473
- v,
474
- M,
475
- u
476
- ]), y(() => {
477
- const e = _.current;
526
+ x,
527
+ A,
528
+ L,
529
+ l
530
+ ]), S(() => {
531
+ const e = M.current;
478
532
  if (!e)
479
533
  return;
480
- if (!o) {
481
- G();
534
+ if (!p) {
535
+ q();
482
536
  return;
483
537
  }
484
- if (T) {
485
- l.current = !1, u(!1), e.pause(), d(!1);
538
+ if (x) {
539
+ c.current = !1, l(!1), e.pause(), h(!1);
486
540
  return;
487
541
  }
488
- const t = nr({
542
+ const t = mr({
489
543
  activeSourceType: U.current,
490
- hasAudioUrl: !!g,
491
- segmentCount: w.length,
492
- preferredSourceType: Z.current,
493
- waitingSegmentIndex: f.current
544
+ hasAudioUrl: !!T,
545
+ segmentCount: E.length,
546
+ preferredSourceType: z.current,
547
+ waitingSegmentIndex: m.current
494
548
  });
495
- if (t && Z.current !== t && (Z.current = t), t === "url" && g) {
496
- const s = E.current !== g, i = V();
549
+ if (t && z.current !== t && (z.current = t), t === "url" && T) {
550
+ const s = R.current !== T, u = H();
497
551
  if (s) {
498
- const p = f.current !== null ? ct() : 0;
499
- e.pause(), e.removeAttribute("src"), e.load(), E.current = g, U.current = "url", e.src = g, e.load(), S.current = p, x(p * 1e3), e.readyState > 0 && (e.currentTime = p, S.current = null);
552
+ const b = m.current !== null ? _t() : 0;
553
+ e.pause(), e.removeAttribute("src"), e.load(), R.current = T, U.current = "url", e.src = T, e.load(), w.current = b, C(b * 1e3), e.readyState > 0 && (e.currentTime = b, w.current = null);
500
554
  }
501
- if (l.current = i, A.current = !1, C.current = !1, u(!1), !i) {
502
- l.current = !1, e.pause(), d(!1);
555
+ if (c.current = u, v.current = !1, N.current = !1, l(!1), !u) {
556
+ c.current = !1, e.pause(), h(!1);
503
557
  return;
504
558
  }
505
- M(s ? "sync-url-init" : "sync-url");
559
+ L(s ? "sync-url-init" : "sync-url");
506
560
  return;
507
561
  }
508
- if (t === "segment" && f.current !== null) {
509
- if (f.current < w.length) {
510
- if (b.current) {
511
- d(!1), u(!1);
562
+ if (t === "segment" && m.current !== null) {
563
+ if (m.current < E.length) {
564
+ if (k.current) {
565
+ h(!1), l(!1);
512
566
  return;
513
567
  }
514
- v(f.current, "wait-resume");
568
+ A(m.current, "wait-resume");
515
569
  return;
516
570
  }
517
- A.current = !0, l.current = V(), d(!1), u(V());
571
+ v.current = !0, c.current = H(), h(!1), l(H());
518
572
  return;
519
573
  }
520
- if (t === "segment" && !w.length) {
521
- if (o.isAudioStreaming) {
522
- f.current = K.current, A.current = !0, l.current = V(), d(!1), u(V());
574
+ if (t === "segment" && !E.length) {
575
+ if (p.isAudioStreaming) {
576
+ m.current = K.current, v.current = !0, c.current = H(), h(!1), l(H());
523
577
  return;
524
578
  }
525
- G();
579
+ q();
526
580
  return;
527
581
  }
528
- if (t === "segment" && !E.current) {
529
- v(
582
+ if (t === "segment" && !R.current) {
583
+ A(
530
584
  Math.min(
531
585
  K.current,
532
- w.length - 1
586
+ E.length - 1
533
587
  ),
534
588
  "effect-init"
535
589
  );
536
590
  return;
537
591
  }
538
592
  if (t !== "segment") {
539
- G();
593
+ q();
540
594
  return;
541
595
  }
542
- if (!L || b.current) {
543
- l.current = !1, e.pause(), d(!1);
596
+ if (!_ || k.current) {
597
+ c.current = !1, e.pause(), h(!1);
544
598
  return;
545
599
  }
546
- e.paused && (l.current = !0, M("sync-paused-retry"));
600
+ e.paused && (c.current = !0, L("sync-paused-retry"));
547
601
  }, [
548
- o,
549
- k,
550
- w,
551
- g,
552
- L,
602
+ p,
603
+ a,
604
+ E,
553
605
  T,
554
- V,
606
+ _,
555
607
  x,
556
- G,
557
- v,
558
- M,
559
- ct,
560
- u
561
- ]), y(() => G, [G]), y(() => h, [h]);
562
- const Nt = r(() => {
563
- m(), ft(), d(!0), u(!1), Ne?.();
608
+ H,
609
+ C,
610
+ q,
611
+ A,
612
+ L,
613
+ _t,
614
+ l
615
+ ]), S(() => {
616
+ if (!O || O.id === tt.current || O.audioIndex !== a)
617
+ return;
618
+ const e = f[O.audioIndex];
619
+ xe(e, O.timeMs) && (tt.current = O.id, we(O.timeMs));
564
620
  }, [
565
- Ne,
566
- ft,
567
- m,
568
- u
569
- ]), Et = r(() => {
570
- A.current || C.current || (h(), m(), d(!1));
571
- }, [k, h, m]), Kt = r(() => {
572
- const e = _.current;
573
- e && S.current !== null && (e.currentTime = S.current, S.current = null), m(), !Se("canplay-seek-finished") && (!l.current || !L || M("canplay"));
621
+ f,
622
+ xe,
623
+ a,
624
+ we,
625
+ O
626
+ ]), S(() => q, [q]), S(() => g, [g]);
627
+ const Ht = r(() => {
628
+ y(), xt(), h(!0), l(!1), Oe?.();
574
629
  }, [
575
- k,
576
- L,
577
- Se,
578
- m,
579
- M
580
- ]), Ut = r(() => {
581
- const e = _.current;
582
- e && S.current !== null && (e.currentTime = S.current, S.current = null), m(), Se("metadata-seek-finished");
583
- }, [k, Se, m]), Ft = r(() => {
584
- m();
585
- }, [m]), Wt = r(() => {
586
- A.current || u(!0, "loadingAudio");
587
- }, [u]), Pt = r(() => {
588
- if (A.current) {
589
- u(!0, "waitingForMoreAudio");
630
+ Oe,
631
+ xt,
632
+ y,
633
+ l
634
+ ]), $t = r(() => {
635
+ v.current || N.current || (g(), y(), h(!1));
636
+ }, [a, g, y]), Jt = r(() => {
637
+ const e = M.current;
638
+ e && w.current !== null && (e.currentTime = w.current, w.current = null), y(), !Me("canplay-seek-finished") && (!c.current || !_ || L("canplay"));
639
+ }, [
640
+ a,
641
+ _,
642
+ Me,
643
+ y,
644
+ L
645
+ ]), Zt = r(() => {
646
+ const e = M.current;
647
+ e && w.current !== null && (e.currentTime = w.current, w.current = null), y(), Me("metadata-seek-finished");
648
+ }, [a, Me, y]), zt = r(() => {
649
+ y();
650
+ }, [y]), Yt = r(() => {
651
+ v.current || l(!0, "loadingAudio");
652
+ }, [l]), Dt = r(() => {
653
+ if (v.current) {
654
+ l(!0, "waitingForMoreAudio");
590
655
  return;
591
656
  }
592
- u(!0, "loadingAudio");
593
- }, [u]), pt = r(() => {
594
- m();
595
- }, [m]), Bt = r(() => {
657
+ l(!0, "loadingAudio");
658
+ }, [l]), wt = r(() => {
659
+ y();
660
+ }, [y]), Xt = r(() => {
596
661
  const e = U.current === "url" || j.current.length === 0;
597
- if (h(), C.current = !1, e) {
598
- Q("url-ended");
662
+ if (g(), N.current = !1, e) {
663
+ ee("url-ended");
599
664
  return;
600
665
  }
601
- mt();
602
- }, [Q, mt, h]), Ot = r(() => {
603
- h(), m(), d(!1), u(!1);
604
- }, [h, m, u]), Vt = r(
666
+ kt();
667
+ }, [ee, kt, g]), Gt = r(() => {
668
+ g(), y(), h(!1), l(!1);
669
+ }, [g, y, l]), Qt = r(
605
670
  (e) => {
606
- Ke?.(e), D(!1);
671
+ He?.(e), Q(!1);
607
672
  },
608
- [Ke]
609
- ), Ae = r(() => {
673
+ [He]
674
+ ), Ke = r(() => {
610
675
  if (F) {
611
- const t = !$;
612
- return B(t), Fe?.(t), !0;
676
+ const t = !Z;
677
+ return B(t), Je?.(t), !0;
613
678
  }
614
- const e = _.current;
615
- return T || !e || !o ? !1 : f.current !== null ? he ? (B(!1), l.current = !1, b.current = !0, f.current = null, A.current = !1, d(!1), u(!1), e.pause(), !0) : (B(!0), W.current = "manual", b.current = !1, l.current = !0, u(!0, "waitingForMoreAudio"), !0) : !e.src && w.length > 0 ? (B(!0), W.current = "manual", b.current = !1, v(
679
+ const e = M.current;
680
+ return x || !e || !p ? !1 : m.current !== null ? Se ? (B(!1), c.current = !1, k.current = !0, m.current = null, v.current = !1, h(!1), l(!1), e.pause(), !0) : (B(!0), W.current = "manual", k.current = !1, c.current = !0, l(!0, "waitingForMoreAudio"), !0) : !e.src && E.length > 0 ? (B(!0), W.current = "manual", k.current = !1, A(
616
681
  Math.min(
617
682
  K.current,
618
- w.length - 1
683
+ E.length - 1
619
684
  ),
620
685
  "toggle"
621
- ), !0) : e.paused ? (B(!0), W.current = "manual", b.current = !1, l.current = !0, M("toggle-resume"), !0) : (B(!1), l.current = !1, b.current = !0, e.pause(), !0);
686
+ ), !0) : e.paused ? (B(!0), W.current = "manual", k.current = !1, c.current = !0, L("toggle-resume"), !0) : (B(!1), c.current = !1, k.current = !0, e.pause(), !0);
622
687
  }, [
623
- o,
624
- w.length,
625
- $,
626
- T,
627
- he,
628
- Fe,
629
- v,
630
- M,
631
- u,
688
+ p,
689
+ E.length,
690
+ Z,
691
+ x,
692
+ Se,
693
+ Je,
694
+ A,
695
+ L,
696
+ l,
632
697
  B,
633
698
  F
634
699
  ]);
635
- y(() => {
700
+ S(() => {
636
701
  if (P)
637
- return Qt(z);
638
- }, [z, P]);
639
- const ve = Y(
702
+ return ir(D);
703
+ }, [D, P]);
704
+ const Ue = te(
640
705
  () => ({
641
- fullscreen: () => te ? (te(), !0) : !1,
642
- interaction: () => fe ? (_e && fe(), !0) : !1,
643
- next: () => oe ? (we || oe(
644
- St(se())
706
+ fullscreen: () => ne ? (ne(), !0) : !1,
707
+ interaction: () => pe ? (Le && pe(), !0) : !1,
708
+ next: () => de ? (je || de(
709
+ We(X())
645
710
  ), !0) : !1,
646
- nextSubtitle: () => X.next ? ae("next") : !0,
647
- previous: () => ce ? (ke || ce(
648
- St(se())
711
+ nextSubtitle: () => I.next ? ie("next") : !0,
712
+ previous: () => fe ? (Ae || fe(
713
+ We(X())
649
714
  ), !0) : !1,
650
- previousSubtitle: () => X.previous ? ae("previous") : !0,
651
- subtitle: () => ee ? (ee(), !0) : !1,
652
- togglePlayback: () => (Ae(), !0)
715
+ previousSubtitle: () => I.previous ? ie("previous") : !0,
716
+ subtitle: () => re ? (re(), !0) : !1,
717
+ togglePlayback: () => (Ke(), !0)
653
718
  }),
654
719
  [
655
- se,
656
- _e,
657
- ae,
658
- we,
659
- te,
720
+ X,
721
+ Le,
722
+ ie,
723
+ je,
724
+ ne,
725
+ pe,
726
+ de,
660
727
  fe,
661
- oe,
662
- ce,
663
- ee,
664
- ke,
665
- X.next,
666
- X.previous,
667
- Ae
728
+ re,
729
+ Ae,
730
+ I.next,
731
+ I.previous,
732
+ Ke
668
733
  ]
669
- ), ht = c(ve);
670
- return y(() => {
671
- ht.current = ve;
672
- }, [ve]), y(() => {
734
+ ), Mt = o(Ue);
735
+ return S(() => {
736
+ Mt.current = Ue;
737
+ }, [Ue]), S(() => {
673
738
  if (!P || typeof document > "u")
674
739
  return;
675
740
  const e = (t) => {
676
- if (!er(z))
741
+ if (!or(D))
677
742
  return;
678
- const s = tr(t);
679
- if (!s || rr(t, s))
743
+ const s = fr(t);
744
+ if (!s || dr(t, s))
680
745
  return;
681
- let i = !1;
682
- const p = ht.current[s];
683
- i = p(), i && t.preventDefault();
746
+ let u = !1;
747
+ const b = Mt.current[s];
748
+ u = b(), u && t.preventDefault();
684
749
  };
685
750
  return document.addEventListener("keydown", e), () => {
686
751
  document.removeEventListener("keydown", e);
687
752
  };
688
- }, [z, P]), y(() => {
689
- ie?.(me.current);
690
- }, [ie]), /* @__PURE__ */ n.jsxs(
753
+ }, [D, P]), S(() => {
754
+ oe?.(ye.current);
755
+ }, [oe]), /* @__PURE__ */ n.jsxs(
691
756
  "div",
692
757
  {
693
- ...Lt,
694
- "data-slide-player-shortcut-owner": z,
695
- className: bt("slide-player", N),
696
- onFocusCapture: Ct,
697
- onPointerDown: jt,
758
+ ...Kt,
759
+ "data-slide-player-shortcut-owner": D,
760
+ className: Tt("slide-player", d),
761
+ onFocusCapture: Vt,
762
+ onPointerDown: Ot,
698
763
  children: [
699
764
  /* @__PURE__ */ n.jsx(
700
765
  "audio",
701
766
  {
702
- ref: _,
767
+ ref: M,
703
768
  preload: "auto",
704
769
  playsInline: !0,
705
- onLoadStart: Wt,
706
- onLoadedMetadata: Ut,
707
- onCanPlay: Kt,
708
- onPlay: Nt,
709
- onPause: Et,
710
- onWaiting: Pt,
711
- onSeeking: pt,
712
- onSeeked: pt,
713
- onTimeUpdate: Ft,
714
- onEnded: Bt,
715
- onError: Ot
770
+ onLoadStart: Yt,
771
+ onLoadedMetadata: Zt,
772
+ onCanPlay: Jt,
773
+ onPlay: Ht,
774
+ onPause: $t,
775
+ onWaiting: Dt,
776
+ onSeeking: wt,
777
+ onSeeked: wt,
778
+ onTimeUpdate: zt,
779
+ onEnded: Xt,
780
+ onError: Gt
716
781
  }
717
782
  ),
718
- Me ? /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
783
+ Ne ? /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
719
784
  /* @__PURE__ */ n.jsx(
720
- zt,
785
+ nr,
721
786
  {
722
- container: wt,
787
+ container: Et,
723
788
  labels: {
724
- closeSettings: a.closeSettingsLabel,
725
- fullscreen: a.fullscreenLabel,
726
- nonFullscreen: a.nonFullscreenLabel,
727
- screen: a.screenLabel,
728
- screenMode: a.screenModeLabel,
729
- subtitle: a.subtitleLabel,
730
- subtitleToggle: a.subtitleToggleAriaLabel,
731
- title: a.settingsTitle
789
+ closeSettings: i.closeSettingsLabel,
790
+ fullscreen: i.fullscreenLabel,
791
+ nonFullscreen: i.nonFullscreenLabel,
792
+ screen: i.screenLabel,
793
+ screenMode: i.screenModeLabel,
794
+ subtitle: i.subtitleLabel,
795
+ subtitleToggle: i.subtitleToggleAriaLabel,
796
+ title: i.settingsTitle
732
797
  },
733
- isSubtitleEnabled: xe,
734
- onClose: () => D(!1),
735
- onOpenChange: D,
736
- onSubtitleToggle: ee ?? (() => {
798
+ isSubtitleEnabled: ve,
799
+ onClose: () => Q(!1),
800
+ onOpenChange: Q,
801
+ onSubtitleToggle: re ?? (() => {
737
802
  }),
738
- onViewModeChange: Vt,
739
- open: ze,
740
- viewMode: kt
803
+ onViewModeChange: Qt,
804
+ open: nt,
805
+ viewMode: Nt
741
806
  }
742
807
  ),
743
- /* @__PURE__ */ n.jsxs("div", { className: "slide-player__controls", style: vt, children: [
808
+ /* @__PURE__ */ n.jsxs("div", { className: "slide-player__controls", style: Pt, children: [
744
809
  /* @__PURE__ */ n.jsxs("div", { className: "slide-player__group", children: [
745
810
  /* @__PURE__ */ n.jsx(
746
811
  "button",
747
812
  {
748
- "aria-expanded": ze,
813
+ "aria-expanded": nt,
749
814
  "aria-haspopup": "dialog",
750
- "aria-label": a.moreOptionsAriaLabel,
815
+ "aria-label": i.moreOptionsAriaLabel,
751
816
  className: "slide-player__action slide-player__action--mobile-more",
752
817
  onClick: () => {
753
- D((e) => !e);
818
+ Q((e) => !e);
754
819
  },
755
820
  type: "button",
756
821
  children: /* @__PURE__ */ n.jsx(
757
- ir,
822
+ gr,
758
823
  {
759
824
  className: "slide-player__icon",
760
825
  strokeWidth: 2.25
@@ -765,104 +830,110 @@ const _t = /* @__PURE__ */ new Map(), xt = (R) => {
765
830
  /* @__PURE__ */ n.jsx(
766
831
  "button",
767
832
  {
768
- "aria-label": a.volumeAriaLabel,
833
+ "aria-label": i.volumeAriaLabel,
769
834
  className: "hidden",
770
835
  type: "button",
771
- children: /* @__PURE__ */ n.jsx(cr, { className: "slide-player__icon", strokeWidth: 2.25 })
836
+ children: /* @__PURE__ */ n.jsx(_r, { className: "slide-player__icon", strokeWidth: 2.25 })
772
837
  }
773
838
  ),
774
839
  /* @__PURE__ */ n.jsx(
775
840
  "button",
776
841
  {
777
- "aria-label": a.subtitleToggleAriaLabel,
778
- "aria-keyshortcuts": Qe.ariaKeyShortcuts,
779
- "aria-pressed": xe,
780
- className: "slide-player__action slide-player__action--subtitle",
781
- onClick: ee,
782
- title: Qe.title,
842
+ "aria-label": ct,
843
+ "aria-keyshortcuts": mt.ariaKeyShortcuts,
844
+ className: "slide-player__toggle slide-player__toggle--playback",
845
+ onClick: () => {
846
+ Ke();
847
+ },
848
+ title: mt.title,
783
849
  type: "button",
784
- children: xe ? /* @__PURE__ */ n.jsx(or, { className: "slide-player__icon", strokeWidth: 2.25 }) : /* @__PURE__ */ n.jsx(
785
- fr,
786
- {
787
- className: "slide-player__icon",
788
- strokeWidth: 2.25
789
- }
790
- )
850
+ children: Bt ? /* @__PURE__ */ n.jsx(Er, {}) : /* @__PURE__ */ n.jsx(Rr, {})
791
851
  }
792
852
  ),
793
853
  /* @__PURE__ */ n.jsx(
794
854
  "button",
795
855
  {
796
- "aria-keyshortcuts": tt.ariaKeyShortcuts,
797
- "aria-label": a.previousSubtitleLabel,
798
- className: "slide-player__action slide-player__action--prev-subtitle",
799
- disabled: !X.previous,
856
+ "aria-keyshortcuts": ft.ariaKeyShortcuts,
857
+ "aria-label": i.previousLabel,
858
+ className: "slide-player__action slide-player__action--prev",
859
+ disabled: Ae,
800
860
  onClick: () => {
801
- ae("previous");
861
+ fe?.(X());
802
862
  },
803
- title: tt.title,
863
+ title: ft.title,
804
864
  type: "button",
805
- children: /* @__PURE__ */ n.jsx(dr, { className: "slide-player__icon", strokeWidth: 2.25 })
865
+ children: /* @__PURE__ */ n.jsx(xr, { className: "slide-player__icon", strokeWidth: 2.25 })
806
866
  }
807
867
  ),
808
868
  /* @__PURE__ */ n.jsx(
809
869
  "button",
810
870
  {
811
- "aria-keyshortcuts": et.ariaKeyShortcuts,
812
- "aria-label": a.previousLabel,
813
- className: "slide-player__action slide-player__action--prev",
814
- disabled: ke,
871
+ "aria-keyshortcuts": pt.ariaKeyShortcuts,
872
+ "aria-label": i.nextLabel,
873
+ className: "slide-player__action slide-player__action--next",
874
+ disabled: je,
815
875
  onClick: () => {
816
- ce?.(se());
876
+ de?.(X());
817
877
  },
818
- title: et.title,
878
+ title: pt.title,
819
879
  type: "button",
820
- children: /* @__PURE__ */ n.jsx(mr, { className: "slide-player__icon", strokeWidth: 2.25 })
880
+ children: /* @__PURE__ */ n.jsx(
881
+ kr,
882
+ {
883
+ className: "slide-player__icon",
884
+ strokeWidth: 2.25
885
+ }
886
+ )
821
887
  }
822
888
  ),
823
889
  /* @__PURE__ */ n.jsx(
824
890
  "button",
825
891
  {
826
- "aria-label": Xe,
827
- "aria-keyshortcuts": rt.ariaKeyShortcuts,
828
- className: "slide-player__toggle slide-player__toggle--playback",
892
+ "aria-keyshortcuts": dt.ariaKeyShortcuts,
893
+ "aria-label": i.previousSubtitleLabel,
894
+ className: "slide-player__action slide-player__action--prev-subtitle",
895
+ disabled: !I.previous,
829
896
  onClick: () => {
830
- Ae();
897
+ ie("previous");
831
898
  },
832
- title: rt.title,
899
+ title: dt.title,
833
900
  type: "button",
834
- children: Rt ? /* @__PURE__ */ n.jsx(gr, {}) : /* @__PURE__ */ n.jsx(_r, {})
901
+ children: /* @__PURE__ */ n.jsx(wr, { className: "slide-player__icon", strokeWidth: 2.25 })
835
902
  }
836
903
  ),
837
904
  /* @__PURE__ */ n.jsx(
838
905
  "button",
839
906
  {
840
- "aria-keyshortcuts": nt.ariaKeyShortcuts,
841
- "aria-label": a.nextLabel,
842
- className: "slide-player__action slide-player__action--next",
843
- disabled: we,
907
+ "aria-keyshortcuts": ht.ariaKeyShortcuts,
908
+ "aria-label": i.nextSubtitleLabel,
909
+ className: "slide-player__action slide-player__action--next-subtitle",
910
+ disabled: !I.next,
844
911
  onClick: () => {
845
- oe?.(se());
912
+ ie("next");
846
913
  },
847
- title: nt.title,
914
+ title: ht.title,
848
915
  type: "button",
849
- children: /* @__PURE__ */ n.jsx(pr, { className: "slide-player__icon", strokeWidth: 2.25 })
916
+ children: /* @__PURE__ */ n.jsx(
917
+ Mr,
918
+ {
919
+ className: "slide-player__icon",
920
+ strokeWidth: 2.25
921
+ }
922
+ )
850
923
  }
851
924
  ),
852
925
  /* @__PURE__ */ n.jsx(
853
926
  "button",
854
927
  {
855
- "aria-keyshortcuts": ut.ariaKeyShortcuts,
856
- "aria-label": a.nextSubtitleLabel,
857
- className: "slide-player__action slide-player__action--next-subtitle",
858
- disabled: !X.next,
859
- onClick: () => {
860
- ae("next");
861
- },
862
- title: ut.title,
928
+ "aria-label": i.subtitleToggleAriaLabel,
929
+ "aria-keyshortcuts": ot.ariaKeyShortcuts,
930
+ "aria-pressed": ve,
931
+ className: "slide-player__action slide-player__action--subtitle",
932
+ onClick: re,
933
+ title: ot.title,
863
934
  type: "button",
864
- children: /* @__PURE__ */ n.jsx(
865
- hr,
935
+ children: ve ? /* @__PURE__ */ n.jsx(Cr, { className: "slide-player__icon", strokeWidth: 2.25 }) : /* @__PURE__ */ n.jsx(
936
+ Tr,
866
937
  {
867
938
  className: "slide-player__icon",
868
939
  strokeWidth: 2.25
@@ -870,23 +941,23 @@ const _t = /* @__PURE__ */ new Map(), xt = (R) => {
870
941
  )
871
942
  }
872
943
  ),
873
- te ? /* @__PURE__ */ n.jsx(
944
+ ne ? /* @__PURE__ */ n.jsx(
874
945
  "button",
875
946
  {
876
- "aria-label": Ge,
877
- "aria-keyshortcuts": st.ariaKeyShortcuts,
947
+ "aria-label": it,
948
+ "aria-keyshortcuts": yt.ariaKeyShortcuts,
878
949
  className: "slide-player__action slide-player__action--fullscreen",
879
- onClick: te,
880
- title: st.title,
950
+ onClick: ne,
951
+ title: yt.title,
881
952
  type: "button",
882
- children: Ee ? /* @__PURE__ */ n.jsx(
883
- yr,
953
+ children: Ve ? /* @__PURE__ */ n.jsx(
954
+ Lr,
884
955
  {
885
956
  className: "slide-player__icon",
886
957
  strokeWidth: 2.25
887
958
  }
888
959
  ) : /* @__PURE__ */ n.jsx(
889
- br,
960
+ vr,
890
961
  {
891
962
  className: "slide-player__icon",
892
963
  strokeWidth: 2.25
@@ -897,22 +968,22 @@ const _t = /* @__PURE__ */ new Map(), xt = (R) => {
897
968
  ] }),
898
969
  /* @__PURE__ */ n.jsx("div", { className: "slide-player__separator" }),
899
970
  /* @__PURE__ */ n.jsxs("div", { className: "slide-player__group", children: [
900
- Ye.map((e, t) => /* @__PURE__ */ n.jsx(Ht.Fragment, { children: e }, `custom-action-${t}`)),
971
+ lt.map((e, t) => /* @__PURE__ */ n.jsx(qt.Fragment, { children: e }, `custom-action-${t}`)),
901
972
  /* @__PURE__ */ n.jsx(
902
973
  "button",
903
974
  {
904
- "aria-label": a.notesLabel,
905
- "aria-keyshortcuts": lt.ariaKeyShortcuts,
906
- className: bt(
975
+ "aria-label": i.notesLabel,
976
+ "aria-keyshortcuts": bt.ariaKeyShortcuts,
977
+ className: Tt(
907
978
  "slide-player__action slide-player__action--notes",
908
- re && "slide-player__action--active"
979
+ ue && "slide-player__action--active"
909
980
  ),
910
- disabled: !_e,
911
- onClick: fe,
912
- title: lt.title,
981
+ disabled: !Le,
982
+ onClick: pe,
983
+ title: bt.title,
913
984
  type: "button",
914
985
  children: /* @__PURE__ */ n.jsx(
915
- Sr,
986
+ Ar,
916
987
  {
917
988
  className: "slide-player__icon",
918
989
  strokeWidth: 2.25
@@ -926,9 +997,9 @@ const _t = /* @__PURE__ */ new Map(), xt = (R) => {
926
997
  ]
927
998
  }
928
999
  );
929
- }, Mr = $t(wr);
930
- Mr.displayName = "Player";
1000
+ }, Wr = er(Fr);
1001
+ Wr.displayName = "Player";
931
1002
  export {
932
- Mr as default
1003
+ Wr as default
933
1004
  };
934
1005
  //# sourceMappingURL=Player.es.js.map