@banou/media-player 0.10.30 → 0.10.32

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 (59) hide show
  1. package/README.md +23 -0
  2. package/dist/de-DphEdq0O.js +52 -0
  3. package/dist/engine/index.js +1 -1
  4. package/dist/engine/playback.d.ts +4 -3
  5. package/dist/engine/source-buffer.d.ts +0 -1
  6. package/dist/{engine-DeEY2qao.js → engine-BZDbaSfM.js} +211 -161
  7. package/dist/es-419-D6gsvnn8.js +52 -0
  8. package/dist/fr-BqAzAJX0.js +52 -0
  9. package/dist/index.js +942 -855
  10. package/dist/it-NTcUh3Gr.js +52 -0
  11. package/dist/ja-DSmX_bxj.js +52 -0
  12. package/dist/ko-DyPzWasj.js +52 -0
  13. package/dist/labels.d.ts +71 -0
  14. package/dist/pl-C6Ow4ra5.js +52 -0
  15. package/dist/pt-BR-wudK3giz.js +52 -0
  16. package/dist/react/labels.d.ts +28 -0
  17. package/dist/react/video-player.d.ts +9 -0
  18. package/dist/ru-D5kxBkik.js +52 -0
  19. package/dist/tr-CW7R7N9k.js +52 -0
  20. package/dist/utils/track-label.d.ts +9 -8
  21. package/dist/volume-normalizer-worklet.js +40 -26
  22. package/dist/zh-Hans-IhL1Pl78.js +52 -0
  23. package/dist/zh-Hant-C5YyFjEc.js +52 -0
  24. package/package.json +4 -2
  25. package/src/lib/audio/loudness-analysis.ts +3 -3
  26. package/src/lib/audio/playback-tap.ts +3 -3
  27. package/src/lib/audio/volume-normalizer-worklet.d.ts +1 -1
  28. package/src/lib/audio/volume-normalizer-worklet.js +40 -26
  29. package/src/lib/engine/playback.ts +21 -22
  30. package/src/lib/engine/source-buffer.ts +5 -7
  31. package/src/lib/labels.ts +75 -0
  32. package/src/lib/locales/de.json +49 -0
  33. package/src/lib/locales/es-419.json +49 -0
  34. package/src/lib/locales/fr.json +49 -0
  35. package/src/lib/locales/it.json +49 -0
  36. package/src/lib/locales/ja.json +49 -0
  37. package/src/lib/locales/ko.json +49 -0
  38. package/src/lib/locales/pl.json +49 -0
  39. package/src/lib/locales/pt-BR.json +49 -0
  40. package/src/lib/locales/ru.json +49 -0
  41. package/src/lib/locales/tr.json +49 -0
  42. package/src/lib/locales/zh-Hans.json +49 -0
  43. package/src/lib/locales/zh-Hant.json +49 -0
  44. package/src/lib/react/components/burn-in-hint.tsx +4 -1
  45. package/src/lib/react/components/chrome.tsx +9 -0
  46. package/src/lib/react/components/control-bar.tsx +15 -26
  47. package/src/lib/react/components/errors.tsx +11 -9
  48. package/src/lib/react/components/overlay.tsx +18 -5
  49. package/src/lib/react/components/playback-slider.tsx +4 -1
  50. package/src/lib/react/components/settings.tsx +23 -31
  51. package/src/lib/react/components/skip-chapter.tsx +5 -2
  52. package/src/lib/react/components/sound.tsx +5 -2
  53. package/src/lib/react/components/subtitles.tsx +7 -4
  54. package/src/lib/react/components/track-menu.tsx +8 -4
  55. package/src/lib/react/components/volume-slider.tsx +3 -1
  56. package/src/lib/react/hooks/use-playback.ts +12 -2
  57. package/src/lib/react/labels.tsx +125 -0
  58. package/src/lib/react/video-player.tsx +14 -1
  59. package/src/lib/utils/track-label.ts +16 -11
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
- import { c as e, l as t, n, o as r, r as i, s as a, t as o, u as s } from "./engine-DeEY2qao.js";
2
- import { languageOf as c, preferredTrack as l } from "./language/index.js";
3
- import { n as u, r as d, t as f } from "./chapters-EBYXcEml.js";
4
- import { Children as p, Fragment as m, createContext as h, isValidElement as g, useCallback as _, useContext as v, useEffect as y, useMemo as b, useRef as x, useState as S, useSyncExternalStore as C } from "react";
5
- import { css as w, keyframes as T } from "@emotion/react";
6
- import { createPlayer as E, useContainerAttach as D, useMediaAttach as O } from "@videojs/react";
7
- import { definePlayerFeature as k, videoFeatures as A } from "@videojs/core/dom";
8
- import { makeRemuxer as j } from "libav-wasm";
9
- import { createMediaElementSource as M } from "@banou/ponyfill/web-audio";
1
+ import { c as e, l as t, m as n, n as r, o as i, p as a, r as o, s, t as c, u as l } from "./engine-BZDbaSfM.js";
2
+ import { languageOf as u, preferredTrack as d } from "./language/index.js";
3
+ import { n as f, r as p, t as m } from "./chapters-EBYXcEml.js";
4
+ import { Children as h, Fragment as g, createContext as _, isValidElement as v, useCallback as y, useContext as b, useEffect as x, useMemo as S, useRef as C, useState as w, useSyncExternalStore as T } from "react";
5
+ import { css as E, keyframes as D } from "@emotion/react";
6
+ import { createPlayer as O, useContainerAttach as k, useMediaAttach as ee } from "@videojs/react";
7
+ import { definePlayerFeature as A, videoFeatures as j } from "@videojs/core/dom";
8
+ import { makeRemuxer as M } from "libav-wasm";
10
9
  import { Fragment as N, jsx as P, jsxs as F } from "@emotion/react/jsx-runtime";
11
- import { Captions as I, CaptionsOff as L, Check as R, ChevronLeft as z, ChevronRight as B, Copy as V, Maximize as H, Minimize as U, Pause as W, Play as ee, RotateCcw as G, Settings as te, TriangleAlert as K, Volume1 as q, Volume2 as J, VolumeX as ne } from "lucide-react";
12
- import { Tooltip as re } from "react-tooltip";
10
+ import { createMediaElementSource as I } from "@banou/ponyfill/web-audio";
11
+ import { Captions as L, CaptionsOff as R, Check as z, ChevronLeft as B, ChevronRight as V, Copy as te, Maximize as H, Minimize as ne, Pause as U, Play as W, RotateCcw as G, Settings as K, TriangleAlert as q, Volume1 as re, Volume2 as ie, VolumeX as ae } from "lucide-react";
12
+ import { Tooltip as oe } from "react-tooltip";
13
13
  //#region src/lib/react/source-feature.ts
14
- var ie = {
14
+ var se = {
15
15
  indexes: [],
16
16
  chapters: [],
17
17
  thumbnails: [],
@@ -36,161 +36,240 @@ var ie = {
36
36
  playbackErrors: [],
37
37
  ready: !1,
38
38
  setSourceState: () => {}
39
- }, ae = k({
39
+ }, ce = A({
40
40
  name: "source",
41
- state: () => ({ ...ie }),
41
+ state: () => ({ ...se }),
42
42
  attach({ set: e }) {
43
43
  e({
44
44
  setSourceState: (t) => e(t),
45
45
  setHideUI: (t) => e({ hideUI: t })
46
46
  });
47
47
  }
48
- }), oe = E({
49
- features: [...A, ae],
48
+ }), le = O({
49
+ features: [...j, ce],
50
50
  displayName: "MediaPlayer"
51
- }), Y = oe.usePlayer, se = (e) => {
51
+ }), J = le.usePlayer, ue = {
52
+ de: () => import("./de-DphEdq0O.js"),
53
+ "es-419": () => import("./es-419-D6gsvnn8.js"),
54
+ fr: () => import("./fr-BqAzAJX0.js"),
55
+ it: () => import("./it-NTcUh3Gr.js"),
56
+ ja: () => import("./ja-DSmX_bxj.js"),
57
+ ko: () => import("./ko-DyPzWasj.js"),
58
+ pl: () => import("./pl-C6Ow4ra5.js"),
59
+ "pt-BR": () => import("./pt-BR-wudK3giz.js"),
60
+ ru: () => import("./ru-D5kxBkik.js"),
61
+ tr: () => import("./tr-CW7R7N9k.js"),
62
+ "zh-Hans": () => import("./zh-Hans-IhL1Pl78.js"),
63
+ "zh-Hant": () => import("./zh-Hant-C5YyFjEc.js")
64
+ }, Y = Object.keys(ue), de = (e) => {
65
+ try {
66
+ let t = new Intl.Locale(e), { language: n, script: r } = t.maximize();
67
+ return {
68
+ tag: t.baseName,
69
+ language: n,
70
+ script: r
71
+ };
72
+ } catch {
73
+ return;
74
+ }
75
+ }, fe = (e) => {
76
+ let t = de(e);
77
+ if (!t) return;
78
+ let n = Y.map((e) => ({
79
+ ...de(e),
80
+ catalogue: e
81
+ }));
82
+ return (n.find(({ tag: e }) => e === t.tag) ?? n.find(({ language: e, script: n }) => e === t.language && n === t.script) ?? n.find(({ language: e }) => e === t.language))?.catalogue;
83
+ }, X = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map(), pe = (e, t) => {
84
+ let n = Z.get(e);
85
+ return n || (n = Promise.all([import("@formatjs/intl"), ue[t]()]).then(([{ createIntl: t }, { default: n }]) => {
86
+ let r = t({
87
+ locale: e,
88
+ defaultLocale: "en",
89
+ messages: n
90
+ });
91
+ return X.set(e, r), r;
92
+ }), n.catch(() => Z.delete(e)), Z.set(e, n)), n;
93
+ }, me = (e) => {
94
+ try {
95
+ return Intl.getCanonicalLocales(e)[0];
96
+ } catch {
97
+ return;
98
+ }
99
+ }, he = (e, t) => {
100
+ let r = t ? me(t) ?? "en" : void 0;
101
+ return {
102
+ format: (t, ...[r]) => e ? e.formatMessage({
103
+ id: t,
104
+ defaultMessage: t
105
+ }, r) : n(t, r),
106
+ number: (e, t) => new Intl.NumberFormat(r ?? "en", t).format(e),
107
+ locale: r
108
+ };
109
+ }, ge = he(void 0, void 0), _e = _(ge), Q = () => b(_e), ve = ({ language: e, children: t }) => {
110
+ let n = e ? fe(e) : void 0, [, r] = w();
111
+ x(() => {
112
+ if (!e || !n || X.has(e)) return;
113
+ let t = !1;
114
+ return pe(e, n).then((e) => {
115
+ t || r(e);
116
+ }, () => {}), () => {
117
+ t = !0;
118
+ };
119
+ }, [e, n]);
120
+ let i = e && n ? X.get(e) : void 0, a = S(() => e ? he(i, e) : ge, [i, e]);
121
+ return /* @__PURE__ */ P(_e.Provider, {
122
+ value: a,
123
+ children: t
124
+ });
125
+ }, ye = (e, t) => {
52
126
  if (e && e !== "und") try {
53
- return new Intl.DisplayNames([navigator.language || "en"], {
127
+ return new Intl.DisplayNames([t ?? (navigator.language || "en")], {
54
128
  type: "language",
55
129
  fallback: "none"
56
130
  }).of(e) || void 0;
57
131
  } catch {
58
132
  return;
59
133
  }
60
- }, ce = (e) => e?.replace(/_/g, " ").trim() || void 0, le = (e) => {
61
- let t = e.map((e) => se(e.language) ?? ce(e.title) ?? `Track ${e.streamIndex}`), n = t.reduce((e, t) => ({
134
+ }, be = (e) => e?.replace(/_/g, " ").trim() || void 0, xe = (e, t) => {
135
+ let r = (e) => t ? t.format(a.track, { number: e }) : n(a.track, { number: e }), i = e.map((e) => ye(e.language, t?.locale) ?? be(e.title) ?? r(e.streamIndex)), o = i.reduce((e, t) => ({
62
136
  ...e,
63
137
  [t]: (e[t] ?? 0) + 1
64
138
  }), {});
65
- return e.map((e, r) => {
66
- let i = t[r], a = ce(e.title);
139
+ return e.map((e, t) => {
140
+ let n = i[t], r = be(e.title);
67
141
  return {
68
142
  track: e,
69
- label: (n[i] ?? 0) > 1 && a && a !== i ? `${i} (${a})` : i
143
+ label: (o[n] ?? 0) > 1 && r && r !== n ? `${n} (${r})` : n
70
144
  };
71
145
  });
72
- }, X = (e) => le(e).map(({ track: e, label: t }) => ({
146
+ }, Se = (e, t) => xe(e, t).map(({ track: e, label: t }) => ({
73
147
  id: e.streamIndex,
74
148
  label: t
75
- })), ue = [
149
+ })), Ce = [
76
150
  0,
77
151
  250,
78
152
  1e3,
79
153
  3e3,
80
154
  1e4
81
- ], de = 6e4, Z = 500, fe = 15e3, pe = (e, t) => {
155
+ ], we = 6e4, Te = 500, Ee = 15e3, De = (e, t) => {
82
156
  if (e === null) return;
83
- let n = e === void 0 ? 0 : l(e, t);
157
+ let n = e === void 0 ? 0 : d(e, t);
84
158
  return t[Math.max(n, 0)]?.streamIndex;
85
- }, me = (e) => e instanceof Error ? e.message : String(e), he = (e) => {
159
+ }, Oe = (e) => e instanceof Error ? e.message : String(e), ke = (e) => {
86
160
  let t = [], n = e?.cause;
87
161
  for (let e = 0; n != null && e < 8; e++) {
88
162
  if (typeof MediaError < "u" && n instanceof MediaError) {
89
163
  t.push(`MediaError code ${n.code}${n.message ? `: ${n.message}` : ""}`);
90
164
  break;
91
165
  }
92
- t.push(me(n)), n = n?.cause;
166
+ t.push(Oe(n)), n = n?.cause;
93
167
  }
94
168
  return t.length ? t.join("\n") : void 0;
95
- }, ge = (e, t, n, i) => {
96
- let o = Y(), { read: s, size: u, publicPath: d = "", libavWorkerUrl: f = "", jassubWorkerUrl: p = "", jassubWasmUrl: m = "", jassubLegacyWasmUrl: h, defaultFontUrl: g, cjkFontUrl: v, bufferSize: b, autoplay: C = !1, chapters: w, seekPrepareBudgetMs: T = Z } = n ?? {}, E = x(w);
97
- E.current = w;
98
- let [D, O] = S(), k = D && D.size === u ? D.streamIndex : void 0, [A, j] = S(0), M = x({
169
+ }, Ae = (e, t, n, r) => {
170
+ let a = J(), { read: o, size: c, publicPath: l = "", libavWorkerUrl: f = "", jassubWorkerUrl: p = "", jassubWasmUrl: m = "", jassubLegacyWasmUrl: h, defaultFontUrl: g, cjkFontUrl: _, bufferSize: v, autoplay: b = !1, chapters: S, seekPrepareBudgetMs: T = Te } = n ?? {}, E = C(S);
171
+ E.current = S;
172
+ let [D, O] = w(), k = D && D.size === c ? D.streamIndex : void 0, [ee, A] = w(0), j = C({
99
173
  count: 0,
100
174
  at: 0
101
- }), N = x(void 0);
102
- y(() => (M.current = {
175
+ }), M = C(void 0);
176
+ x(() => (j.current = {
103
177
  count: 0,
104
178
  at: 0
105
- }, o.setSourceState({ playbackErrors: [] }), () => {
106
- N.current && clearTimeout(N.current);
107
- }), [u]);
108
- let P = x(null), F = x(null), I = x(void 0), L = x(u);
109
- L.current = u;
110
- let R = x({
179
+ }, a.setSourceState({ playbackErrors: [] }), () => {
180
+ M.current && clearTimeout(M.current);
181
+ }), [c]);
182
+ let N = C(null), P = C(null), F = C(void 0), I = C(c);
183
+ I.current = c;
184
+ let L = C({
111
185
  audio: [],
112
186
  subtitles: []
113
- }), z = x(s);
114
- z.current = s;
115
- let B = x(n?.preferredAudioLanguage);
116
- B.current = n?.preferredAudioLanguage;
117
- let V = x(n?.preferredSubtitleLanguage);
118
- V.current = n?.preferredSubtitleLanguage;
119
- let H = x(n?.onPreferredAudioLanguageChange);
120
- H.current = n?.onPreferredAudioLanguageChange;
121
- let U = x(n?.onPreferredSubtitleLanguageChange);
122
- U.current = n?.onPreferredSubtitleLanguageChange;
123
- let W = x(n?.onSeek);
124
- W.current = n?.onSeek;
125
- let ee = x(n?.onPlaybackError);
126
- ee.current = n?.onPlaybackError;
127
- let G = x(i);
128
- G.current = i;
129
- let te = _((e) => {
130
- let t = typeof e == "number" ? e : void 0, n = o.selectedSubtitleTrack === void 0;
131
- I.current = L.current, o.setSourceState({ selectedSubtitleTrack: t }), P.current?.selectSubtitleStream(t);
132
- let r = R.current.subtitles.find((e) => e.streamIndex === t), i = t === void 0 ? null : c(r) ?? (n ? r?.title?.trim() || "und" : void 0);
133
- i !== void 0 && U.current?.(i);
134
- }, [o]), K = _((e) => {
135
- let t = P.current;
187
+ }), R = C(o);
188
+ R.current = o;
189
+ let z = C(n?.preferredAudioLanguage);
190
+ z.current = n?.preferredAudioLanguage;
191
+ let B = C(n?.preferredSubtitleLanguage);
192
+ B.current = n?.preferredSubtitleLanguage;
193
+ let V = C(n?.onPreferredAudioLanguageChange);
194
+ V.current = n?.onPreferredAudioLanguageChange;
195
+ let te = C(n?.onPreferredSubtitleLanguageChange);
196
+ te.current = n?.onPreferredSubtitleLanguageChange;
197
+ let H = C(n?.onSeek);
198
+ H.current = n?.onSeek;
199
+ let ne = C(n?.onPlaybackError);
200
+ ne.current = n?.onPlaybackError;
201
+ let U = C(r);
202
+ U.current = r;
203
+ let W = Q(), G = C(W);
204
+ G.current = W, x(() => {
205
+ let { audio: e, subtitles: t } = L.current;
206
+ t.length && a.setSourceState({ subtitleTracks: Se(t, W) }), e.length && a.setSourceState({ audioTracks: Se(e, W) });
207
+ }, [a, W]);
208
+ let K = y((e) => {
209
+ let t = typeof e == "number" ? e : void 0, n = a.selectedSubtitleTrack === void 0;
210
+ F.current = I.current, a.setSourceState({ selectedSubtitleTrack: t }), N.current?.selectSubtitleStream(t);
211
+ let r = L.current.subtitles.find((e) => e.streamIndex === t), i = t === void 0 ? null : u(r) ?? (n ? r?.title?.trim() || "und" : void 0);
212
+ i !== void 0 && te.current?.(i);
213
+ }, [a]), q = y((e) => {
214
+ let t = N.current;
136
215
  if (!t || T <= 0) {
137
- o.seek(e);
216
+ a.seek(e);
138
217
  return;
139
218
  }
140
- let n = typeof window < "u" && window.__mediaPlayerSeekDebug, r = performance.now(), i = !1, a = "prepared", s = () => {
141
- if (!i && (i = !0, o.seek(e), n)) {
219
+ let n = typeof window < "u" && window.__mediaPlayerSeekDebug, r = performance.now(), i = !1, o = "prepared", s = () => {
220
+ if (!i && (i = !0, a.seek(e), n)) {
142
221
  let n = t.videoElement, i = 0;
143
222
  if (n) for (let t = 0; t < n.buffered.length; t++) n.buffered.start(t) <= e + 1 && e < n.buffered.end(t) && (i = n.buffered.end(t) - e);
144
- console.warn(`[media-player] seek to ${e.toFixed(2)} moved after ${Math.round(performance.now() - r)}ms via ${a}, runway ${i.toFixed(1)}s${a === "deadline" ? " (EXPOSED: moved before its data was ready)" : ""}`);
223
+ console.warn(`[media-player] seek to ${e.toFixed(2)} moved after ${Math.round(performance.now() - r)}ms via ${o}, runway ${i.toFixed(1)}s${o === "deadline" ? " (EXPOSED: moved before its data was ready)" : ""}`);
145
224
  }
146
225
  };
147
- o.setSourceState({ seekingTo: e });
226
+ a.setSourceState({ seekingTo: e });
148
227
  let c = t.videoElement, l = () => {
149
- c?.removeEventListener("seeked", l), clearTimeout(u), o.setSourceState({ seekingTo: void 0 });
150
- }, u = setTimeout(l, fe);
228
+ c?.removeEventListener("seeked", l), clearTimeout(u), a.setSourceState({ seekingTo: void 0 });
229
+ }, u = setTimeout(l, Ee);
151
230
  c?.addEventListener("seeked", l);
152
231
  let d = setTimeout(() => {
153
- a = "deadline", s();
232
+ o = "deadline", s();
154
233
  }, T);
155
234
  t.prepareSeek(e).catch(() => {}).finally(() => {
156
235
  clearTimeout(d), s();
157
236
  });
158
- }, [o, T]), q = _((e) => {
159
- if (typeof e != "number" || L.current === void 0) return;
160
- o.setSourceState({ selectedAudioTrack: e }), O({
161
- size: L.current,
237
+ }, [a, T]), re = y((e) => {
238
+ if (typeof e != "number" || I.current === void 0) return;
239
+ a.setSourceState({ selectedAudioTrack: e }), O({
240
+ size: I.current,
162
241
  streamIndex: e
163
242
  });
164
- let t = c(R.current.audio.find((t) => t.streamIndex === e));
165
- t !== void 0 && H.current?.(t);
166
- }, [o]), J = Y((e) => e.setSourceState);
167
- y(() => {
168
- J({
169
- selectSubtitleTrack: te,
170
- selectAudioTrack: q,
171
- requestSeek: K
243
+ let t = u(L.current.audio.find((t) => t.streamIndex === e));
244
+ t !== void 0 && V.current?.(t);
245
+ }, [a]), ie = J((e) => e.setSourceState);
246
+ x(() => {
247
+ ie({
248
+ selectSubtitleTrack: K,
249
+ selectAudioTrack: re,
250
+ requestSeek: q
172
251
  });
173
252
  }, [
174
- J,
175
- te,
176
- q,
177
- K
178
- ]), y(() => {
179
- if (!e || !t || !u || !s) return;
253
+ ie,
254
+ K,
255
+ re,
256
+ q
257
+ ]), x(() => {
258
+ if (!e || !t || !c || !o) return;
180
259
  let n = !1;
181
- o.setSourceState({
260
+ a.setSourceState({
182
261
  playbackError: null,
183
262
  ready: !1
184
263
  });
185
- let i = (t, n) => {
186
- let r = Date.now(), i = me(t), a = he(t), s = o.playbackErrors, c = s[s.length - 1];
187
- if (c && c.message === i && c.detail === a && c.recovered === n) {
264
+ let r = (t, n) => {
265
+ let r = Date.now(), i = Oe(t), o = ke(t), s = a.playbackErrors, c = s[s.length - 1];
266
+ if (c && c.message === i && c.detail === o && c.recovered === n) {
188
267
  let e = {
189
268
  ...c,
190
269
  count: c.count + 1,
191
270
  lastAt: r
192
271
  };
193
- o.setSourceState({ playbackErrors: [...s.slice(0, -1), e] });
272
+ a.setSourceState({ playbackErrors: [...s.slice(0, -1), e] });
194
273
  return;
195
274
  }
196
275
  let l = {
@@ -199,69 +278,69 @@ var ie = {
199
278
  count: 1,
200
279
  atMediaTime: Number.isFinite(e.currentTime) ? e.currentTime : void 0,
201
280
  message: i,
202
- detail: a,
281
+ detail: o,
203
282
  recovered: n
204
283
  };
205
- o.setSourceState({ playbackErrors: [...s, l] });
206
- }, c = (e) => {
284
+ a.setSourceState({ playbackErrors: [...s, l] });
285
+ }, u = (e) => {
207
286
  if (n) return;
208
- let t = r(e);
209
- if (i(e, t), t) {
287
+ let t = i(e);
288
+ if (r(e, t), t) {
210
289
  let t = performance.now();
211
- t - M.current.at > de && (M.current = {
290
+ t - j.current.at > we && (j.current = {
212
291
  count: 0,
213
292
  at: t
214
293
  });
215
- let n = ue[Math.min(M.current.count, ue.length - 1)];
216
- M.current = {
217
- count: M.current.count + 1,
294
+ let n = Ce[Math.min(j.current.count, Ce.length - 1)];
295
+ j.current = {
296
+ count: j.current.count + 1,
218
297
  at: t
219
- }, console.warn(`the media element failed; rebuilding the pipeline${n ? ` in ${n}ms` : ""}`, e), N.current && clearTimeout(N.current), N.current = setTimeout(() => j((e) => e + 1), n);
298
+ }, console.warn(`the media element failed; rebuilding the pipeline${n ? ` in ${n}ms` : ""}`, e), M.current && clearTimeout(M.current), M.current = setTimeout(() => A((e) => e + 1), n);
220
299
  return;
221
300
  }
222
- console.error("playback failed", e), o.setSourceState({ playbackError: e }), ee.current?.(e);
301
+ console.error("playback failed", e), a.setSourceState({ playbackError: e }), ne.current?.(e);
223
302
  };
224
303
  return (async () => {
225
304
  try {
226
- let r = await a({
305
+ let r = await s({
227
306
  videoElement: e,
228
307
  subtitleContainer: t,
229
- read: (e, t) => z.current(e, t),
230
- length: u,
231
- publicPath: d,
308
+ read: (e, t) => R.current(e, t),
309
+ length: c,
310
+ publicPath: l,
232
311
  libavWorkerUrl: f,
233
312
  jassubWorkerUrl: p,
234
313
  jassubWasmUrl: m,
235
314
  jassubLegacyWasmUrl: h,
236
315
  defaultFontUrl: g,
237
- cjkFontUrl: v,
238
- bufferSize: b,
316
+ cjkFontUrl: _,
317
+ bufferSize: v,
239
318
  audioStreamIndex: k,
240
319
  chooseAudioStream: (e) => {
241
- let t = B.current;
242
- return t === void 0 ? void 0 : e[l(t, e)]?.streamIndex;
320
+ let t = z.current;
321
+ return t === void 0 ? void 0 : e[d(t, e)]?.streamIndex;
243
322
  },
244
323
  onReady: () => {
245
324
  if (n) return;
246
- o.setSourceState({ ready: !0 });
247
- let t = F.current;
248
- F.current = null, t && t.size === u && t.time > 0 && (e.currentTime = t.time), C && e.play().catch(() => {});
325
+ a.setSourceState({ ready: !0 });
326
+ let t = P.current;
327
+ P.current = null, t && t.size === c && t.time > 0 && (e.currentTime = t.time), b && e.play().catch(() => {});
249
328
  },
250
- onError: c,
329
+ onError: u,
251
330
  onRecovered: () => {
252
- n || o.setSourceState({ playbackError: null });
331
+ n || a.setSourceState({ playbackError: null });
253
332
  },
254
- onSeek: (e) => W.current?.(e),
255
- onOutput: (e) => G.current?.(e),
333
+ onSeek: (e) => H.current?.(e),
334
+ onOutput: (e) => U.current?.(e),
256
335
  onSubtitleStreams: (e) => {
257
- n || (R.current.subtitles = e, o.setSourceState({
258
- subtitleTracks: X(e),
259
- ...I.current === u ? {} : { selectedSubtitleTrack: pe(V.current, e) }
336
+ n || (L.current.subtitles = e, a.setSourceState({
337
+ subtitleTracks: Se(e, G.current),
338
+ ...F.current === c ? {} : { selectedSubtitleTrack: De(B.current, e) }
260
339
  }));
261
340
  },
262
341
  onAudioStreams: (e, t) => {
263
- n || (R.current.audio = e, o.setSourceState({
264
- audioTracks: X(e),
342
+ n || (L.current.audio = e, a.setSourceState({
343
+ audioTracks: Se(e, G.current),
265
344
  selectedAudioTrack: t
266
345
  }));
267
346
  }
@@ -270,44 +349,44 @@ var ie = {
270
349
  r.destroy();
271
350
  return;
272
351
  }
273
- P.current = r, o.setSourceState({
352
+ N.current = r, a.setSourceState({
274
353
  indexes: r.indexes,
275
354
  chapters: E.current ?? r.chapters
276
355
  });
277
- let i = o.selectedSubtitleTrack;
356
+ let i = a.selectedSubtitleTrack;
278
357
  r.selectSubtitleStream(typeof i == "number" ? i : void 0);
279
358
  } catch (e) {
280
- c(e);
359
+ u(e);
281
360
  }
282
361
  })(), () => {
283
- n = !0, F.current = {
362
+ n = !0, P.current = {
284
363
  time: e.currentTime,
285
- size: u
286
- }, P.current?.destroy(), P.current = null, o.setSourceState({ ready: !1 });
364
+ size: c
365
+ }, N.current?.destroy(), N.current = null, a.setSourceState({ ready: !1 });
287
366
  };
288
367
  }, [
289
- o,
368
+ a,
290
369
  e,
291
370
  t,
292
- u,
293
- d,
371
+ c,
372
+ l,
294
373
  f,
295
374
  p,
296
375
  m,
297
376
  h,
298
377
  g,
378
+ _,
299
379
  v,
300
- b,
301
380
  k,
302
- C,
303
- A
381
+ b,
382
+ ee
304
383
  ]);
305
- }, _e = 1001 / 24e3, ve = (e, t) => new Promise((n) => {
384
+ }, je = 1001 / 24e3, Me = (e, t) => new Promise((n) => {
306
385
  let r = setTimeout(n, t);
307
386
  e.requestVideoFrameCallback(() => {
308
387
  clearTimeout(r), n();
309
388
  });
310
- }), ye = (e) => {
389
+ }), Ne = (e) => {
311
390
  let t = !1, n, r = async (i) => {
312
391
  if (t) {
313
392
  n = i;
@@ -323,14 +402,14 @@ var ie = {
323
402
  }
324
403
  };
325
404
  return r;
326
- }, be = (e, t) => {
327
- let n = Y(), r = Y((e) => e.setSourceState), i = x(t);
405
+ }, Pe = (e, t) => {
406
+ let n = J(), r = J((e) => e.setSourceState), i = C(t);
328
407
  i.current = t;
329
408
  let a = !!t;
330
- y(() => {
409
+ x(() => {
331
410
  let t = e;
332
411
  if (!t) return;
333
- if (typeof t.requestVideoFrameCallback != "function") return a ? (r({ stepFrame: ye(async (e) => {
412
+ if (typeof t.requestVideoFrameCallback != "function") return a ? (r({ stepFrame: Ne(async (e) => {
334
413
  try {
335
414
  await i.current?.(e);
336
415
  } catch (e) {
@@ -349,11 +428,11 @@ var ie = {
349
428
  };
350
429
  d = t.requestVideoFrameCallback(f);
351
430
  let p = () => {
352
- if (c.length < 5) return _e;
431
+ if (c.length < 5) return je;
353
432
  let e = [...c].sort((e, t) => e - t), t = e[e.length >> 1], n = e.filter((e) => Math.abs(e - t) <= t / 4);
354
433
  return n.reduce((e, t) => e + t, 0) / n.length;
355
- }, m = ye(async (e) => {
356
- t.paused || (t.pause(), await ve(t, 100));
434
+ }, m = Ne(async (e) => {
435
+ t.paused || (t.pause(), await Me(t, 100));
357
436
  let r = p(), i = n.state.seekingTo, a = i === void 0 ? o ? o.mediaTime + (e > 0 ? 1.5 : -.5) * r : t.currentTime + e * r : i + e * r, s = Math.max(0, Math.min(a, t.duration || a)), c = new Promise((e) => {
358
437
  let n = setTimeout(e, 1e3);
359
438
  t.addEventListener("seeked", () => {
@@ -371,88 +450,88 @@ var ie = {
371
450
  n,
372
451
  r
373
452
  ]);
374
- }, xe = 5e3, Se = 6e4, Ce = ({ publicPath: e, workerUrl: t, length: n, read: r, downloadedRanges: a }) => {
375
- let [o, s] = S([]), c = x(null), l = x(r);
453
+ }, Fe = 5e3, Ie = 6e4, Le = ({ publicPath: e, workerUrl: t, length: n, read: r, downloadedRanges: i }) => {
454
+ let [a, s] = w([]), c = C(null), l = C(r);
376
455
  l.current = r;
377
- let u = b(() => a?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [a?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")]), d = x(u);
378
- return d.current = u, y(() => {
456
+ let u = S(() => i?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [i?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")]), d = C(u);
457
+ return d.current = u, x(() => {
379
458
  if (!n || !r || !e || !t) return;
380
- let a = !1, o = null, u, f = xe, p = () => {
381
- i({
459
+ let i = !1, a = null, u, f = Fe, p = () => {
460
+ o({
382
461
  publicPath: e,
383
462
  workerUrl: t,
384
463
  length: n,
385
464
  read: (e, t) => l.current(e, t),
386
465
  onThumbnails: (e) => {
387
- a || s(e);
466
+ i || s(e);
388
467
  }
389
468
  }).then((e) => {
390
- if (a) {
469
+ if (i) {
391
470
  e.destroy();
392
471
  return;
393
472
  }
394
- o = e, c.current = e, e.update(d.current);
473
+ a = e, c.current = e, e.update(d.current);
395
474
  }, () => {
396
- a || (u = setTimeout(p, f), f = Math.min(f * 2, Se));
475
+ i || (u = setTimeout(p, f), f = Math.min(f * 2, Ie));
397
476
  });
398
477
  };
399
478
  return p(), () => {
400
- a = !0, clearTimeout(u), c.current = null, o?.destroy(), s([]);
479
+ i = !0, clearTimeout(u), c.current = null, a?.destroy(), s([]);
401
480
  };
402
481
  }, [
403
482
  n,
404
483
  e,
405
484
  t
406
- ]), y(() => {
485
+ ]), x(() => {
407
486
  c.current?.update(u);
408
487
  }, [u]), {
409
- thumbnails: o,
410
- requestThumbnail: _((e) => {
488
+ thumbnails: a,
489
+ requestThumbnail: y((e) => {
411
490
  c.current?.prioritize(e);
412
491
  }, [])
413
492
  };
414
- }, we = (e, t) => {
415
- let r = x(null), [i, a] = S(!1), [s] = S(() => n());
416
- y(() => {
417
- if (!e || !t || !s) return;
418
- let n = o({
493
+ }, Re = (e, t) => {
494
+ let n = C(null), [i, a] = w(!1), [o] = w(() => r());
495
+ x(() => {
496
+ if (!e || !t || !o) return;
497
+ let r = c({
419
498
  video: e,
420
499
  subtitles: t,
421
- mode: s,
500
+ mode: o,
422
501
  onBurnedInChange: a
423
502
  });
424
- return r.current = n, () => {
425
- n.destroy(), r.current = null, a(!1);
503
+ return n.current = r, () => {
504
+ r.destroy(), n.current = null, a(!1);
426
505
  };
427
506
  }, [
428
507
  e,
429
508
  t,
430
- s
509
+ o
431
510
  ]);
432
- let c = _(() => {
433
- r.current?.toggle().catch((e) => {
511
+ let s = y(() => {
512
+ n.current?.toggle().catch((e) => {
434
513
  console.warn("picture in picture was refused", e);
435
514
  });
436
515
  }, []);
437
516
  return {
438
- toggle: e && t && s ? c : null,
439
- mode: s,
517
+ toggle: e && t && o ? s : null,
518
+ mode: o,
440
519
  burnedIn: i
441
520
  };
442
- }, Te = "(hover: hover) and (pointer: fine)", Ee = () => typeof matchMedia == "function" ? matchMedia(Te) : void 0, De = (e) => {
443
- let t = Ee();
521
+ }, ze = "(hover: hover) and (pointer: fine)", Be = () => typeof matchMedia == "function" ? matchMedia(ze) : void 0, Ve = (e) => {
522
+ let t = Be();
444
523
  return t?.addEventListener("change", e), () => t?.removeEventListener("change", e);
445
- }, Oe = () => !!Ee()?.matches, ke = () => !1, Ae = (e, t) => {
446
- let [n, r] = S(!1), [i, a] = S(), o = x(t);
524
+ }, He = () => !!Be()?.matches, Ue = () => !1, We = (e, t) => {
525
+ let [n, r] = w(!1), [i, a] = w(), o = C(t);
447
526
  t && (o.current = t);
448
- let s = x(!1), c = _((e) => {
527
+ let s = C(!1), c = y((e) => {
449
528
  s.current !== e && (s.current = e, o.current?.onArmedChange(e));
450
- }, []), l = _((t) => {
529
+ }, []), l = y((t) => {
451
530
  !e || e.readyState < 1 || e.error || (a(t), c(!0));
452
- }, [e, c]), u = _(() => {
531
+ }, [e, c]), u = y(() => {
453
532
  a(void 0), c(!1);
454
533
  }, [c]), d = !!t && !!e;
455
- y(() => {
534
+ x(() => {
456
535
  if (!d || !e) return;
457
536
  let t = () => {
458
537
  r(!0), u();
@@ -465,8 +544,8 @@ var ie = {
465
544
  d,
466
545
  u
467
546
  ]);
468
- let f = C(De, Oe, ke), [p, m] = S(!1);
469
- y(() => {
547
+ let f = T(Ve, He, Ue), [p, m] = w(!1);
548
+ x(() => {
470
549
  if (!d) return;
471
550
  let e = (e) => {
472
551
  e.pointerType === "touch" && m(!0);
@@ -484,15 +563,15 @@ var ie = {
484
563
  };
485
564
  }, [d]);
486
565
  let h = d && f && !p;
487
- y(() => {
566
+ x(() => {
488
567
  h || u();
489
568
  }, [h, u]);
490
- let g = _(() => {
569
+ let g = y(() => {
491
570
  Promise.resolve(e?.exitPictureInPicture?.()).catch((e) => {
492
571
  console.warn("leaving picture in picture was refused", e);
493
572
  });
494
573
  }, [e]);
495
- return b(() => h ? {
574
+ return S(() => h ? {
496
575
  active: n,
497
576
  armed: i,
498
577
  arm: l,
@@ -506,16 +585,16 @@ var ie = {
506
585
  u,
507
586
  g
508
587
  ]);
509
- }, je = async (e, t, n = {}) => (await e.audioWorklet.addModule(t), new AudioWorkletNode(e, "banou-volume-normalizer", {
588
+ }, Ge = async (e, t, n = {}) => (await e.audioWorklet.addModule(t), new AudioWorkletNode(e, "banou-volume-normalizer", {
510
589
  channelCountMode: "max",
511
590
  processorOptions: n
512
- })), Me = /* @__PURE__ */ new WeakMap(), Ne = (e) => new Promise((t, n) => {
591
+ })), Ke = /* @__PURE__ */ new WeakMap(), qe = (e) => new Promise((t, n) => {
513
592
  let r = () => {
514
593
  (e.state === "running" || e.state === "closed") && (e.removeEventListener("statechange", r), e.state === "running" ? t() : n(new DOMException("The AudioContext closed before it ran", "InvalidStateError")));
515
594
  };
516
595
  e.addEventListener("statechange", r), r();
517
- }), Pe = (e, t, n = {}) => {
518
- let r = Me.get(e);
596
+ }), Je = (e, t, n = {}) => {
597
+ let r = Ke.get(e);
519
598
  if (r) return r.wake(), r;
520
599
  let i = new AudioContext(), a = n.enabled !== !1, o, s = !1, c = () => 20 * Math.log10(Math.max(e.volume, 1e-6)), l = e.ownerDocument, u = () => {
521
600
  i.state === "suspended" && i.resume().catch(() => {});
@@ -531,13 +610,13 @@ var ie = {
531
610
  };
532
611
  i.addEventListener("statechange", f), f();
533
612
  let p = (async () => {
534
- let r = await je(i, t, {
613
+ let r = await Ge(i, t, {
535
614
  ...n,
536
615
  enabled: a,
537
616
  inputGainDb: c()
538
617
  });
539
- await Ne(i);
540
- let s = M(i, e);
618
+ await qe(i);
619
+ let s = I(i, e);
541
620
  return r.port.postMessage({
542
621
  enabled: a,
543
622
  inputGainDb: c()
@@ -553,14 +632,14 @@ var ie = {
553
632
  a = e, o?.port.postMessage({ enabled: a });
554
633
  },
555
634
  release: () => {
556
- s = !0, d(!1), e.isConnected ? i.state === "running" && i.suspend().catch(() => {}) : (Me.delete(e), i.close().catch(() => {}));
635
+ s = !0, d(!1), e.isConnected ? i.state === "running" && i.suspend().catch(() => {}) : (Ke.delete(e), i.close().catch(() => {}));
557
636
  },
558
637
  wake: () => {
559
638
  i.state !== "closed" && (s = !1, u(), f());
560
639
  }
561
640
  };
562
- return Me.set(e, m), m;
563
- }, Fe = 20, Ie = 5, Le = 1, Re = 50, ze = ({ node: t, element: n, scriptUrl: r, source: i }) => {
641
+ return Ke.set(e, m), m;
642
+ }, Ye = 20, Xe = 5, Ze = 1, Qe = 50, $e = ({ node: t, element: n, scriptUrl: r, source: i }) => {
564
643
  let a = !1, o, s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = () => {
565
644
  for (let e of [...c]) e();
566
645
  c.clear();
@@ -591,7 +670,7 @@ var ie = {
591
670
  }, g = 0, _ = /* @__PURE__ */ new Map(), v = (e, t) => new Promise((n) => _.set(`${e}:${t}`, n)), y = -1;
592
671
  p.onmessage = ({ data: e }) => {
593
672
  if (e.type === "unsupported") {
594
- G();
673
+ U();
595
674
  return;
596
675
  }
597
676
  e.spans && ((JSON.stringify(e.spans) !== JSON.stringify(h.spans) || e.end !== h.end) && g++, h = {
@@ -607,7 +686,7 @@ var ie = {
607
686
  }), S = () => p.postMessage({
608
687
  type: "playhead",
609
688
  time: n.currentTime
610
- }), C = setInterval(x, Re), w = [
689
+ }), C = setInterval(x, Qe), w = [
611
690
  "play",
612
691
  "playing",
613
692
  "pause",
@@ -618,25 +697,25 @@ var ie = {
618
697
  "ended"
619
698
  ];
620
699
  for (let e of w) n.addEventListener(e, x);
621
- let T = Infinity, E = !1, D = 0, O = !1, k = 0, A = 0, M = /* @__PURE__ */ new Map(), N = (e) => {
700
+ let T = Infinity, E = !1, D = 0, O = !1, k = 0, ee = 0, A = /* @__PURE__ */ new Map(), j = (e) => {
622
701
  let t = e;
623
702
  for (let [e, n] of h.spans) e <= t && t < n && (t = n);
624
703
  return t >= (h.end ?? T) - .05 ? null : t;
625
- }, P = (e) => M.get(Math.round(e * 10)) === g ? "idle" : e, F = () => {
626
- let e = n.currentTime, t = N(e), r = O && y !== D;
627
- if (t !== null && t < e + Fe) return r && k <= t + 1 && t <= A + Ie ? "read" : P(t);
704
+ }, N = (e) => A.get(Math.round(e * 10)) === g ? "idle" : e, P = () => {
705
+ let e = n.currentTime, t = j(e), r = O && y !== D;
706
+ if (t !== null && t < e + Ye) return r && k <= t + 1 && t <= ee + Xe ? "read" : N(t);
628
707
  if (r) return "read";
629
- let i = t ?? N(0);
630
- return i === null ? "done" : P(i);
631
- }, I = () => {}, L = (e) => (e.catch(() => {}), Promise.race([e, new Promise((e) => {
632
- I = () => e(void 0);
633
- })])), R = () => {
634
- S(), E && s.size && typeof F() == "number" && I(), l();
635
- }, z = () => {
708
+ let i = t ?? j(0);
709
+ return i === null ? "done" : N(i);
710
+ }, F = () => {}, I = (e) => (e.catch(() => {}), Promise.race([e, new Promise((e) => {
711
+ F = () => e(void 0);
712
+ })])), L = () => {
713
+ S(), E && s.size && typeof P() == "number" && F(), l();
714
+ }, R = () => {
636
715
  S(), l();
637
716
  };
638
- n.addEventListener("seeking", R), n.addEventListener("seeked", z), n.addEventListener("timeupdate", z);
639
- let B, V = async (e) => {
717
+ n.addEventListener("seeking", L), n.addEventListener("seeked", R), n.addEventListener("timeupdate", R);
718
+ let z, B = async (e) => {
640
719
  if (!O) return;
641
720
  O = !1;
642
721
  let t = v("ended", D);
@@ -645,24 +724,24 @@ var ie = {
645
724
  run: D,
646
725
  finished: e
647
726
  }), await t;
648
- }, H = async (e) => {
649
- if (A = e.pts + e.duration, !e.data.byteLength) return;
727
+ }, V = async (e) => {
728
+ if (ee = e.pts + e.duration, !e.data.byteLength) return;
650
729
  let t = v("ack", D);
651
730
  p.postMessage({
652
731
  type: "fragment",
653
732
  run: D,
654
733
  data: e.data
655
734
  }, [e.data]), await t;
656
- }, U = async (t) => {
657
- if (B = await j({
735
+ }, te = async (t) => {
736
+ if (z = await M({
658
737
  publicPath: t.publicPath,
659
738
  workerUrl: t.libavWorkerUrl,
660
739
  workerOptions: { type: "module" },
661
740
  length: t.length,
662
741
  read: (e, n) => d(t, e, n),
663
742
  audioStreamIndex: t.audioStreamIndex
664
- }), a) return e(B);
665
- let n = await B.init();
743
+ }), a) return e(z);
744
+ let n = await z.init();
666
745
  if (!a) {
667
746
  for (T = n.info.input.duration || Infinity, p.postMessage({
668
747
  type: "init",
@@ -671,10 +750,11 @@ var ie = {
671
750
  }, [n.data]), O = !0, E = !0, p.postMessage({
672
751
  type: "run",
673
752
  run: D,
674
- pts: 0,
753
+ pts: n.timestampOffset,
754
+ from: 0,
675
755
  start: !0
676
756
  }); !a;) {
677
- let e = F();
757
+ let e = P();
678
758
  if (e === "done") break;
679
759
  if (e === "idle") {
680
760
  await u();
@@ -682,32 +762,33 @@ var ie = {
682
762
  }
683
763
  try {
684
764
  if (e === "read") {
685
- let e = await L(B.read());
765
+ let e = await I(z.read());
686
766
  if (a) return;
687
767
  if (!e) continue;
688
- await H(e), e.finished && await V(!0);
768
+ await V(e), e.finished && await B(!0);
689
769
  } else {
690
- await V(!1), M.set(Math.round(e * 10), g);
691
- let t = B.seek(Math.max(0, e - Le));
770
+ await B(!1), A.set(Math.round(e * 10), g);
771
+ let t = z.seek(Math.max(0, e - Ze));
692
772
  f(!0);
693
- let n = await L(t);
773
+ let r = await I(t);
694
774
  if (a) return;
695
- if (!n) continue;
696
- D++, O = !0, k = n.pts, p.postMessage({
775
+ if (!r) continue;
776
+ D++, O = !0, k = r.pts, p.postMessage({
697
777
  type: "run",
698
778
  run: D,
699
- pts: n.pts,
700
- start: n.pts <= 0
701
- }), await H(n), n.finished && await V(!0);
779
+ pts: n.timestampOffset,
780
+ from: r.pts,
781
+ start: r.pts <= 0
782
+ }), await V(r), r.finished && await B(!0);
702
783
  }
703
784
  } catch {
704
785
  if (a) return;
705
- await V(!1), typeof F() != "number" && await u();
786
+ await B(!1), typeof P() != "number" && await u();
706
787
  }
707
788
  }
708
- e(B), B = void 0;
789
+ e(z), z = void 0;
709
790
  }
710
- }, W = () => {}, ee = (e, t) => {
791
+ }, H = () => {}, ne = (e, t) => {
711
792
  let n = !1, r = (e) => {
712
793
  n && p.postMessage({
713
794
  type: "end",
@@ -715,7 +796,7 @@ var ie = {
715
796
  finished: e
716
797
  }), n = !1;
717
798
  };
718
- W = e.attach(t, (e, t) => {
799
+ H = e.attach(t, (e, t) => {
719
800
  if (e.type === "init") {
720
801
  r(!1);
721
802
  let t = e.data.slice(0);
@@ -728,7 +809,8 @@ var ie = {
728
809
  type: "run",
729
810
  run: ++D,
730
811
  pts: e.pts,
731
- start: !t && e.pts <= 0,
812
+ from: e.from,
813
+ start: !t && e.from <= 0,
732
814
  join: t
733
815
  });
734
816
  else if (e.type === "end") r(!0);
@@ -741,29 +823,29 @@ var ie = {
741
823
  }, [t]);
742
824
  }
743
825
  });
744
- }, G = () => {
826
+ }, U = () => {
745
827
  if (!a) {
746
828
  a = !0, f(!0), l(), clearInterval(C);
747
829
  for (let e of w) n.removeEventListener(e, x);
748
- n.removeEventListener("seeking", R), n.removeEventListener("seeked", z), n.removeEventListener("timeupdate", z), W(), B && e(B), p.terminate(), t.port.postMessage({ analysis: null });
830
+ n.removeEventListener("seeking", L), n.removeEventListener("seeked", R), n.removeEventListener("timeupdate", R), H(), z && e(z), p.terminate(), t.port.postMessage({ analysis: null });
749
831
  for (let e of _.values()) e(h);
750
832
  _.clear();
751
833
  }
752
834
  };
753
- return "tap" in i ? ee(i.tap, i.audioStreamIndex) : U(i).catch((e) => {
754
- a || (console.warn("[media-player] the volume normalizer cannot analyse ahead:", e), G());
835
+ return "tap" in i ? ne(i.tap, i.audioStreamIndex) : te(i).catch((e) => {
836
+ a || (console.warn("[media-player] the volume normalizer cannot analyse ahead:", e), U());
755
837
  }), S(), {
756
838
  update: (e) => {
757
839
  o = e, f(!1);
758
840
  },
759
- stop: G
841
+ stop: U
760
842
  };
761
- }, Be = (e, t, n, r, i) => {
762
- let a = x(null), [o, s] = S(!1), [c, l] = S(null);
763
- y(() => {
843
+ }, et = (e, t, n, r, i) => {
844
+ let a = C(null), [o, s] = w(!1), [c, l] = w(null);
845
+ x(() => {
764
846
  if (e && t) {
765
847
  if (n && !a.current) {
766
- let r = Pe(e, t, { enabled: n });
848
+ let r = Je(e, t, { enabled: n });
767
849
  a.current = r, r.routed.then((e) => {
768
850
  a.current === r && l(e);
769
851
  }, (e) => {
@@ -776,18 +858,18 @@ var ie = {
776
858
  e,
777
859
  t,
778
860
  n
779
- ]), y(() => () => {
861
+ ]), x(() => () => {
780
862
  a.current?.release(), a.current = null, l(null);
781
863
  }, [e]);
782
- let u = x(i);
864
+ let u = C(i);
783
865
  u.current = i;
784
- let d = x(null), f = x(r);
866
+ let d = C(null), f = C(r);
785
867
  f.current = r;
786
868
  let { length: p, publicPath: m, libavWorkerUrl: h } = r && "read" in r ? r : {}, g = r && "tap" in r ? r.tap : void 0, _ = r?.audioStreamIndex;
787
- return y(() => {
869
+ return x(() => {
788
870
  let r = f.current;
789
871
  if (!c || !e || !t || !n || !r) return;
790
- let i = ze({
872
+ let i = $e({
791
873
  node: c,
792
874
  element: e,
793
875
  scriptUrl: t,
@@ -806,15 +888,15 @@ var ie = {
806
888
  h,
807
889
  _,
808
890
  g
809
- ]), y(() => {
891
+ ]), x(() => {
810
892
  d.current?.update(i);
811
893
  }, [i]), { refused: o };
812
- }, Ve = () => {
894
+ }, tt = () => {
813
895
  let e, t, n, r = () => n && e?.audioStreamIndex === n.audioStreamIndex ? n : void 0;
814
896
  return {
815
897
  push: (n) => {
816
898
  n.type === "init" ? (e = n, t = void 0) : n.type === "run" ? t = {
817
- pts: n.pts,
899
+ output: n,
818
900
  begun: !1
819
901
  } : n.type === "fragment" && t && (t.begun = !0), r()?.take(n);
820
902
  },
@@ -823,15 +905,12 @@ var ie = {
823
905
  audioStreamIndex: i,
824
906
  take: a
825
907
  };
826
- return n = o, r() && e && (a(e), t && a({
827
- type: "run",
828
- pts: t.pts
829
- }, t.begun)), () => {
908
+ return n = o, r() && e && (a(e), t && a(t.output, t.begun)), () => {
830
909
  n === o && (n = void 0);
831
910
  };
832
911
  }
833
912
  };
834
- }, Q = {
913
+ }, $ = {
835
914
  headings: {
836
915
  large: "\n font-weight: 600;\n font-size: calc(2.8 * var(--mp-unit));\n line-height: calc(3.4 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(3.4 * var(--mp-unit));\n line-height: calc(4.1 * var(--mp-unit));\n }\n ",
837
916
  medium: "\n font-weight: 600;\n font-size: calc(2.4 * var(--mp-unit));\n line-height: calc(2.9 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(2.8 * var(--mp-unit));\n line-height: calc(3.4 * var(--mp-unit));\n }\n ",
@@ -858,7 +937,7 @@ var ie = {
858
937
  medium: "\n font-weight: 500;\n font-size: calc(0.8 * var(--mp-unit));\n line-height: calc(1.1 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1 * var(--mp-unit));\n line-height: calc(1.4 * var(--mp-unit));\n }\n ",
859
938
  regular: "\n font-weight: 400;\n font-size: calc(0.8 * var(--mp-unit));\n line-height: calc(1.1 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1 * var(--mp-unit));\n line-height: calc(1.4 * var(--mp-unit));\n }\n "
860
939
  }
861
- }, He = w`
940
+ }, nt = E`
862
941
  display: flex;
863
942
  justify-content: center;
864
943
  align-items: center;
@@ -871,7 +950,7 @@ var ie = {
871
950
  margin: auto;
872
951
  pointer-events: none;
873
952
  }
874
- `, Ue = w`
953
+ `, rt = E`
875
954
  position: absolute;
876
955
  top: 0;
877
956
  left: 0;
@@ -879,7 +958,7 @@ var ie = {
879
958
  padding: calc(1.2 * var(--mp-unit)) calc(1.6 * var(--mp-unit));
880
959
  /* clears a notch once the player is fullscreen; resolves to zero everywhere else */
881
960
  padding-top: calc(calc(1.2 * var(--mp-unit)) + env(safe-area-inset-top, 0px));
882
- ${Q.headings.small}
961
+ ${$.headings.small}
883
962
  color: white;
884
963
  text-shadow: 0 0 4px rgba(0, 0, 0, 1);
885
964
  z-index: 2;
@@ -900,9 +979,9 @@ var ie = {
900
979
 
901
980
  background: linear-gradient(180deg, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.3) 30%, rgba(0,0,0,0.2) 60%, rgba(0,0,0,0.1) 80%, transparent 100%);
902
981
  transition: opacity 0.1s cubic-bezier(.4,0,1,1);
903
- `, We = T`
982
+ `, it = D`
904
983
  to { transform: rotate(360deg); }
905
- `, Ge = w`
984
+ `, at = E`
906
985
  position: absolute;
907
986
  inset: 0;
908
987
  z-index: 2;
@@ -918,46 +997,46 @@ var ie = {
918
997
  border-radius: 50%;
919
998
  border: 3px solid rgba(255, 255, 255, 0.25);
920
999
  border-top-color: #fff;
921
- animation: ${We} 0.8s linear infinite;
1000
+ animation: ${it} 0.8s linear infinite;
922
1001
  }
923
- `, Ke = w`
1002
+ `, ot = E`
924
1003
  position: absolute;
925
1004
  inset: auto 0 20%;
926
1005
  z-index: 3;
927
1006
  padding: 0 calc(2 * var(--mp-unit));
928
1007
  text-align: center;
929
1008
  color: #fff;
930
- ${Q.bLarge.regular}
1009
+ ${$.bLarge.regular}
931
1010
  text-shadow: 0 0 4px rgba(0, 0, 0, 1);
932
1011
  pointer-events: none;
933
- `, qe = (e) => e instanceof Error ? e.message : typeof e == "string" ? e : "Playback failed", Je = ({ onSubtitleRef: e }) => {
934
- let t = Y((e) => e.title), n = Y((e) => e.hideUI), r = Y((e) => e.playbackError), i = Y((e) => e.ready), a = Y((e) => e.size), o = Y((e) => e.waiting), s = Y((e) => e.seekingTo);
1012
+ `, st = new Set(Object.values(a)), ct = (e) => e instanceof Error && st.has(e.label ?? ""), lt = (e, { format: t }) => ct(e) ? t(e.label, e.values) : e instanceof Error ? e.message : typeof e == "string" ? e : t(a.failed), ut = ({ onSubtitleRef: e }) => {
1013
+ let t = Q(), n = J((e) => e.title), r = J((e) => e.hideUI), i = J((e) => e.playbackError), a = J((e) => e.ready), o = J((e) => e.size), s = J((e) => e.waiting), c = J((e) => e.seekingTo);
935
1014
  return /* @__PURE__ */ F(N, { children: [
936
- t ? /* @__PURE__ */ P("div", {
1015
+ n ? /* @__PURE__ */ P("div", {
937
1016
  className: "title",
938
- css: Ue,
939
- style: { ...n ? {
1017
+ css: rt,
1018
+ style: { ...r ? {
940
1019
  opacity: "0",
941
1020
  pointerEvents: "none"
942
1021
  } : {} },
943
- children: t
1022
+ children: n
944
1023
  }) : void 0,
945
- ((a ? !i : o) || s !== void 0) && !r ? /* @__PURE__ */ P("div", { css: Ge }) : void 0,
946
- r ? /* @__PURE__ */ P("div", {
947
- css: Ke,
948
- children: qe(r)
1024
+ ((o ? !a : s) || c !== void 0) && !i ? /* @__PURE__ */ P("div", { css: at }) : void 0,
1025
+ i ? /* @__PURE__ */ P("div", {
1026
+ css: ot,
1027
+ children: lt(i, t)
949
1028
  }) : void 0,
950
1029
  /* @__PURE__ */ P("div", {
951
1030
  className: "subtitles",
952
1031
  ref: e,
953
- css: He
1032
+ css: nt
954
1033
  })
955
1034
  ] });
956
- }, Ye = 1e-4, Xe = 1, Ze = (e) => Math.max(Ye, Math.min(Xe, e)) ** 2, Qe = (e) => Math.max(Ye, Math.min(Xe, e)) ** (Xe / 2), $e = (e) => {
1035
+ }, dt = 1e-4, ft = 1, pt = (e) => Math.max(dt, Math.min(ft, e)) ** 2, mt = (e) => Math.max(dt, Math.min(ft, e)) ** (ft / 2), ht = (e) => {
957
1036
  if (e === void 0) return "0:00";
958
1037
  let t = Math.floor(e / 3600), n = Math.floor(e % 3600 / 60), r = Math.floor(e % 60);
959
1038
  return t > 0 ? `${t}:${n < 10 ? "0" : ""}${n}:${r < 10 ? "0" : ""}${r}` : `${n}:${r < 10 ? "0" : ""}${r}`;
960
- }, et = (e, t) => `${$e(e)} / ${$e(t)}`, tt = (e) => w`
1039
+ }, gt = (e, t) => `${ht(e)} / ${ht(t)}`, _t = (e) => E`
961
1040
  display: flex;
962
1041
  justify-content: flex-start;
963
1042
 
@@ -989,37 +1068,37 @@ var ie = {
989
1068
  z-index: 3;
990
1069
 
991
1070
  * {
992
- ${Q.bMedium.regular}
1071
+ ${$.bMedium.regular}
993
1072
  }
994
1073
 
995
- ${e === "sm" && w`
1074
+ ${e === "sm" && E`
996
1075
  padding: calc(0.4 * var(--mp-unit))!important;
997
1076
  `}
998
- ${e === "md" && w`
1077
+ ${e === "md" && E`
999
1078
  padding: calc(0.6 * var(--mp-unit))!important;
1000
1079
  `}
1001
- ${e === "lg" && w`
1080
+ ${e === "lg" && E`
1002
1081
  padding: calc(1.2 * var(--mp-unit))!important;
1003
1082
  `}
1004
- `, nt = {
1083
+ `, vt = {
1005
1084
  x: -1,
1006
1085
  y: -1,
1007
1086
  anchors: 0
1008
- }, rt = (e) => {
1009
- nt.x = e.clientX, nt.y = e.clientY;
1010
- }, it = () => (nt.anchors++ === 0 && window.addEventListener("pointermove", rt, {
1087
+ }, yt = (e) => {
1088
+ vt.x = e.clientX, vt.y = e.clientY;
1089
+ }, bt = () => (vt.anchors++ === 0 && window.addEventListener("pointermove", yt, {
1011
1090
  capture: !0,
1012
1091
  passive: !0
1013
1092
  }), () => {
1014
- --nt.anchors === 0 && window.removeEventListener("pointermove", rt, { capture: !0 });
1015
- }), at = h(!1), $ = ({ id: e, toolTipText: t, text: n, delayShow: r = 0, closeDelay: i = 0, offset: a = 20, tooltipPlace: o = "top", disabled: s = !1, size: c = "md" }) => {
1016
- let l = x(null), u = x(null), d = v(at);
1017
- return y(() => {
1018
- let e = it(), t = () => {
1093
+ --vt.anchors === 0 && window.removeEventListener("pointermove", yt, { capture: !0 });
1094
+ }), xt = _(!1), St = ({ id: e, toolTipText: t, text: n, delayShow: r = 0, closeDelay: i = 0, offset: a = 20, tooltipPlace: o = "top", disabled: s = !1, size: c = "md" }) => {
1095
+ let l = C(null), u = C(null), d = b(xt);
1096
+ return x(() => {
1097
+ let e = bt(), t = () => {
1019
1098
  let e = l.current;
1020
1099
  if (!e) return;
1021
1100
  let { left: t, right: n, top: r, bottom: i } = e.getBoundingClientRect();
1022
- nt.x >= t && nt.x < n && nt.y >= r && nt.y < i || u.current?.close();
1101
+ vt.x >= t && vt.x < n && vt.y >= r && vt.y < i || u.current?.close();
1023
1102
  }, n = ["fullscreenchange", "webkitfullscreenchange"];
1024
1103
  for (let e of n) document.addEventListener(e, t);
1025
1104
  return d && window.addEventListener("resize", t), () => {
@@ -1036,22 +1115,22 @@ var ie = {
1036
1115
  "data-tooltip-delay-hide": i,
1037
1116
  "data-tooltip-place": o,
1038
1117
  children: n
1039
- }), !s && /* @__PURE__ */ P(re, {
1118
+ }), !s && /* @__PURE__ */ P(oe, {
1040
1119
  ref: u,
1041
- css: tt(c),
1120
+ css: _t(c),
1042
1121
  id: e,
1043
1122
  noArrow: !0,
1044
1123
  children: t
1045
1124
  })] });
1046
- }, ot = ({ ref: e, onChange: t, orientation: n = "horizontal", disabled: r = !1 }) => {
1047
- let [i, a] = S(!1), o = x(t);
1125
+ }, Ct = ({ ref: e, onChange: t, orientation: n = "horizontal", disabled: r = !1 }) => {
1126
+ let [i, a] = w(!1), o = C(t);
1048
1127
  o.current = t;
1049
- let s = x(null), c = _((t, r) => {
1128
+ let s = C(null), c = y((t, r) => {
1050
1129
  let i = e.current;
1051
1130
  if (!i) return 0;
1052
1131
  let { left: a, right: o, top: s, bottom: c } = i.getBoundingClientRect(), l = n === "horizontal" ? (t - a) / (o - a) : (c - r) / (c - s);
1053
1132
  return Math.min(Math.max(l, 0), 1);
1054
- }, [e, n]), l = _((e) => {
1133
+ }, [e, n]), l = y((e) => {
1055
1134
  if (!(r || e.button > 0)) {
1056
1135
  s.current = e.pointerId;
1057
1136
  try {
@@ -1059,9 +1138,9 @@ var ie = {
1059
1138
  } catch {}
1060
1139
  a(!0), o.current(c(e.clientX, e.clientY));
1061
1140
  }
1062
- }, [r, c]), u = _((e) => {
1141
+ }, [r, c]), u = y((e) => {
1063
1142
  s.current === e.pointerId && o.current(c(e.clientX, e.clientY));
1064
- }, [c]), d = _((e) => {
1143
+ }, [c]), d = y((e) => {
1065
1144
  if (s.current === e.pointerId) {
1066
1145
  s.current = null;
1067
1146
  try {
@@ -1070,7 +1149,7 @@ var ie = {
1070
1149
  a(!1);
1071
1150
  }
1072
1151
  }, []);
1073
- return y(() => {
1152
+ return x(() => {
1074
1153
  r && (s.current = null, a(!1));
1075
1154
  }, [r]), {
1076
1155
  dragging: i,
@@ -1082,7 +1161,7 @@ var ie = {
1082
1161
  style: { touchAction: "none" }
1083
1162
  }
1084
1163
  };
1085
- }, st = w`
1164
+ }, wt = E`
1086
1165
  position: relative;
1087
1166
  height: calc(.4 * var(--mp-unit));
1088
1167
 
@@ -1167,7 +1246,7 @@ var ie = {
1167
1246
  box-shadow: 0 0 calc(1 * var(--mp-unit)) rgba(0, 0, 0, .5);
1168
1247
 
1169
1248
  text-shadow: 0 0 4px rgba(0, 0, 0, 1);
1170
- ${Q.bMedium.bold}
1249
+ ${$.bMedium.bold}
1171
1250
 
1172
1251
  gap: calc(.6 * var(--mp-unit));
1173
1252
 
@@ -1301,46 +1380,46 @@ var ie = {
1301
1380
  --thumbnail-width: calc(18 * var(--mp-unit));
1302
1381
  --thumbnail-half: calc(9 * var(--mp-unit));
1303
1382
  }
1304
- `, ct = 4, lt = () => {
1305
- let e = Y(), t = Y((e) => e.currentTime), n = Y((e) => e.requestSeek), r = Y((e) => e.duration), i = Y((e) => e.size), a = Y((e) => e.downloadedRanges), o = Y((e) => e.buffered), s = Y((e) => e.indexes), c = Y((e) => e.thumbnails), l = Y((e) => e.thumbnailAt), f = Y((e) => e.requestThumbnail), p = Y((e) => e.chapters), m = Y((e) => e.seekingTo), h = Y((e) => e.setSourceState), g = Y((e) => e.hideUI), _ = x(null), [v, C] = S(void 0), [w, T] = S(void 0), E = (e) => {
1306
- T(e), f(e);
1307
- }, D = !!w;
1308
- y(() => {
1383
+ `, Tt = 4, Et = () => {
1384
+ let e = J(), t = J((e) => e.currentTime), n = J((e) => e.requestSeek), r = J((e) => e.duration), i = J((e) => e.size), a = J((e) => e.downloadedRanges), o = J((e) => e.buffered), s = J((e) => e.indexes), c = J((e) => e.thumbnails), l = J((e) => e.thumbnailAt), u = J((e) => e.requestThumbnail), d = J((e) => e.chapters), m = J((e) => e.seekingTo), h = J((e) => e.setSourceState), g = J((e) => e.hideUI), _ = C(null), [v, y] = w(void 0), [b, T] = w(void 0), E = (e) => {
1385
+ T(e), u(e);
1386
+ }, D = !!b;
1387
+ x(() => {
1309
1388
  if (D) return h({ seekPreview: !0 }), () => h({ seekPreview: !1 });
1310
- }, [h, D]), y(() => {
1389
+ }, [h, D]), x(() => {
1311
1390
  g && E(void 0);
1312
1391
  }, [g]);
1313
- let O = x(void 0), k = x(0), A = x(void 0), j = x(void 0), M = x(!1), { dragging: N, handlers: I } = ot({
1392
+ let O = C(void 0), k = C(0), ee = C(void 0), A = C(void 0), j = C(!1), { dragging: M, handlers: N } = Ct({
1314
1393
  ref: _,
1315
1394
  onChange: (e) => {
1316
- if (k.current += 1, A.current = e, j.current === void 0) j.current = e;
1317
- else if (!M.current) {
1395
+ if (k.current += 1, ee.current = e, A.current === void 0) A.current = e;
1396
+ else if (!j.current) {
1318
1397
  let t = _.current?.getBoundingClientRect().width ?? 0;
1319
- Math.abs(e - j.current) * t > ct && (M.current = !0);
1398
+ Math.abs(e - A.current) * t > Tt && (j.current = !0);
1320
1399
  }
1321
- C(e), O.current !== "mouse" && E(e * r);
1400
+ y(e), O.current !== "mouse" && E(e * r);
1322
1401
  }
1323
- }), L = (e) => {
1324
- O.current = e.pointerType, k.current = 0, j.current = void 0, M.current = !1, I.onPointerDown(e);
1325
- }, R = (t) => {
1326
- I.onPointerUp(t);
1327
- let i = k.current > 0 ? A.current : void 0;
1402
+ }), I = (e) => {
1403
+ O.current = e.pointerType, k.current = 0, A.current = void 0, j.current = !1, N.onPointerDown(e);
1404
+ }, L = (t) => {
1405
+ N.onPointerUp(t);
1406
+ let i = k.current > 0 ? ee.current : void 0;
1328
1407
  if (i !== void 0 && r) {
1329
1408
  let t = i * r;
1330
1409
  n ? n(t) : e.seek(t);
1331
1410
  }
1332
- k.current = 0, M.current = !1, j.current = void 0, t.pointerType !== "mouse" && E(void 0);
1333
- }, z = (e) => {
1411
+ k.current = 0, j.current = !1, A.current = void 0, t.pointerType !== "mouse" && E(void 0);
1412
+ }, R = (e) => {
1334
1413
  if (!_.current) return;
1335
1414
  let { left: t, right: n } = _.current.getBoundingClientRect();
1336
1415
  return Math.min(Math.max((e - t) / (n - t), 0), 1) * r;
1337
- }, B = x("mouse"), V = (e) => {
1338
- B.current = e.pointerType;
1339
- }, H = (e) => {
1340
- B.current !== "touch" && E(z(e.clientX));
1341
- }, U = () => {
1416
+ }, z = C("mouse"), B = (e) => {
1417
+ z.current = e.pointerType;
1418
+ }, V = (e) => {
1419
+ z.current !== "touch" && E(R(e.clientX));
1420
+ }, te = () => {
1342
1421
  _.current && E(void 0);
1343
- }, W = (e) => r ? e / r * 100 : 0, ee = (e, t, n) => {
1422
+ }, H = (e) => r ? e / r * 100 : 0, ne = (e, t, n) => {
1344
1423
  let r = Number((n - t).toFixed(4)), i = t * 100;
1345
1424
  return /* @__PURE__ */ P("div", {
1346
1425
  className: "loaded-part",
@@ -1349,10 +1428,10 @@ var ie = {
1349
1428
  marginLeft: `${i}%`
1350
1429
  }
1351
1430
  }, e);
1352
- }, G = b(() => i === void 0 ? r ? o.map(([e, t], n) => ee(n, e / r, t / r)) : [] : a?.map((e, t) => {
1431
+ }, U = S(() => i === void 0 ? r ? o.map(([e, t], n) => ne(n, e / r, t / r)) : [] : a?.map((e, t) => {
1353
1432
  if (!i || !r) return null;
1354
1433
  let n = s.filter((t) => e.startByteOffset <= t.pos && t.pos <= e.endByteOffset), a = n.at(0), o = n.at(-1);
1355
- return !a || !o ? null : ee(t, a.timestamp / r, o.timestamp / r);
1434
+ return !a || !o ? null : ne(t, a.timestamp / r, o.timestamp / r);
1356
1435
  }) ?? [], [
1357
1436
  r,
1358
1437
  i,
@@ -1360,114 +1439,114 @@ var ie = {
1360
1439
  s.length,
1361
1440
  a?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}/${t}`).join(",")
1362
1441
  ]);
1363
- y(() => {
1364
- v !== void 0 && r && N && M.current && e.seek(v * r);
1442
+ x(() => {
1443
+ v !== void 0 && r && M && j.current && e.seek(v * r);
1365
1444
  }, [
1366
1445
  e,
1367
- N,
1446
+ M,
1368
1447
  v,
1369
1448
  r
1370
1449
  ]);
1371
- let te = b(() => {
1450
+ let W = S(() => {
1372
1451
  if (!r) return 0;
1373
- if (N && v !== void 0) return v;
1452
+ if (M && v !== void 0) return v;
1374
1453
  let e = m ?? t;
1375
1454
  return typeof e == "number" ? e / r : 0;
1376
1455
  }, [
1377
1456
  r,
1378
1457
  t,
1379
- N,
1458
+ M,
1380
1459
  v,
1381
1460
  m
1382
- ]), K = b(() => u(p, r), [p, r]), q = K.length > 0, J = b(() => {
1383
- if (!q || w === void 0 || !r) return -1;
1384
- let e = w / r * 100, t = K.findIndex((t, n) => n < K.length - 1 && e >= t && e < K[n + 1]);
1385
- return t >= 0 ? t : K.length - 2;
1461
+ ]), G = S(() => f(d, r), [d, r]), K = G.length > 0, q = S(() => {
1462
+ if (!K || b === void 0 || !r) return -1;
1463
+ let e = b / r * 100, t = G.findIndex((t, n) => n < G.length - 1 && e >= t && e < G[n + 1]);
1464
+ return t >= 0 ? t : G.length - 2;
1386
1465
  }, [
1387
- q,
1388
1466
  K,
1389
- w,
1467
+ G,
1468
+ b,
1390
1469
  r
1391
- ]), ne = b(() => q ? d(K, (e) => e !== J) : void 0, [
1392
- q,
1470
+ ]), re = S(() => K ? p(G, (e) => e !== q) : void 0, [
1393
1471
  K,
1394
- J
1395
- ]), re = b(() => J >= 0 ? d(K, (e) => e === J) : void 0, [K, J]), ie = b(() => {
1396
- if (w !== void 0) return p.find(({ start: e, end: t }) => e <= w && w < t);
1397
- }, [p, w]), ae = b(() => {
1398
- if (w) {
1399
- if (l) return l(w);
1400
- if (c.length) return c.find(({ startTime: e, endTime: t }) => e <= w && w < t);
1472
+ G,
1473
+ q
1474
+ ]), ie = S(() => q >= 0 ? p(G, (e) => e === q) : void 0, [G, q]), ae = S(() => {
1475
+ if (b !== void 0) return d.find(({ start: e, end: t }) => e <= b && b < t);
1476
+ }, [d, b]), oe = S(() => {
1477
+ if (b) {
1478
+ if (l) return l(b);
1479
+ if (c.length) return c.find(({ startTime: e, endTime: t }) => e <= b && b < t);
1401
1480
  }
1402
1481
  }, [
1403
1482
  c,
1404
1483
  l,
1405
- w
1406
- ]), oe = (e, t) => /* @__PURE__ */ F("div", {
1484
+ b
1485
+ ]), se = (e, t) => /* @__PURE__ */ F("div", {
1407
1486
  className: e ? `track ${e}` : "track",
1408
1487
  style: t ? { maskImage: t } : void 0,
1409
1488
  children: [
1410
1489
  /* @__PURE__ */ P("div", { className: "background-bar" }),
1411
1490
  /* @__PURE__ */ P("div", {
1412
1491
  className: "loaded",
1413
- children: G
1492
+ children: U
1414
1493
  }),
1415
1494
  /* @__PURE__ */ P("div", {
1416
1495
  className: "play-container",
1417
1496
  children: /* @__PURE__ */ P("div", {
1418
1497
  className: "play",
1419
- style: { transform: `scaleX(${te})` }
1498
+ style: { transform: `scaleX(${W})` }
1420
1499
  })
1421
1500
  })
1422
1501
  ]
1423
1502
  });
1424
1503
  return /* @__PURE__ */ F("div", {
1425
- css: st,
1504
+ css: wt,
1426
1505
  ref: _,
1427
1506
  className: [
1428
1507
  "progress-bar",
1429
- N ? "dragging" : "",
1430
- q ? "segmented" : ""
1508
+ M ? "dragging" : "",
1509
+ K ? "segmented" : ""
1431
1510
  ].filter(Boolean).join(" "),
1432
- onPointerDown: V,
1433
- onPointerMove: V,
1434
- onMouseMove: H,
1435
- onMouseOut: U,
1511
+ onPointerDown: B,
1512
+ onPointerMove: B,
1513
+ onMouseMove: V,
1514
+ onMouseOut: te,
1436
1515
  children: [
1437
- oe(void 0, ne),
1438
- w ? /* @__PURE__ */ F("div", {
1516
+ se(void 0, re),
1517
+ b ? /* @__PURE__ */ F("div", {
1439
1518
  className: "cursor-time",
1440
1519
  style: {
1441
- left: ie ? `clamp(var(--thumbnail-half), ${W(w)}%, calc(100% - var(--thumbnail-half)))` : `clamp(calc(3 * var(--mp-unit)), ${W(w)}%, calc(100% - calc(3 * var(--mp-unit))))`,
1442
- maxWidth: ie ? "var(--thumbnail-width)" : void 0
1520
+ left: ae ? `clamp(var(--thumbnail-half), ${H(b)}%, calc(100% - var(--thumbnail-half)))` : `clamp(calc(3 * var(--mp-unit)), ${H(b)}%, calc(100% - calc(3 * var(--mp-unit))))`,
1521
+ maxWidth: ae ? "var(--thumbnail-width)" : void 0
1443
1522
  },
1444
1523
  children: [/* @__PURE__ */ P("span", {
1445
1524
  className: "cursor-time-value",
1446
- children: $e(w)
1447
- }), ie ? /* @__PURE__ */ P("span", {
1525
+ children: ht(b)
1526
+ }), ae ? /* @__PURE__ */ P("span", {
1448
1527
  className: "chapter-title",
1449
- children: ie.title
1528
+ children: ae.title
1450
1529
  }) : void 0]
1451
1530
  }) : void 0,
1452
1531
  /* @__PURE__ */ P("div", { className: "progress" }),
1453
1532
  /* @__PURE__ */ P("div", { className: "hover" }),
1454
- re ? oe("focus", re) : void 0,
1533
+ ie ? se("focus", ie) : void 0,
1455
1534
  /* @__PURE__ */ P("div", { className: "scrubber" }),
1456
1535
  /* @__PURE__ */ P("div", {
1457
1536
  className: "padding",
1458
- ...I,
1459
- onPointerDown: L,
1460
- onPointerUp: R,
1461
- onPointerCancel: R
1537
+ ...N,
1538
+ onPointerDown: I,
1539
+ onPointerUp: L,
1540
+ onPointerCancel: L
1462
1541
  }),
1463
1542
  /* @__PURE__ */ P("div", {
1464
1543
  className: "thumbnail",
1465
- style: { left: `clamp(var(--thumbnail-half), ${W(w ?? 1)}%, calc(100% - var(--thumbnail-half)))` },
1466
- children: ae?.url ? /* @__PURE__ */ P("img", { src: ae.url }) : void 0
1544
+ style: { left: `clamp(var(--thumbnail-half), ${H(b ?? 1)}%, calc(100% - var(--thumbnail-half)))` },
1545
+ children: oe?.url ? /* @__PURE__ */ P("img", { src: oe.url }) : void 0
1467
1546
  })
1468
1547
  ]
1469
1548
  });
1470
- }, ut = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%23fff'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='icon%20icon-tabler%20icons-tabler-outline%20icon-tabler-picture-in-picture'%3e%3cpath%20stroke='none'%20d='M0%200h24v24H0z'%20fill='none'%20/%3e%3cpath%20d='M11%2019h-6a2%202%200%200%201%20-2%20-2v-10a2%202%200%200%201%202%20-2h14a2%202%200%200%201%202%202v4'%20/%3e%3cpath%20d='M14%2014m0%201a1%201%200%200%201%201%20-1h5a1%201%200%200%201%201%201v3a1%201%200%200%201%20-1%201h-5a1%201%200%200%201%20-1%20-1z'%20/%3e%3c/svg%3e", dt = {
1549
+ }, Dt = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%23fff'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='icon%20icon-tabler%20icons-tabler-outline%20icon-tabler-picture-in-picture'%3e%3cpath%20stroke='none'%20d='M0%200h24v24H0z'%20fill='none'%20/%3e%3cpath%20d='M11%2019h-6a2%202%200%200%201%20-2%20-2v-10a2%202%200%200%201%202%20-2h14a2%202%200%200%201%202%202v4'%20/%3e%3cpath%20d='M14%2014m0%201a1%201%200%200%201%201%20-1h5a1%201%200%200%201%201%201v3a1%201%200%200%201%20-1%201h-5a1%201%200%200%201%20-1%20-1z'%20/%3e%3c/svg%3e", Ot = {
1471
1550
  xmlns: "http://www.w3.org/2000/svg",
1472
1551
  width: 24,
1473
1552
  height: 24,
@@ -1477,8 +1556,8 @@ var ie = {
1477
1556
  strokeWidth: 2,
1478
1557
  strokeLinecap: "round",
1479
1558
  strokeLinejoin: "round"
1480
- }, ft = (e) => /* @__PURE__ */ F("svg", {
1481
- ...dt,
1559
+ }, kt = (e) => /* @__PURE__ */ F("svg", {
1560
+ ...Ot,
1482
1561
  ...e,
1483
1562
  children: [
1484
1563
  /* @__PURE__ */ P("path", { d: "M21 11V7a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h5" }),
@@ -1492,8 +1571,8 @@ var ie = {
1492
1571
  }),
1493
1572
  /* @__PURE__ */ P("path", { d: "M14.5 18.5h2m2 0h1" })
1494
1573
  ]
1495
- }), pt = (e) => /* @__PURE__ */ F("svg", {
1496
- ...dt,
1574
+ }), At = (e) => /* @__PURE__ */ F("svg", {
1575
+ ...Ot,
1497
1576
  ...e,
1498
1577
  children: [
1499
1578
  /* @__PURE__ */ P("path", { d: "M21 11V7a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h5" }),
@@ -1507,7 +1586,7 @@ var ie = {
1507
1586
  }),
1508
1587
  /* @__PURE__ */ P("path", { d: "M6 9h3m2 0h2" })
1509
1588
  ]
1510
- }), mt = w`
1589
+ }), jt = E`
1511
1590
  .popover {
1512
1591
  position: absolute;
1513
1592
  /* Anchored to the PLAYER's right edge, never to the gear. The gear is not the last control in the
@@ -1528,9 +1607,10 @@ var ie = {
1528
1607
  once subtitles moved out to its own button, and a long track list scrolls at the cap either way. */
1529
1608
  height: max-content;
1530
1609
  /* The room actually above the bar. A short player had the top of the menu clipped by that same
1531
- \`overflow: hidden\`. With no size container in the ancestry this resolves against the small
1532
- viewport, so it can only ever shrink the box, never grow it. */
1533
- max-height: min(160px, calc(100cqh - 100% - 16px));
1610
+ \`overflow: hidden\`. \`--mp-height\` is the player's own height, which the chrome writes: with no
1611
+ size container in the ancestry \`100cqh\` is the small viewport's, and a translated menu whose rows
1612
+ wrap reached the cap and rose 2px past a phone's 220px tall player. */
1613
+ max-height: min(160px, calc(var(--mp-height, 100cqh) - 100% - 16px));
1534
1614
  @media (min-width: 768px) {
1535
1615
  right: calc(16px + env(safe-area-inset-right, 0px));
1536
1616
  width: 250px;
@@ -1546,7 +1626,7 @@ var ie = {
1546
1626
 
1547
1627
  border-radius: 8px;
1548
1628
  background-color: rgba(28,28,28,0.95);
1549
- ${Q.bMedium.regular}
1629
+ ${$.bMedium.regular}
1550
1630
 
1551
1631
  z-index: 4;
1552
1632
 
@@ -1589,7 +1669,7 @@ var ie = {
1589
1669
 
1590
1670
  .secondary {
1591
1671
  color: #eee;
1592
- ${Q.bSmall.regular}
1672
+ ${$.bSmall.regular}
1593
1673
  }
1594
1674
  }
1595
1675
  }
@@ -1631,18 +1711,18 @@ var ie = {
1631
1711
  .failed {
1632
1712
  border-bottom: 1px solid #4D4D4E;
1633
1713
  color: #f66;
1634
- ${Q.bSmall.regular}
1714
+ ${$.bSmall.regular}
1635
1715
  }
1636
1716
  }
1637
- `, ht = ({ title: e, tracks: t, selected: n, onSelect: r, onBack: i, offLabel: a, pending: o, failed: s }) => {
1638
- let c = o !== void 0, l = (e, i, a) => {
1639
- let s = c && o === e, l = c || t.find((t) => t.id === e)?.disabled;
1717
+ `, Mt = ({ title: e, tracks: t, selected: n, onSelect: r, onBack: i, offLabel: o, pending: s, failed: c }) => {
1718
+ let { format: l } = Q(), u = s !== void 0, d = (e, i, a) => {
1719
+ let o = u && s === e, c = u || t.find((t) => t.id === e)?.disabled;
1640
1720
  return /* @__PURE__ */ F("div", {
1641
1721
  onClick: () => {
1642
- l || r(e ?? void 0);
1722
+ c || r(e ?? void 0);
1643
1723
  },
1644
- className: [a, l ? "unavailable" : null].filter(Boolean).join(" ") || void 0,
1645
- children: [/* @__PURE__ */ P("span", { children: i }), /* @__PURE__ */ P("span", { children: s ? "…" : (n ?? null) === e ? "✓" : "" })]
1724
+ className: [a, c ? "unavailable" : null].filter(Boolean).join(" ") || void 0,
1725
+ children: [/* @__PURE__ */ P("span", { children: i }), /* @__PURE__ */ P("span", { children: o ? "…" : (n ?? null) === e ? "✓" : "" })]
1646
1726
  }, e ?? "__off__");
1647
1727
  };
1648
1728
  return /* @__PURE__ */ F("div", {
@@ -1651,23 +1731,23 @@ var ie = {
1651
1731
  /* @__PURE__ */ F("div", {
1652
1732
  className: i ? "back" : "back no-hover",
1653
1733
  onClick: i,
1654
- children: [i ? /* @__PURE__ */ P(z, {}) : null, /* @__PURE__ */ P("span", { children: e })]
1734
+ children: [i ? /* @__PURE__ */ P(B, {}) : null, /* @__PURE__ */ P("span", { children: e })]
1655
1735
  }),
1656
- s ? /* @__PURE__ */ P("div", {
1736
+ c ? /* @__PURE__ */ P("div", {
1657
1737
  className: "no-hover failed",
1658
- children: "Could not switch. Try again."
1738
+ children: l(a.switchFailed)
1659
1739
  }) : null,
1660
- a ? l(null, a) : null,
1661
- t.map(({ id: e, label: t }) => l(e, t, "description"))
1740
+ o ? d(null, o) : null,
1741
+ t.map(({ id: e, label: t }) => d(e, t, "description"))
1662
1742
  ]
1663
1743
  });
1664
- }, gt = ({ onReset: e } = {}) => {
1665
- let t = x(null), [n, r] = S(!1), [i, a] = S(void 0), [o, s] = S(!1), c = x(e);
1744
+ }, Nt = ({ onReset: e } = {}) => {
1745
+ let t = C(null), [n, r] = w(!1), [i, a] = w(void 0), [o, s] = w(!1), c = C(e);
1666
1746
  c.current = e;
1667
1747
  let l = () => {
1668
1748
  r(!1), c.current?.();
1669
1749
  };
1670
- return y(() => {
1750
+ return x(() => {
1671
1751
  let e = (e) => {
1672
1752
  n && t.current && !t.current.contains(e.target) && l();
1673
1753
  };
@@ -1702,7 +1782,7 @@ var ie = {
1702
1782
  });
1703
1783
  }
1704
1784
  };
1705
- }, _t = w`
1785
+ }, Pt = E`
1706
1786
  /* Not a containing block, for the reason given on popoverStyle: the menu anchors to the control bar,
1707
1787
  which is the width of the player box, so it can be clamped to it. */
1708
1788
  position: static;
@@ -1718,13 +1798,13 @@ position: static;
1718
1798
  }
1719
1799
  }
1720
1800
 
1721
- ${mt}
1801
+ ${jt}
1722
1802
 
1723
1803
  .popover.error-list {
1724
1804
  /* Wider than a track menu and taller, because these rows are sentences rather than labels, and a
1725
1805
  decoder message that has been ellipsized is not worth copying. */
1726
1806
  width: 420px;
1727
- max-height: min(300px, calc(100cqh - 100% - 16px));
1807
+ max-height: min(300px, calc(var(--mp-height, 100cqh) - 100% - 16px));
1728
1808
 
1729
1809
  /* track-menu's header is a left-aligned label row; here it carries a control too, so the two
1730
1810
  ends go to the two ends */
@@ -1746,7 +1826,7 @@ ${mt}
1746
1826
 
1747
1827
  color: #fff;
1748
1828
  cursor: pointer;
1749
- ${Q.bSmall.regular}
1829
+ ${$.bSmall.regular}
1750
1830
 
1751
1831
  &:hover {
1752
1832
  background-color: rgba(255,255,255,.1);
@@ -1767,7 +1847,7 @@ ${mt}
1767
1847
 
1768
1848
  .when {
1769
1849
  color: #bbb;
1770
- ${Q.bSmall.regular}
1850
+ ${$.bSmall.regular}
1771
1851
 
1772
1852
  /* the one part of the line worth scanning for, so it is the one part at full brightness */
1773
1853
  .count {
@@ -1786,61 +1866,63 @@ ${mt}
1786
1866
  color: #ddd;
1787
1867
  overflow-wrap: anywhere;
1788
1868
  white-space: pre-wrap;
1789
- ${Q.bSmall.regular}
1869
+ ${$.bSmall.regular}
1790
1870
  }
1791
1871
  }
1792
1872
  }
1793
- `, vt = (e) => new Date(e).toLocaleTimeString(), yt = (e) => e === void 0 || !Number.isFinite(e) ? void 0 : $e(Math.max(0, e)), bt = (e) => e.reduce((e, t) => e + t.count, 0), xt = (e) => e.map((e, t) => {
1794
- let n = yt(e.atMediaTime), r = e.count > 1 ? `${new Date(e.at).toISOString()} to ${new Date(e.lastAt).toISOString()} ×${e.count}` : new Date(e.at).toISOString();
1873
+ `, Ft = (e, t) => new Date(e).toLocaleTimeString(t), It = (e) => e === void 0 || !Number.isFinite(e) ? void 0 : ht(Math.max(0, e)), Lt = (e) => e.reduce((e, t) => e + t.count, 0), Rt = (e) => e.map((e, t) => {
1874
+ let n = It(e.atMediaTime), r = e.count > 1 ? `${new Date(e.at).toISOString()} to ${new Date(e.lastAt).toISOString()} ×${e.count}` : new Date(e.at).toISOString();
1795
1875
  return [
1796
1876
  `${t + 1}. ${r}${n ? ` (at ${n})` : ""}${e.recovered ? " [recovered]" : ""}`,
1797
1877
  e.message,
1798
1878
  e.detail
1799
1879
  ].filter(Boolean).join("\n");
1800
- }).join("\n\n"), St = () => {
1801
- let e = Y((e) => e.playbackErrors), { open: t, toggle: n, containerRef: r } = gt(), [i, a] = S(!1);
1880
+ }).join("\n\n"), zt = () => {
1881
+ let e = J((e) => e.playbackErrors), { format: t, locale: n } = Q(), { open: r, toggle: i, containerRef: o } = Nt(), [s, c] = w(!1);
1802
1882
  if (e.length === 0) return null;
1803
- let o = () => {
1804
- navigator.clipboard?.writeText(xt(e)).then(() => {
1805
- a(!0), setTimeout(() => a(!1), 2e3);
1883
+ let l = () => {
1884
+ navigator.clipboard?.writeText(Rt(e)).then(() => {
1885
+ c(!0), setTimeout(() => c(!1), 2e3);
1806
1886
  }, (e) => console.warn("[media-player] could not copy the errors:", e));
1807
- }, s = `Playback errors (${bt(e)})`;
1887
+ }, u = t(a.errors, { count: Lt(e) });
1808
1888
  return /* @__PURE__ */ F("div", {
1809
- css: _t,
1810
- ref: r,
1811
- children: [/* @__PURE__ */ P($, {
1889
+ css: Pt,
1890
+ ref: o,
1891
+ children: [/* @__PURE__ */ P(St, {
1812
1892
  id: "errors",
1813
- disabled: t,
1893
+ disabled: r,
1814
1894
  text: /* @__PURE__ */ P("button", {
1815
1895
  className: "errors",
1816
1896
  type: "button",
1817
- onClick: n,
1818
- "aria-label": s,
1819
- "aria-expanded": t,
1820
- children: /* @__PURE__ */ P(K, { className: "alert-triangle" })
1897
+ onClick: i,
1898
+ "aria-label": u,
1899
+ "aria-expanded": r,
1900
+ children: /* @__PURE__ */ P(q, { className: "alert-triangle" })
1821
1901
  }),
1822
- toolTipText: /* @__PURE__ */ P("span", { children: s })
1823
- }), t && /* @__PURE__ */ F("div", {
1902
+ toolTipText: /* @__PURE__ */ P("span", { children: u })
1903
+ }), r && /* @__PURE__ */ F("div", {
1824
1904
  className: "popover error-list",
1825
1905
  children: [/* @__PURE__ */ F("div", {
1826
1906
  className: "back no-hover",
1827
- children: [/* @__PURE__ */ P("span", { children: s }), /* @__PURE__ */ F("button", {
1907
+ children: [/* @__PURE__ */ P("span", { children: u }), /* @__PURE__ */ F("button", {
1828
1908
  className: "copy",
1829
1909
  type: "button",
1830
- onClick: o,
1831
- "aria-label": "Copy the errors",
1832
- children: [P(i ? R : V, {}), /* @__PURE__ */ P("span", { children: i ? "Copied" : "Copy" })]
1910
+ onClick: l,
1911
+ "aria-label": t(a.copyErrors),
1912
+ children: [P(s ? z : te, {}), /* @__PURE__ */ P("span", { children: t(s ? a.copied : a.copy) })]
1833
1913
  })]
1834
- }), e.map((e, t) => /* @__PURE__ */ F("div", {
1914
+ }), e.map((e, r) => /* @__PURE__ */ F("div", {
1835
1915
  className: "entry no-hover",
1836
1916
  children: [
1837
1917
  /* @__PURE__ */ F("span", {
1838
1918
  className: "when",
1839
1919
  children: [
1840
- vt(e.at),
1841
- e.count > 1 ? ` to ${vt(e.lastAt)}` : "",
1842
- yt(e.atMediaTime) ? ` at ${yt(e.atMediaTime)}` : "",
1843
- e.recovered ? " recovered" : "",
1920
+ e.count > 1 ? t(a.errorSpan, {
1921
+ start: Ft(e.at, n),
1922
+ end: Ft(e.lastAt, n)
1923
+ }) : Ft(e.at, n),
1924
+ It(e.atMediaTime) ? ` ${t(a.errorAt, { time: It(e.atMediaTime) })}` : "",
1925
+ e.recovered ? ` ${t(a.recovered)}` : "",
1844
1926
  e.count > 1 ? /* @__PURE__ */ P("span", {
1845
1927
  className: "count",
1846
1928
  children: `×${e.count}`
@@ -1856,10 +1938,10 @@ ${mt}
1856
1938
  children: e.detail
1857
1939
  }) : null
1858
1940
  ]
1859
- }, `${e.at}-${t}`))]
1941
+ }, `${e.at}-${r}`))]
1860
1942
  })]
1861
1943
  });
1862
- }, Ct = w`
1944
+ }, Bt = E`
1863
1945
  display: flex;
1864
1946
  align-items: center;
1865
1947
  justify-content: center;
@@ -1912,42 +1994,45 @@ width: 100%;
1912
1994
  }
1913
1995
  }
1914
1996
  }
1915
- `, wt = () => {
1916
- let e = Y(), t = Y((e) => e.playbackRate), n = x(null), r = x(null), i = .25, a = 2.75, o = (e, t = .05) => Math.round(e / t) * t, s = o(t || 1), c = (e) => (e - i) / a * 100, l = (e) => o(i + e * a), { handlers: u } = ot({
1917
- ref: r,
1918
- onChange: (t) => e.setPlaybackRate(l(t))
1919
- }), d = (t) => {
1997
+ `, Vt = () => {
1998
+ let e = J(), { format: t, number: n } = Q(), r = J((e) => e.playbackRate), i = C(null), o = C(null), s = .25, c = 2.75, l = (e, t = .05) => Math.round(e / t) * t, u = l(r || 1), d = (e) => (e - s) / c * 100, f = (e) => l(s + e * c), { handlers: p } = Ct({
1999
+ ref: o,
2000
+ onChange: (t) => e.setPlaybackRate(f(t))
2001
+ }), m = (t) => {
1920
2002
  t.preventDefault();
1921
- let n = .05, r = s;
1922
- r = t.deltaY < 0 ? Math.min(3, r + n) : Math.max(i, r - n), e.setPlaybackRate(r);
2003
+ let n = .05, r = u;
2004
+ r = t.deltaY < 0 ? Math.min(3, r + n) : Math.max(s, r - n), e.setPlaybackRate(r);
1923
2005
  };
1924
- y(() => {
1925
- let e = n.current;
1926
- return e && e.addEventListener("wheel", d, { passive: !1 }), () => {
1927
- e && e.removeEventListener("wheel", d);
2006
+ x(() => {
2007
+ let e = i.current;
2008
+ return e && e.addEventListener("wheel", m, { passive: !1 }), () => {
2009
+ e && e.removeEventListener("wheel", m);
1928
2010
  };
1929
- }, [t]);
1930
- let f = c(s);
2011
+ }, [r]);
2012
+ let h = d(u);
1931
2013
  return /* @__PURE__ */ F("div", {
1932
- css: Ct,
1933
- children: [/* @__PURE__ */ F("div", { children: [s.toFixed(2), "x"] }), /* @__PURE__ */ P("div", {
2014
+ css: Bt,
2015
+ children: [/* @__PURE__ */ P("div", { children: t(a.speed, { rate: n(u, {
2016
+ minimumFractionDigits: 2,
2017
+ maximumFractionDigits: 2
2018
+ }) }) }), /* @__PURE__ */ P("div", {
1934
2019
  className: "playback-slider",
1935
- ref: n,
1936
- ...u,
2020
+ ref: i,
2021
+ ...p,
1937
2022
  children: /* @__PURE__ */ P("div", {
1938
- ref: r,
2023
+ ref: o,
1939
2024
  style: { background: `linear-gradient(to right,
1940
- #fff 0% ${f}%,
1941
- #3A3A3A ${f}% 100%
2025
+ #fff 0% ${h}%,
2026
+ #3A3A3A ${h}% 100%
1942
2027
  )` },
1943
2028
  children: /* @__PURE__ */ P("div", {
1944
2029
  className: "playback-handle",
1945
- style: { left: `${f}%` }
2030
+ style: { left: `${h}%` }
1946
2031
  })
1947
2032
  })
1948
2033
  })]
1949
2034
  });
1950
- }, Tt = w`
2035
+ }, Ht = E`
1951
2036
  /* Deliberately NOT a containing block. The menu anchors to the control bar instead, which is exactly
1952
2037
  as wide as the player box and can therefore be clamped to it. The outside-click check uses
1953
2038
  \`contains\` on the ref, which is DOM containment and needs no position, and the bar's other
@@ -1965,7 +2050,7 @@ position: static;
1965
2050
  }
1966
2051
  }
1967
2052
 
1968
- ${mt}
2053
+ ${jt}
1969
2054
 
1970
2055
  .switch {
1971
2056
  position: relative;
@@ -2041,126 +2126,120 @@ ${mt}
2041
2126
  }
2042
2127
  }
2043
2128
 
2044
- `, Et = () => {
2045
- let e = Y(), t = Y((e) => e.playbackRate), n = Y((e) => e.audioTracks), r = Y((e) => e.selectedAudioTrack), i = Y((e) => e.selectAudioTrack), a = Y((e) => e.quality), o = Y((e) => e.volumeNormalizer), [s, c] = S(0), { open: l, toggle: u, containerRef: d, pending: f, failed: p, runSelect: m } = gt({ onReset: () => c(0) }), h = (t) => {
2046
- e.setPlaybackRate(t), c(0);
2047
- }, g = (e) => {
2048
- e !== void 0 && m(e, () => i(e));
2049
- }, _ = (e) => {
2050
- a && m(e ?? null, () => a.select(e === void 0 ? null : String(e)));
2051
- }, v = a ? a.options.length + +!!a.offLabel : 0, y = a?.selectedId == null ? a?.offLabel : a.options.find(({ id: e }) => e === a.selectedId)?.label, b = (e) => () => {
2052
- c(e);
2129
+ `, Ut = [
2130
+ .5,
2131
+ 1,
2132
+ 1.5,
2133
+ 2
2134
+ ], Wt = () => {
2135
+ let e = J(), { format: t, number: n } = Q(), r = J((e) => e.playbackRate), i = J((e) => e.audioTracks), o = J((e) => e.selectedAudioTrack), s = J((e) => e.selectAudioTrack), c = J((e) => e.quality), l = J((e) => e.volumeNormalizer), [u, d] = w(0), { open: f, toggle: p, containerRef: m, pending: h, failed: g, runSelect: _ } = Nt({ onReset: () => d(0) }), v = (t) => {
2136
+ e.setPlaybackRate(t), d(0);
2137
+ }, y = (e) => {
2138
+ e !== void 0 && _(e, () => s(e));
2139
+ }, b = (e) => {
2140
+ c && _(e ?? null, () => c.select(e === void 0 ? null : String(e)));
2141
+ }, x = c ? c.options.length + +!!c.offLabel : 0, S = c?.selectedId == null ? c?.offLabel : c.options.find(({ id: e }) => e === c.selectedId)?.label, C = (e) => () => {
2142
+ d(e);
2053
2143
  };
2054
2144
  return /* @__PURE__ */ F("div", {
2055
- css: Tt,
2056
- ref: d,
2145
+ css: Ht,
2146
+ ref: m,
2057
2147
  children: [
2058
- /* @__PURE__ */ P($, {
2148
+ /* @__PURE__ */ P(St, {
2059
2149
  id: "settings",
2060
- disabled: l,
2150
+ disabled: f,
2061
2151
  text: /* @__PURE__ */ P("button", {
2062
2152
  className: "settings",
2063
2153
  type: "button",
2064
- onClick: u,
2065
- "aria-label": "Settings",
2066
- "aria-expanded": l,
2067
- children: /* @__PURE__ */ P(te, {})
2154
+ onClick: p,
2155
+ "aria-label": t(a.settings),
2156
+ "aria-expanded": f,
2157
+ children: /* @__PURE__ */ P(K, {})
2068
2158
  }),
2069
- toolTipText: /* @__PURE__ */ P("span", { children: "Settings" })
2159
+ toolTipText: /* @__PURE__ */ P("span", { children: t(a.settings) })
2070
2160
  }),
2071
- l && s === 0 && /* @__PURE__ */ F("div", {
2161
+ f && u === 0 && /* @__PURE__ */ F("div", {
2072
2162
  className: "popover menu",
2073
2163
  children: [
2074
- n.length > 1 ? /* @__PURE__ */ F("div", {
2075
- onClick: b(2),
2076
- children: [/* @__PURE__ */ P("div", { children: "Audio" }), /* @__PURE__ */ P("div", { children: /* @__PURE__ */ P(B, {}) })]
2164
+ i.length > 1 ? /* @__PURE__ */ F("div", {
2165
+ onClick: C(2),
2166
+ children: [/* @__PURE__ */ P("div", { children: t(a.audio) }), /* @__PURE__ */ P("div", { children: /* @__PURE__ */ P(V, {}) })]
2077
2167
  }) : null,
2078
- v > 1 ? /* @__PURE__ */ F("div", {
2079
- onClick: b(3),
2080
- children: [/* @__PURE__ */ P("div", { children: "Quality" }), /* @__PURE__ */ F("div", { children: [y ? /* @__PURE__ */ P("span", {
2168
+ x > 1 ? /* @__PURE__ */ F("div", {
2169
+ onClick: C(3),
2170
+ children: [/* @__PURE__ */ P("div", { children: t(a.quality) }), /* @__PURE__ */ F("div", { children: [S ? /* @__PURE__ */ P("span", {
2081
2171
  className: "secondary",
2082
- children: y
2083
- }) : null, /* @__PURE__ */ P(B, {})] })]
2172
+ children: S
2173
+ }) : null, /* @__PURE__ */ P(V, {})] })]
2084
2174
  }) : null,
2085
2175
  /* @__PURE__ */ F("div", {
2086
- onClick: b(1),
2087
- children: [/* @__PURE__ */ P("div", { children: "Playback speed" }), /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P("span", {
2176
+ onClick: C(1),
2177
+ children: [/* @__PURE__ */ P("div", { children: t(a.playbackSpeed) }), /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P("span", {
2088
2178
  className: "secondary",
2089
- children: t === 1 ? "(Default)" : t.toFixed(2)
2090
- }), /* @__PURE__ */ P(B, {})] })]
2179
+ children: r === 1 ? t(a.defaultSpeed) : n(r, {
2180
+ minimumFractionDigits: 2,
2181
+ maximumFractionDigits: 2
2182
+ })
2183
+ }), /* @__PURE__ */ P(V, {})] })]
2091
2184
  }),
2092
- o ? /* @__PURE__ */ F("div", {
2185
+ l ? /* @__PURE__ */ F("div", {
2093
2186
  role: "switch",
2094
- "aria-checked": o.available && o.enabled,
2095
- "aria-disabled": !o.available,
2096
- className: o.available ? void 0 : "no-hover unavailable",
2187
+ "aria-checked": l.available && l.enabled,
2188
+ "aria-disabled": !l.available,
2189
+ className: l.available ? void 0 : "no-hover unavailable",
2097
2190
  onClick: () => {
2098
- o.available && o.setEnabled(!o.enabled);
2191
+ l.available && l.setEnabled(!l.enabled);
2099
2192
  },
2100
- children: [/* @__PURE__ */ P("div", { children: "Normalize volume" }), /* @__PURE__ */ P("div", { children: o.available ? /* @__PURE__ */ P("span", { className: o.enabled ? "switch on" : "switch" }) : /* @__PURE__ */ P("span", {
2193
+ children: [/* @__PURE__ */ P("div", { children: t(a.normalizeVolume) }), /* @__PURE__ */ P("div", { children: l.available ? /* @__PURE__ */ P("span", { className: l.enabled ? "switch on" : "switch" }) : /* @__PURE__ */ P("span", {
2101
2194
  className: "secondary",
2102
- children: "Unavailable"
2195
+ children: t(a.unavailable)
2103
2196
  }) })]
2104
2197
  }) : null
2105
2198
  ]
2106
2199
  }),
2107
- l && s === 1 && /* @__PURE__ */ F("div", {
2200
+ f && u === 1 && /* @__PURE__ */ F("div", {
2108
2201
  className: "popover playback-rate",
2109
2202
  children: [
2110
2203
  /* @__PURE__ */ F("div", {
2111
2204
  className: "back",
2112
- onClick: b(0),
2113
- children: [/* @__PURE__ */ P(z, {}), /* @__PURE__ */ P("span", { children: "Playback speed" })]
2205
+ onClick: C(0),
2206
+ children: [/* @__PURE__ */ P(B, {}), /* @__PURE__ */ P("span", { children: t(a.playbackSpeed) })]
2114
2207
  }),
2115
2208
  /* @__PURE__ */ P("div", {
2116
2209
  className: "slider no-hover",
2117
- children: /* @__PURE__ */ P(wt, {})
2210
+ children: /* @__PURE__ */ P(Vt, {})
2118
2211
  }),
2119
- /* @__PURE__ */ F("div", {
2212
+ /* @__PURE__ */ P("div", {
2120
2213
  className: "options no-hover",
2121
- children: [
2122
- /* @__PURE__ */ P("div", {
2123
- onClick: () => h(.5),
2124
- children: "0.5x"
2125
- }),
2126
- /* @__PURE__ */ P("div", {
2127
- onClick: () => h(1),
2128
- children: "1x"
2129
- }),
2130
- /* @__PURE__ */ P("div", {
2131
- onClick: () => h(1.5),
2132
- children: "1.5x"
2133
- }),
2134
- /* @__PURE__ */ P("div", {
2135
- onClick: () => h(2),
2136
- children: "2x"
2137
- })
2138
- ]
2214
+ children: Ut.map((e) => /* @__PURE__ */ P("div", {
2215
+ onClick: () => v(e),
2216
+ children: t(a.speed, { rate: n(e) })
2217
+ }, e))
2139
2218
  })
2140
2219
  ]
2141
2220
  }),
2142
- l && s === 2 && /* @__PURE__ */ P(ht, {
2143
- title: "Audio",
2144
- tracks: n,
2145
- selected: r,
2146
- onSelect: g,
2147
- onBack: b(0),
2148
- pending: f,
2149
- failed: p
2221
+ f && u === 2 && /* @__PURE__ */ P(Mt, {
2222
+ title: t(a.audio),
2223
+ tracks: i,
2224
+ selected: o,
2225
+ onSelect: y,
2226
+ onBack: C(0),
2227
+ pending: h,
2228
+ failed: g
2150
2229
  }),
2151
- l && s === 3 && a && /* @__PURE__ */ P(ht, {
2152
- title: "Quality",
2153
- tracks: a.options,
2154
- selected: a.selectedId ?? void 0,
2155
- onSelect: _,
2156
- onBack: b(0),
2157
- offLabel: a.offLabel,
2158
- pending: f,
2159
- failed: p
2230
+ f && u === 3 && c && /* @__PURE__ */ P(Mt, {
2231
+ title: t(a.quality),
2232
+ tracks: c.options,
2233
+ selected: c.selectedId ?? void 0,
2234
+ onSelect: b,
2235
+ onBack: C(0),
2236
+ offLabel: c.offLabel,
2237
+ pending: h,
2238
+ failed: g
2160
2239
  })
2161
2240
  ]
2162
2241
  });
2163
- }, Dt = w`
2242
+ }, Gt = E`
2164
2243
  /* Not a containing block, for the reason given on popoverStyle: the menu anchors to the control bar,
2165
2244
  which is the width of the player box, so it can be clamped to it. */
2166
2245
  position: static;
@@ -2176,44 +2255,44 @@ position: static;
2176
2255
  }
2177
2256
  }
2178
2257
 
2179
- ${mt}
2180
- `, Ot = () => {
2181
- let e = Y((e) => e.subtitleTracks), t = Y((e) => e.selectedSubtitleTrack), n = Y((e) => e.selectSubtitleTrack), r = Y((e) => e.subtitleOffLabel), { open: i, toggle: a, containerRef: o, pending: s, failed: c, runSelect: l } = gt();
2182
- if (e.length === 0) return null;
2183
- let u = t !== void 0;
2258
+ ${jt}
2259
+ `, Kt = () => {
2260
+ let { format: e } = Q(), t = J((e) => e.subtitleTracks), n = J((e) => e.selectedSubtitleTrack), r = J((e) => e.selectSubtitleTrack), i = J((e) => e.subtitleOffLabel), { open: o, toggle: s, containerRef: c, pending: l, failed: u, runSelect: d } = Nt();
2261
+ if (t.length === 0) return null;
2262
+ let f = n !== void 0;
2184
2263
  return /* @__PURE__ */ F("div", {
2185
- css: Dt,
2186
- ref: o,
2187
- children: [/* @__PURE__ */ P($, {
2264
+ css: Gt,
2265
+ ref: c,
2266
+ children: [/* @__PURE__ */ P(St, {
2188
2267
  id: "subtitles",
2189
- disabled: i,
2268
+ disabled: o,
2190
2269
  text: /* @__PURE__ */ P("button", {
2191
2270
  className: "subtitles",
2192
2271
  type: "button",
2193
- onClick: a,
2194
- "aria-label": "Subtitles",
2195
- "aria-expanded": i,
2196
- "aria-pressed": u,
2197
- children: u ? /* @__PURE__ */ P(I, { className: "captions" }) : /* @__PURE__ */ P(L, { className: "captions-off" })
2272
+ onClick: s,
2273
+ "aria-label": e(a.subtitles),
2274
+ "aria-expanded": o,
2275
+ "aria-pressed": f,
2276
+ children: f ? /* @__PURE__ */ P(L, { className: "captions" }) : /* @__PURE__ */ P(R, { className: "captions-off" })
2198
2277
  }),
2199
- toolTipText: /* @__PURE__ */ P("span", { children: "Subtitles" })
2200
- }), i && /* @__PURE__ */ P(ht, {
2201
- title: "Subtitles",
2202
- tracks: e,
2203
- selected: t,
2204
- onSelect: (e) => l(e ?? null, () => n(e)),
2205
- offLabel: r ?? "Disable",
2206
- pending: s,
2207
- failed: c
2278
+ toolTipText: /* @__PURE__ */ P("span", { children: e(a.subtitles) })
2279
+ }), o && /* @__PURE__ */ P(Mt, {
2280
+ title: e(a.subtitles),
2281
+ tracks: t,
2282
+ selected: n,
2283
+ onSelect: (e) => d(e ?? null, () => r(e)),
2284
+ offLabel: i ?? e(a.subtitlesOff),
2285
+ pending: l,
2286
+ failed: u
2208
2287
  })]
2209
2288
  });
2210
- }, kt = {
2289
+ }, qt = {
2211
2290
  primary: "#EAEBEE",
2212
2291
  secondary: "#D0D0D9",
2213
2292
  hover: "rgba(255, 255, 255, 0.13)",
2214
2293
  borderPrimary: "#384F70",
2215
2294
  backgroundTooltip: "#222222"
2216
- }, At = w`
2295
+ }, Jt = E`
2217
2296
  display: flex;
2218
2297
  align-items: center;
2219
2298
 
@@ -2256,33 +2335,33 @@ ${mt}
2256
2335
  width: 10px;
2257
2336
  height: 10px;
2258
2337
  }
2259
- `, jt = ({ value: e, onChange: t }) => {
2260
- let n = Y((e) => e.volume), r = Y((e) => e.muted), i = x(null), a = x(null), { handlers: o } = ot({
2261
- ref: a,
2338
+ `, Yt = ({ value: e, onChange: t }) => {
2339
+ let { number: n } = Q(), r = J((e) => e.volume), i = J((e) => e.muted), a = C(null), o = C(null), { handlers: s } = Ct({
2340
+ ref: o,
2262
2341
  onChange: t
2263
- }), s = (n) => {
2342
+ }), c = (n) => {
2264
2343
  n.preventDefault();
2265
2344
  let r = .05, i = e;
2266
2345
  i = n.deltaY < 0 ? Math.min(1, i + r) : Math.max(0, i - r), t(i);
2267
2346
  };
2268
- y(() => {
2269
- let e = i.current;
2270
- return e && e.addEventListener("wheel", s, { passive: !1 }), () => {
2271
- e && e.removeEventListener("wheel", s);
2347
+ x(() => {
2348
+ let e = a.current;
2349
+ return e && e.addEventListener("wheel", c, { passive: !1 }), () => {
2350
+ e && e.removeEventListener("wheel", c);
2272
2351
  };
2273
2352
  }, [e]);
2274
- let c = e * 100, l = b(() => Math.round(r ? 0 : Qe(n) * 100), [n, r]);
2275
- return /* @__PURE__ */ P($, {
2353
+ let l = e * 100, u = S(() => Math.round(i ? 0 : mt(r) * 100), [r, i]);
2354
+ return /* @__PURE__ */ P(St, {
2276
2355
  id: "volume-slider",
2277
2356
  text: /* @__PURE__ */ P("div", {
2278
- ref: i,
2279
- css: At,
2280
- ...o,
2357
+ ref: a,
2358
+ css: Jt,
2359
+ ...s,
2281
2360
  children: /* @__PURE__ */ P("div", {
2282
- ref: a,
2361
+ ref: o,
2283
2362
  style: { background: `linear-gradient(to right,
2284
- #fff 0% ${c}%,
2285
- #3A3A3A ${c}% 100%
2363
+ #fff 0% ${l}%,
2364
+ #3A3A3A ${l}% 100%
2286
2365
  )` },
2287
2366
  children: /* @__PURE__ */ P("div", {
2288
2367
  className: "volume-handle",
@@ -2290,12 +2369,12 @@ ${mt}
2290
2369
  })
2291
2370
  })
2292
2371
  }),
2293
- toolTipText: /* @__PURE__ */ F("div", {
2372
+ toolTipText: /* @__PURE__ */ P("div", {
2294
2373
  className: "volume-value",
2295
- children: [l, "%"]
2374
+ children: n(u / 100, { style: "percent" })
2296
2375
  })
2297
2376
  });
2298
- }, Mt = w`
2377
+ }, Xt = E`
2299
2378
  position: relative;
2300
2379
  display: flex;
2301
2380
  align-items: center;
@@ -2320,7 +2399,7 @@ ${mt}
2320
2399
  border-radius: 4px;
2321
2400
 
2322
2401
  .volume-value {
2323
- ${Q.bMedium.regular};
2402
+ ${$.bMedium.regular};
2324
2403
  color: #ffffff;
2325
2404
  }
2326
2405
  }
@@ -2358,39 +2437,39 @@ ${mt}
2358
2437
  }
2359
2438
  }
2360
2439
 
2361
- `, Nt = ({ ref: e }) => {
2362
- let t = Y(), n = Y((e) => e.volume), r = Y((e) => e.muted), i = b(() => Qe(n), [n]);
2440
+ `, Zt = ({ ref: e }) => {
2441
+ let t = J(), { format: n } = Q(), r = J((e) => e.volume), i = J((e) => e.muted), o = S(() => mt(r), [r]);
2363
2442
  return /* @__PURE__ */ F("div", {
2364
- css: Mt,
2365
- children: [/* @__PURE__ */ P($, {
2443
+ css: Xt,
2444
+ children: [/* @__PURE__ */ P(St, {
2366
2445
  id: "sound",
2367
2446
  text: /* @__PURE__ */ P("button", {
2368
2447
  className: "sound",
2369
2448
  type: "button",
2370
2449
  onClick: () => t.toggleMuted(),
2371
2450
  ref: e,
2372
- "aria-label": "Mute",
2373
- "aria-pressed": r || n === 0,
2374
- children: P(r || n === 0 ? ne : n <= .5 ? q : J, {
2451
+ "aria-label": n(a.mute),
2452
+ "aria-pressed": i || r === 0,
2453
+ children: P(i || r === 0 ? ae : r <= .5 ? re : ie, {
2375
2454
  size: 18,
2376
2455
  color: "#fff"
2377
2456
  })
2378
2457
  }),
2379
- toolTipText: /* @__PURE__ */ P("span", { children: r ? "Unmute (m)" : "Mute (m)" })
2458
+ toolTipText: /* @__PURE__ */ P("span", { children: n(i ? a.unmuteKey : a.muteKey) })
2380
2459
  }), /* @__PURE__ */ P("div", {
2381
2460
  className: "volume-slider-container",
2382
2461
  children: /* @__PURE__ */ P("div", {
2383
2462
  className: "volume-slider-background",
2384
- children: /* @__PURE__ */ P(jt, {
2385
- value: r ? 0 : i,
2463
+ children: /* @__PURE__ */ P(Yt, {
2464
+ value: i ? 0 : o,
2386
2465
  onChange: (e) => {
2387
- t.setVolume(Ze(e));
2466
+ t.setVolume(pt(e));
2388
2467
  }
2389
2468
  })
2390
2469
  })
2391
2470
  })]
2392
2471
  });
2393
- }, Pt = .05, Ft = 5, It = 50, Lt = 1e3, Rt = w`
2472
+ }, Qt = .05, $t = 5, en = 50, tn = 1e3, nn = E`
2394
2473
  position: absolute;
2395
2474
  bottom: 0;
2396
2475
  width: 100%;
@@ -2482,7 +2561,7 @@ ${mt}
2482
2561
  /* .armed is the hover of a control letting its click through, which takes no pointer events
2483
2562
  of its own and so is never :hover */
2484
2563
  :hover, &.armed {
2485
- background-color: ${kt.hover};
2564
+ background-color: ${qt.hover};
2486
2565
  }
2487
2566
 
2488
2567
  /* the hit area grows, the icon does not, keyed on the pointer because a narrow desktop
@@ -2499,7 +2578,7 @@ ${mt}
2499
2578
 
2500
2579
  .left {
2501
2580
  .time {
2502
- ${Q.bMedium.regular}
2581
+ ${$.bMedium.regular}
2503
2582
  text-shadow: 0 0 4px rgba(0, 0, 0, 1);
2504
2583
  }
2505
2584
  }
@@ -2520,40 +2599,40 @@ ${mt}
2520
2599
  }
2521
2600
  }
2522
2601
  }
2523
- `, zt = ({ shortcuts: e = "window", root: t, fullscreen: n }) => {
2524
- let r = Y(), i = Y((e) => e.paused), a = Y((e) => e.currentTime), o = Y((e) => e.duration), s = Y((e) => e.seekingTo), c = Y((e) => e.fullscreen), l = n ? n.active : c, u = x(n);
2525
- u.current = n;
2526
- let d = Y((e) => e.hideUI), f = Y((e) => e.togglePictureInPicture), p = Y((e) => e.pictureInPictureMode), m = Y((e) => e.burnedInSubtitles), h = Y((e) => e.passThroughPictureInPicture), g = Y((e) => e.subtitleTracks), v = Y((e) => e.requestSeek), b = Y((e) => e.stepFrame), [C, w] = S(null), T = x(null), E = x(void 0), D = p === "burn-in", O = g.length > 0, k = o > 0 && a === o, A = _(({ direction: e, stepSize: t }) => {
2527
- let n = Qe(r.volume), i = e === "up" ? t : -t, a = Math.max(0, Math.min(1, n + i)), o = r.muted;
2528
- r.setVolume(Ze(a)), o && !r.muted && r.toggleMuted();
2529
- }, [r]), j = x(!1), M = _(() => {
2530
- u.current ? u.current.request() : r.toggleFullscreen();
2602
+ `, rn = ({ shortcuts: e = "window", root: t, fullscreen: n }) => {
2603
+ let r = J(), { format: i } = Q(), o = J((e) => e.paused), s = J((e) => e.currentTime), c = J((e) => e.duration), l = J((e) => e.seekingTo), u = J((e) => e.fullscreen), d = n ? n.active : u, f = C(n);
2604
+ f.current = n;
2605
+ let p = J((e) => e.hideUI), m = J((e) => e.togglePictureInPicture), h = J((e) => e.pictureInPictureMode), g = J((e) => e.burnedInSubtitles), _ = J((e) => e.passThroughPictureInPicture), v = J((e) => e.subtitleTracks), b = J((e) => e.requestSeek), S = J((e) => e.stepFrame), [T, E] = w(null), D = C(null), O = C(void 0), k = h === "burn-in", ee = v.length > 0, A = c > 0 && s === c, j = y(({ direction: e, stepSize: t }) => {
2606
+ let n = mt(r.volume), i = e === "up" ? t : -t, a = Math.max(0, Math.min(1, n + i)), o = r.muted;
2607
+ r.setVolume(pt(a)), o && !r.muted && r.toggleMuted();
2608
+ }, [r]), M = C(!1), N = y(() => {
2609
+ f.current ? f.current.request() : r.toggleFullscreen();
2531
2610
  }, [r]);
2532
- y(() => {
2533
- let n = (e) => v ? v(e) : r.seek(e), i = (e) => e.composedPath()[0], a = (e) => {
2534
- j.current = !!t.current?.contains(i(e) ?? null);
2611
+ x(() => {
2612
+ let n = (e) => b ? b(e) : r.seek(e), i = (e) => e.composedPath()[0], a = (e) => {
2613
+ M.current = !!t.current?.contains(i(e) ?? null);
2535
2614
  }, o = (a) => {
2536
2615
  let o = i(a);
2537
2616
  if (o?.isContentEditable || /^(input|textarea|select)$/i.test(o?.tagName ?? "") || (a.ctrlKey || a.metaKey || a.altKey) && !a.getModifierState("AltGraph")) return;
2538
- let s = t.current?.contains(o ?? null) || o === document.body && j.current, c = u.current ? u.current.active : r.fullscreen;
2617
+ let s = t.current?.contains(o ?? null) || o === document.body && M.current, c = f.current ? f.current.active : r.fullscreen;
2539
2618
  if (e === "player" && !c && !s) return;
2540
2619
  let l = !0;
2541
- if (a.key === "f") M();
2620
+ if (a.key === "f") N();
2542
2621
  else if (a.key === "k") r.togglePaused();
2543
2622
  else if (a.key === " ") r.togglePaused();
2544
2623
  else if (a.key === "m") r.toggleMuted();
2545
- else if (a.key === "ArrowUp") A({
2624
+ else if (a.key === "ArrowUp") j({
2546
2625
  direction: "up",
2547
- stepSize: Pt
2626
+ stepSize: Qt
2548
2627
  });
2549
- else if (a.key === "ArrowDown") A({
2628
+ else if (a.key === "ArrowDown") j({
2550
2629
  direction: "down",
2551
- stepSize: Pt
2630
+ stepSize: Qt
2552
2631
  });
2553
2632
  else if (a.key === "ArrowRight") {
2554
2633
  if (!r.duration) return;
2555
- n(Math.min(r.currentTime + Ft, r.duration));
2556
- } else a.key === "ArrowLeft" ? n(Math.max(r.currentTime - Ft, 0)) : (a.key === "<" || a.key === ">") && b ? b(a.key === ">" ? 1 : -1) : l = !1;
2634
+ n(Math.min(r.currentTime + $t, r.duration));
2635
+ } else a.key === "ArrowLeft" ? n(Math.max(r.currentTime - $t, 0)) : (a.key === "<" || a.key === ">") && S ? S(a.key === ">" ? 1 : -1) : l = !1;
2557
2636
  l && a.preventDefault();
2558
2637
  };
2559
2638
  return window.addEventListener("keydown", o), window.addEventListener("pointerdown", a, !0), window.addEventListener("focusin", a, !0), () => {
@@ -2561,138 +2640,138 @@ ${mt}
2561
2640
  };
2562
2641
  }, [
2563
2642
  r,
2564
- A,
2565
- v,
2643
+ j,
2566
2644
  b,
2645
+ S,
2567
2646
  e,
2568
2647
  t,
2569
- M
2648
+ N
2570
2649
  ]);
2571
- let N = _((e) => {
2572
- e.preventDefault(), e.deltaY < 0 ? A({
2650
+ let I = y((e) => {
2651
+ e.preventDefault(), e.deltaY < 0 ? j({
2573
2652
  direction: "up",
2574
- stepSize: Pt
2575
- }) : A({
2653
+ stepSize: Qt
2654
+ }) : j({
2576
2655
  direction: "down",
2577
- stepSize: Pt
2656
+ stepSize: Qt
2578
2657
  });
2579
- }, [A]);
2580
- y(() => {
2581
- if (C) return C.addEventListener("wheel", N, { passive: !1 }), () => C.removeEventListener("wheel", N);
2582
- }, [C, N]);
2583
- let I = (e) => {
2584
- if (!h || h.active || h.armed || e.pointerType === "touch") return;
2658
+ }, [j]);
2659
+ x(() => {
2660
+ if (T) return T.addEventListener("wheel", I, { passive: !1 }), () => T.removeEventListener("wheel", I);
2661
+ }, [T, I]);
2662
+ let L = (e) => {
2663
+ if (!_ || _.active || _.armed || e.pointerType === "touch") return;
2585
2664
  let { left: t, top: n, width: r, height: i } = e.currentTarget.getBoundingClientRect();
2586
- h.arm({
2665
+ _.arm({
2587
2666
  left: t,
2588
2667
  top: n,
2589
2668
  width: r,
2590
2669
  height: i
2591
2670
  });
2592
- }, L = !!h?.armed;
2593
- return y(() => {
2594
- if (!L) return;
2595
- clearInterval(E.current);
2671
+ }, R = !!_?.armed;
2672
+ return x(() => {
2673
+ if (!R) return;
2674
+ clearInterval(O.current);
2596
2675
  let e = Infinity, t = setInterval(() => {
2597
2676
  if (Date.now() > e) {
2598
2677
  clearInterval(t);
2599
2678
  return;
2600
2679
  }
2601
- let n = T.current, r = document.activeElement;
2680
+ let n = D.current, r = document.activeElement;
2602
2681
  n && r?.tagName === "IFRAME" && r.closest(".video")?.parentElement?.contains(n) && n.focus({ preventScroll: !0 });
2603
- }, It);
2604
- return E.current = t, () => {
2605
- e = Date.now() + Lt;
2682
+ }, en);
2683
+ return O.current = t, () => {
2684
+ e = Date.now() + tn;
2606
2685
  };
2607
- }, [L]), y(() => () => clearInterval(E.current), []), /* @__PURE__ */ F("div", {
2686
+ }, [R]), x(() => () => clearInterval(O.current), []), /* @__PURE__ */ F("div", {
2608
2687
  className: "control-bar",
2609
- css: Rt,
2610
- style: { ...d ? {
2688
+ css: nn,
2689
+ style: { ...p ? {
2611
2690
  opacity: "0",
2612
2691
  pointerEvents: "none"
2613
- } : L ? { pointerEvents: "none" } : {} },
2614
- children: [/* @__PURE__ */ P(lt, {}), /* @__PURE__ */ F("div", {
2692
+ } : R ? { pointerEvents: "none" } : {} },
2693
+ children: [/* @__PURE__ */ P(Et, {}), /* @__PURE__ */ F("div", {
2615
2694
  className: "actions",
2616
2695
  children: [/* @__PURE__ */ F("div", {
2617
2696
  className: "left",
2618
2697
  children: [
2619
- /* @__PURE__ */ P($, {
2698
+ /* @__PURE__ */ P(St, {
2620
2699
  id: "play",
2621
2700
  tooltipPlace: "top-start",
2622
2701
  text: /* @__PURE__ */ P("button", {
2623
2702
  className: "play",
2624
2703
  type: "button",
2625
2704
  onClick: () => r.togglePaused(),
2626
- "aria-label": k ? "Replay" : i ? "Play" : "Pause",
2627
- children: P(k ? G : i ? ee : W, {})
2705
+ "aria-label": i(A ? a.replay : o ? a.play : a.pause),
2706
+ children: P(A ? G : o ? W : U, {})
2628
2707
  }),
2629
- toolTipText: /* @__PURE__ */ P("span", { children: k ? "Replay (k)" : i ? "Play (k)" : "Pause (k)" })
2708
+ toolTipText: /* @__PURE__ */ P("span", { children: i(A ? a.replayKey : o ? a.playKey : a.pauseKey) })
2630
2709
  }),
2631
- /* @__PURE__ */ P(Nt, { ref: w }),
2710
+ /* @__PURE__ */ P(Zt, { ref: E }),
2632
2711
  /* @__PURE__ */ P("div", {
2633
2712
  className: "time",
2634
- children: et(s ?? a, o)
2713
+ children: gt(l ?? s, c)
2635
2714
  })
2636
2715
  ]
2637
2716
  }), /* @__PURE__ */ F("div", {
2638
2717
  className: "right",
2639
2718
  children: [
2640
- /* @__PURE__ */ P(St, {}),
2641
- /* @__PURE__ */ P(Ot, {}),
2642
- /* @__PURE__ */ P(Et, {}),
2643
- h ? /* @__PURE__ */ P($, {
2719
+ /* @__PURE__ */ P(zt, {}),
2720
+ /* @__PURE__ */ P(Kt, {}),
2721
+ /* @__PURE__ */ P(Wt, {}),
2722
+ _ ? /* @__PURE__ */ P(St, {
2644
2723
  id: "picture-in-picture",
2645
2724
  tooltipPlace: "top-end",
2646
2725
  text: /* @__PURE__ */ P("button", {
2647
- ref: T,
2648
- className: h.armed ? "picture-in-picture armed" : "picture-in-picture",
2726
+ ref: D,
2727
+ className: _.armed ? "picture-in-picture armed" : "picture-in-picture",
2649
2728
  type: "button",
2650
- onPointerEnter: I,
2651
- onPointerMove: I,
2652
- onClick: h.active ? h.exit : void 0,
2653
- "aria-label": "Picture in picture",
2654
- "aria-pressed": h.active,
2729
+ onPointerEnter: L,
2730
+ onPointerMove: L,
2731
+ onClick: _.active ? _.exit : void 0,
2732
+ "aria-label": i(a.pictureInPicture),
2733
+ "aria-pressed": _.active,
2655
2734
  children: /* @__PURE__ */ P("img", {
2656
- src: ut,
2735
+ src: Dt,
2657
2736
  alt: ""
2658
2737
  })
2659
2738
  }),
2660
- toolTipText: /* @__PURE__ */ P("span", { children: h.active ? "Exit picture in picture" : "Picture in picture" })
2661
- }) : f ? /* @__PURE__ */ P($, {
2739
+ toolTipText: /* @__PURE__ */ P("span", { children: i(_.active ? a.exitPictureInPicture : a.pictureInPicture) })
2740
+ }) : m ? /* @__PURE__ */ P(St, {
2662
2741
  id: "picture-in-picture",
2663
2742
  tooltipPlace: "top-end",
2664
2743
  text: /* @__PURE__ */ P("button", {
2665
2744
  className: "picture-in-picture",
2666
2745
  type: "button",
2667
- onClick: f,
2668
- disabled: D && !O,
2669
- "aria-label": D ? "Put the subtitles in the video" : "Picture in picture",
2670
- "aria-pressed": D ? m : void 0,
2671
- children: D ? P(m ? ft : pt, {}) : /* @__PURE__ */ P("img", {
2672
- src: ut,
2746
+ onClick: m,
2747
+ disabled: k && !ee,
2748
+ "aria-label": i(k ? a.burnIn : a.pictureInPicture),
2749
+ "aria-pressed": k ? g : void 0,
2750
+ children: k ? P(g ? kt : At, {}) : /* @__PURE__ */ P("img", {
2751
+ src: Dt,
2673
2752
  alt: ""
2674
2753
  })
2675
2754
  }),
2676
- toolTipText: /* @__PURE__ */ P("span", { children: D ? O ? m ? "Subtitles are in the picture" : "Put the subtitles in the picture" : "This file has no subtitles" : "Picture in picture" })
2755
+ toolTipText: /* @__PURE__ */ P("span", { children: i(k ? ee ? g ? a.burnedIn : a.burnInOffer : a.noSubtitles : a.pictureInPicture) })
2677
2756
  }) : null,
2678
- /* @__PURE__ */ P($, {
2757
+ /* @__PURE__ */ P(St, {
2679
2758
  id: "full-screen",
2680
2759
  tooltipPlace: "top-end",
2681
2760
  text: /* @__PURE__ */ P("button", {
2682
2761
  className: "full-screen",
2683
2762
  type: "button",
2684
- onClick: M,
2685
- "aria-label": "Full screen",
2686
- "aria-pressed": l,
2687
- children: P(l ? U : H, {})
2763
+ onClick: N,
2764
+ "aria-label": i(a.fullScreen),
2765
+ "aria-pressed": d,
2766
+ children: P(d ? ne : H, {})
2688
2767
  }),
2689
- toolTipText: /* @__PURE__ */ P("span", { children: l ? "Exit full screen (f)" : "Full screen (f)" })
2768
+ toolTipText: /* @__PURE__ */ P("span", { children: i(d ? a.exitFullScreenKey : a.fullScreenKey) })
2690
2769
  })
2691
2770
  ]
2692
2771
  })]
2693
2772
  })]
2694
2773
  });
2695
- }, Bt = 9e3, Vt = w`
2774
+ }, an = 9e3, on = E`
2696
2775
  position: absolute;
2697
2776
  inset: 0;
2698
2777
  z-index: 2;
@@ -2724,7 +2803,7 @@ ${mt}
2724
2803
  }
2725
2804
 
2726
2805
  .text {
2727
- ${Q.bMedium.medium}
2806
+ ${$.bMedium.medium}
2728
2807
  color: #fff;
2729
2808
  }
2730
2809
 
@@ -2735,25 +2814,25 @@ ${mt}
2735
2814
  line-height: 1;
2736
2815
  color: #fff;
2737
2816
  }
2738
- `, Ht = () => {
2739
- let e = Y((e) => e.burnedInSubtitles), t = Y((e) => e.pictureInPictureMode), [n, r] = S(!1);
2740
- return y(() => {
2741
- if (t !== "burn-in" || !e) {
2742
- r(!1);
2817
+ `, sn = () => {
2818
+ let { format: e } = Q(), t = J((e) => e.burnedInSubtitles), n = J((e) => e.pictureInPictureMode), [r, i] = w(!1);
2819
+ return x(() => {
2820
+ if (n !== "burn-in" || !t) {
2821
+ i(!1);
2743
2822
  return;
2744
2823
  }
2745
- r(!0);
2746
- let n = setTimeout(() => r(!1), Bt);
2747
- return () => clearTimeout(n);
2748
- }, [t, e]), t !== "burn-in" || !e ? null : /* @__PURE__ */ P("div", {
2749
- css: Vt,
2750
- className: n ? "show" : "",
2824
+ i(!0);
2825
+ let e = setTimeout(() => i(!1), an);
2826
+ return () => clearTimeout(e);
2827
+ }, [n, t]), n !== "burn-in" || !t ? null : /* @__PURE__ */ P("div", {
2828
+ css: on,
2829
+ className: r ? "show" : "",
2751
2830
  role: "status",
2752
2831
  children: /* @__PURE__ */ F("div", {
2753
2832
  className: "card",
2754
2833
  children: [/* @__PURE__ */ P("div", {
2755
2834
  className: "text",
2756
- children: "Now click your browser's pop out button"
2835
+ children: e(a.burnInHint)
2757
2836
  }), /* @__PURE__ */ P("div", {
2758
2837
  className: "arrow",
2759
2838
  "aria-hidden": "true",
@@ -2761,10 +2840,10 @@ ${mt}
2761
2840
  })]
2762
2841
  })
2763
2842
  });
2764
- }, Ut = 1, Wt = 6e3, Gt = 1, Kt = {
2765
- opening: "Skip Opening",
2766
- ending: "Skip Ending"
2767
- }, qt = w`
2843
+ }, cn = 1, ln = 6e3, un = 1, dn = {
2844
+ opening: a.skipOpening,
2845
+ ending: a.skipEnding
2846
+ }, fn = E`
2768
2847
  position: absolute;
2769
2848
  inset: 0;
2770
2849
  z-index: 2;
@@ -2781,7 +2860,7 @@ ${mt}
2781
2860
  pointer-events: auto;
2782
2861
  cursor: pointer;
2783
2862
 
2784
- ${Q.bMedium.bold}
2863
+ ${$.bMedium.bold}
2785
2864
  color: #fff;
2786
2865
  padding: calc(1 * var(--mp-unit)) calc(1.8 * var(--mp-unit));
2787
2866
  border: 1px solid rgba(255, 255, 255, .55);
@@ -2815,47 +2894,47 @@ ${mt}
2815
2894
  bottom: calc(9 * var(--mp-unit));
2816
2895
  }
2817
2896
  }
2818
- `, Jt = () => {
2819
- let e = Y((e) => e.chapters), t = Y((e) => e.currentTime), n = Y((e) => e.requestSeek), r = Y((e) => e.seekPreview), i = Y(), a = b(() => f(e), [e]), o = b(() => {
2897
+ `, pn = () => {
2898
+ let e = J((e) => e.chapters), t = J((e) => e.currentTime), n = J((e) => e.requestSeek), r = J((e) => e.seekPreview), i = J(), { format: a } = Q(), o = S(() => m(e), [e]), s = S(() => {
2820
2899
  if (typeof t != "number") return;
2821
- let n = e.findIndex((e, n) => a[n] !== void 0 && e.start - Ut <= t && t < e.end), r = n >= 0 ? a[n] : void 0;
2900
+ let n = e.findIndex((e, n) => o[n] !== void 0 && e.start - cn <= t && t < e.end), r = n >= 0 ? o[n] : void 0;
2822
2901
  return r ? {
2823
2902
  kind: r,
2824
2903
  end: e[n].end
2825
2904
  } : void 0;
2826
2905
  }, [
2827
2906
  e,
2828
- a,
2907
+ o,
2829
2908
  t
2830
- ]), s = x(0), [c, l] = S(0);
2831
- y(() => {
2832
- let e = typeof t == "number" ? t : 0, n = s.current;
2833
- s.current = e, e < n - Gt && l((e) => e + 1);
2909
+ ]), c = C(0), [l, u] = w(0);
2910
+ x(() => {
2911
+ let e = typeof t == "number" ? t : 0, n = c.current;
2912
+ c.current = e, e < n - un && u((e) => e + 1);
2834
2913
  }, [t]);
2835
- let [u, d] = S(!1), p = o ? `${o.kind}@${o.end}` : "";
2836
- return y(() => {
2914
+ let [d, f] = w(!1), p = s ? `${s.kind}@${s.end}` : "";
2915
+ return x(() => {
2837
2916
  if (!p) {
2838
- d(!1);
2917
+ f(!1);
2839
2918
  return;
2840
2919
  }
2841
- d(!0);
2842
- let e = setTimeout(() => d(!1), Wt);
2920
+ f(!0);
2921
+ let e = setTimeout(() => f(!1), ln);
2843
2922
  return () => clearTimeout(e);
2844
- }, [p, c]), y(() => {
2845
- o || d(!1);
2846
- }, [o]), o ? /* @__PURE__ */ P("div", {
2847
- css: qt,
2848
- className: u && !r ? "show" : "",
2923
+ }, [p, l]), x(() => {
2924
+ s || f(!1);
2925
+ }, [s]), s ? /* @__PURE__ */ P("div", {
2926
+ css: fn,
2927
+ className: d && !r ? "show" : "",
2849
2928
  children: /* @__PURE__ */ P("button", {
2850
2929
  type: "button",
2851
2930
  className: "skip-chapter",
2852
2931
  onClick: () => {
2853
- d(!1), n ? n(o.end) : i.seek(o.end);
2932
+ f(!1), n ? n(s.end) : i.seek(s.end);
2854
2933
  },
2855
- children: Kt[o.kind]
2934
+ children: a(dn[s.kind])
2856
2935
  })
2857
2936
  }) : null;
2858
- }, Yt = 3e3, Xt = w`
2937
+ }, mn = 3e3, hn = E`
2859
2938
  position: absolute;
2860
2939
  inset: 0;
2861
2940
  z-index: 2;
@@ -2866,10 +2945,10 @@ ${mt}
2866
2945
  hoverable while faded out, popping a tooltip over nothing. It cascades where pointer-events does
2867
2946
  not, and transitioning it holds the item on screen for the length of the fade. */
2868
2947
  transition: opacity 0.1s cubic-bezier(.4,0,1,1), visibility 0.1s;
2869
- `, Zt = (e, t) => {
2948
+ `, gn = (e, t) => {
2870
2949
  let n = e.left - t.left, r = e.top - t.top;
2871
2950
  return `path(evenodd, 'M0 0H${t.width}V${t.height}H0Z M${n} ${r}H${n + e.width}V${r + e.height}H${n}Z')`;
2872
- }, Qt = w`
2951
+ }, _n = E`
2873
2952
  position: relative;
2874
2953
  background-color: black;
2875
2954
  display: flex;
@@ -2926,39 +3005,44 @@ ${mt}
2926
3005
  &.hide {
2927
3006
  cursor: none;
2928
3007
  }
2929
- `, $t = (e, t = "") => p.toArray(e).flatMap((e, n) => {
2930
- let r = `${t}${g(e) && e.key != null ? e.key : n}`;
2931
- return g(e) && e.type === m ? $t(e.props.children, `${r}/`) : [{
3008
+ `, vn = (e, t = "") => h.toArray(e).flatMap((e, n) => {
3009
+ let r = `${t}${v(e) && e.key != null ? e.key : n}`;
3010
+ return v(e) && e.type === g ? vn(e.props.children, `${r}/`) : [{
2932
3011
  key: r,
2933
3012
  item: e
2934
3013
  }];
2935
- }), en = ({ ref: e, onVideoRef: t, onSubtitleRef: n, overlay: r, controls: i, shortcuts: a, fullscreen: o, children: s }) => {
2936
- let c = Y(), l = Y((e) => e.hideUI), u = Y((e) => e.setHideUI), d = Y((e) => e.hasMedia), f = Y((e) => e.passThroughPictureInPicture), p = x(void 0), m = x("mouse"), h = x({
3014
+ }), yn = ({ ref: e, onVideoRef: t, onSubtitleRef: n, overlay: r, controls: i, shortcuts: a, fullscreen: o, children: s }) => {
3015
+ let c = J(), l = J((e) => e.hideUI), u = J((e) => e.setHideUI), d = J((e) => e.hasMedia), f = J((e) => e.passThroughPictureInPicture), p = C(void 0), m = C("mouse"), h = C({
2937
3016
  x: -1,
2938
3017
  y: -1
2939
- }), g = x(!1), _ = x(null);
2940
- y(() => () => clearTimeout(p.current), []), y(() => {
3018
+ }), g = C(!1), _ = C(null);
3019
+ x(() => () => clearTimeout(p.current), []), x(() => {
3020
+ let e = _.current;
3021
+ if (!e) return;
3022
+ let t = new ResizeObserver(([t]) => e.style.setProperty("--mp-height", `${t.contentRect.height}px`));
3023
+ return t.observe(e), () => t.disconnect();
3024
+ }, []), x(() => {
2941
3025
  d || (clearTimeout(p.current), u(!1));
2942
3026
  }, [d, u]);
2943
3027
  let v = () => {
2944
3028
  d && u(!0);
2945
- }, b = (t) => {
3029
+ }, y = (t) => {
2946
3030
  _.current = t, typeof e == "function" ? e(t) : e && (e.current = t);
2947
- }, S = () => {
3031
+ }, b = () => {
2948
3032
  if (c.passThroughPictureInPicture?.armed) return !0;
2949
3033
  if (m.current !== "mouse") return !1;
2950
3034
  let { x: e, y: t } = h.current;
2951
3035
  if (!_.current || e < 0) return !1;
2952
3036
  let n = document.elementFromPoint(e, t);
2953
3037
  return !n || !_.current.contains(n) || n.closest(".video") ? !1 : !n.closest(".control-bar") || g.current || !!_.current.querySelector(".control-bar [aria-expanded=\"true\"]");
2954
- }, C = () => {
2955
- if (S()) {
2956
- p.current = setTimeout(C, Yt);
3038
+ }, S = () => {
3039
+ if (b()) {
3040
+ p.current = setTimeout(S, mn);
2957
3041
  return;
2958
3042
  }
2959
3043
  v();
2960
3044
  }, w = () => {
2961
- u(!1), clearTimeout(p.current), p.current = setTimeout(C, Yt);
3045
+ u(!1), clearTimeout(p.current), p.current = setTimeout(S, mn);
2962
3046
  }, T = (e) => {
2963
3047
  m.current = e.pointerType, e.pointerType === "mouse" && (h.current = {
2964
3048
  x: e.clientX,
@@ -2968,10 +3052,10 @@ ${mt}
2968
3052
  m.current = e.pointerType, g.current = !0;
2969
3053
  }, D = () => {
2970
3054
  g.current = !1;
2971
- }, O = x(!0);
3055
+ }, O = C(!0);
2972
3056
  return /* @__PURE__ */ F("div", {
2973
- css: Qt,
2974
- ref: b,
3057
+ css: _n,
3058
+ ref: y,
2975
3059
  onPointerMove: T,
2976
3060
  onPointerDown: E,
2977
3061
  onPointerUp: D,
@@ -2985,9 +3069,9 @@ ${mt}
2985
3069
  className: l ? "hide" : "",
2986
3070
  tabIndex: a === "player" ? -1 : void 0,
2987
3071
  children: [
2988
- /* @__PURE__ */ P(Je, { onSubtitleRef: n }),
2989
- $t(r).map(({ key: e, item: t }) => /* @__PURE__ */ P("div", {
2990
- css: Xt,
3072
+ /* @__PURE__ */ P(ut, { onSubtitleRef: n }),
3073
+ vn(r).map(({ key: e, item: t }) => /* @__PURE__ */ P("div", {
3074
+ css: hn,
2991
3075
  style: { ...l ? {
2992
3076
  opacity: "0",
2993
3077
  visibility: "hidden",
@@ -2995,19 +3079,19 @@ ${mt}
2995
3079
  } : {} },
2996
3080
  children: t
2997
3081
  }, e)),
2998
- i === !1 ? null : /* @__PURE__ */ P(at, {
3082
+ i === !1 ? null : /* @__PURE__ */ P(xt, {
2999
3083
  value: !!o,
3000
- children: /* @__PURE__ */ P(zt, {
3084
+ children: /* @__PURE__ */ P(rn, {
3001
3085
  shortcuts: a,
3002
3086
  root: _,
3003
3087
  fullscreen: o
3004
3088
  })
3005
3089
  }),
3006
- /* @__PURE__ */ P(Ht, {}),
3007
- /* @__PURE__ */ P(Jt, {}),
3090
+ /* @__PURE__ */ P(sn, {}),
3091
+ /* @__PURE__ */ P(pn, {}),
3008
3092
  f?.armed && _.current ? /* @__PURE__ */ P("div", {
3009
3093
  className: "pass-through",
3010
- style: { clipPath: Zt(f.armed, _.current.getBoundingClientRect()) },
3094
+ style: { clipPath: gn(f.armed, _.current.getBoundingClientRect()) },
3011
3095
  onPointerOver: f.disarm
3012
3096
  }) : null,
3013
3097
  /* @__PURE__ */ F("div", {
@@ -3030,22 +3114,22 @@ ${mt}
3030
3114
  })
3031
3115
  ]
3032
3116
  });
3033
- }, tn = (e, t) => ({ title: e.options.find((e) => e.id === t)?.label }), nn = (e, t) => e instanceof Promise ? e.then(t) : t(), rn = ({ options: e, children: t }) => {
3034
- let n = "media" in e ? e : null, r = n ? null : e, { title: i, chapters: a } = e, { size: o, downloadedRanges: s, publicPath: l, libavWorkerUrl: u, read: d, thumbnailRead: f, thumbnailsEnabled: p, readsDownload: m } = r ?? {}, h = O(), g = D(), [_, v] = S(null), [C, w] = S(null), T = n?.media ?? _;
3035
- y(() => (h?.(T), () => h?.(null)), [T, h]), be(T, n?.stepFrame);
3036
- let { expose: E } = e, [k, A] = S(null), [j] = S(() => Object.assign(new EventTarget(), {
3117
+ }, bn = (e, t) => ({ title: e.options.find((e) => e.id === t)?.label }), xn = (e, t) => e instanceof Promise ? e.then(t) : t(), Sn = ({ options: e, children: t }) => {
3118
+ let n = "media" in e ? e : null, r = n ? null : e, { title: i, chapters: a } = e, { size: o, downloadedRanges: s, publicPath: c, libavWorkerUrl: l, read: d, thumbnailRead: f, thumbnailsEnabled: p, readsDownload: m } = r ?? {}, h = ee(), g = k(), [_, v] = w(null), [y, b] = w(null), T = n?.media ?? _;
3119
+ x(() => (h?.(T), () => h?.(null)), [T, h]), Pe(T, n?.stepFrame);
3120
+ let { expose: E } = e, [D, O] = w(null), [A] = w(() => Object.assign(new EventTarget(), {
3037
3121
  chapters: [],
3038
- onHostFullscreen: A
3039
- })), M = E === !0 ? {} : E || void 0, N = x(M);
3040
- N.current = M;
3041
- let F = M ? M.id : void 0, I = M ? M.origin : void 0, L = M ? M.channel : void 0;
3042
- y(() => {
3122
+ onHostFullscreen: O
3123
+ })), j = E === !0 ? {} : E || void 0, M = C(j);
3124
+ M.current = j;
3125
+ let N = j ? j.id : void 0, F = j ? j.origin : void 0, I = j ? j.channel : void 0;
3126
+ x(() => {
3043
3127
  if (!E || !T) return;
3044
3128
  let e, t = !1;
3045
3129
  return import("./remote/index.js").then(({ exposePlayer: n }) => {
3046
3130
  t || (e = n(T, {
3047
- ...N.current,
3048
- player: j
3131
+ ...M.current,
3132
+ player: A
3049
3133
  }));
3050
3134
  }).catch(() => {}), () => {
3051
3135
  t = !0, e?.();
@@ -3053,152 +3137,152 @@ ${mt}
3053
3137
  }, [
3054
3138
  T,
3055
3139
  !!E,
3140
+ N,
3056
3141
  F,
3057
- I,
3058
- L
3142
+ I
3059
3143
  ]);
3060
- let R = Y((e) => e.chapters), z = JSON.stringify(R);
3061
- y(() => {
3062
- j.chapters = R, j.dispatchEvent(new Event("chapterschange"));
3063
- }, [z]);
3064
- let B = e.fullscreen ?? (k === null ? void 0 : {
3065
- active: k,
3066
- request: () => j.dispatchEvent(new Event("fullscreenrequest"))
3067
- }), V = b(() => Ve(), [o]);
3068
- ge(_, C, r, m ? V.push : void 0);
3069
- let H = r?.normalizeVolume ?? !0, [U, W] = S(H);
3070
- y(() => {
3071
- W(H);
3072
- }, [H]);
3073
- let ee = x(r?.onNormalizeVolumeChange);
3074
- ee.current = r?.onNormalizeVolumeChange;
3075
- let G = r?.normalizerWorkletUrl, te = x(f ?? d);
3076
- te.current = f ?? d;
3077
- let K = Y((e) => e.selectedAudioTrack), q = !!d, { refused: J } = Be(_, G, U, b(() => q && o && l && u && typeof K == "number" && K >= 0 ? m ? {
3078
- tap: V,
3079
- audioStreamIndex: K
3144
+ let L = J((e) => e.chapters), R = JSON.stringify(L);
3145
+ x(() => {
3146
+ A.chapters = L, A.dispatchEvent(new Event("chapterschange"));
3147
+ }, [R]);
3148
+ let z = e.fullscreen ?? (D === null ? void 0 : {
3149
+ active: D,
3150
+ request: () => A.dispatchEvent(new Event("fullscreenrequest"))
3151
+ }), B = S(() => tt(), [o]);
3152
+ Ae(_, y, r, m ? B.push : void 0);
3153
+ let V = r?.normalizeVolume ?? !0, [te, H] = w(V);
3154
+ x(() => {
3155
+ H(V);
3156
+ }, [V]);
3157
+ let ne = C(r?.onNormalizeVolumeChange);
3158
+ ne.current = r?.onNormalizeVolumeChange;
3159
+ let U = r?.normalizerWorkletUrl, W = C(f ?? d);
3160
+ W.current = f ?? d;
3161
+ let G = J((e) => e.selectedAudioTrack), K = !!d, { refused: q } = et(_, U, te, S(() => K && o && c && l && typeof G == "number" && G >= 0 ? m ? {
3162
+ tap: B,
3163
+ audioStreamIndex: G
3080
3164
  } : {
3081
- read: (e, t) => te.current(e, t),
3165
+ read: (e, t) => W.current(e, t),
3082
3166
  length: o,
3083
- publicPath: l,
3084
- libavWorkerUrl: u,
3085
- audioStreamIndex: K
3167
+ publicPath: c,
3168
+ libavWorkerUrl: l,
3169
+ audioStreamIndex: G
3086
3170
  } : void 0, [
3087
- q,
3171
+ K,
3088
3172
  o,
3173
+ c,
3089
3174
  l,
3090
- u,
3091
- K,
3175
+ G,
3092
3176
  m,
3093
- V
3094
- ]), b(() => s?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [s?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")])), ne = b(() => G && typeof AudioWorkletNode == "function" ? {
3095
- enabled: U,
3096
- available: !J,
3177
+ B
3178
+ ]), S(() => s?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [s?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")])), re = S(() => U && typeof AudioWorkletNode == "function" ? {
3179
+ enabled: te,
3180
+ available: !q,
3097
3181
  setEnabled: (e) => {
3098
- W(e), ee.current?.(e);
3182
+ H(e), ne.current?.(e);
3099
3183
  }
3100
3184
  } : null, [
3101
- G,
3102
3185
  U,
3103
- J
3104
- ]), { thumbnails: re, requestThumbnail: ie } = Ce({
3105
- publicPath: l,
3106
- workerUrl: u,
3186
+ te,
3187
+ q
3188
+ ]), { thumbnails: ie, requestThumbnail: ae } = Le({
3189
+ publicPath: c,
3190
+ workerUrl: l,
3107
3191
  length: p === !1 ? void 0 : o,
3108
3192
  read: f ?? d,
3109
3193
  downloadedRanges: s
3110
- }), ae = n?.thumbnails?.all ?? re, { toggle: oe, mode: se, burnedIn: ce } = we(_, C), le = Ae(n?.media ?? null, n?.pictureInPicture), X = Y((e) => e.setSourceState), ue = n ? !!n.media : o !== void 0;
3111
- y(() => {
3112
- X({
3194
+ }), oe = n?.thumbnails?.all ?? ie, { toggle: se, mode: ce, burnedIn: le } = Re(_, y), ue = We(n?.media ?? null, n?.pictureInPicture), Y = J((e) => e.setSourceState), de = n ? !!n.media : o !== void 0;
3195
+ x(() => {
3196
+ Y({
3113
3197
  title: i,
3114
3198
  size: o,
3115
3199
  downloadedRanges: s,
3116
- hasMedia: ue
3200
+ hasMedia: de
3117
3201
  });
3118
3202
  }, [
3119
- X,
3203
+ Y,
3120
3204
  i,
3121
3205
  o,
3122
3206
  s,
3123
- ue
3207
+ de
3124
3208
  ]);
3125
- let de = n?.thumbnails?.at;
3126
- y(() => {
3127
- X({
3128
- thumbnails: ae,
3129
- thumbnailAt: de,
3130
- requestThumbnail: ie,
3131
- togglePictureInPicture: oe,
3132
- pictureInPictureMode: se,
3133
- burnedInSubtitles: ce
3209
+ let fe = n?.thumbnails?.at;
3210
+ x(() => {
3211
+ Y({
3212
+ thumbnails: oe,
3213
+ thumbnailAt: fe,
3214
+ requestThumbnail: ae,
3215
+ togglePictureInPicture: se,
3216
+ pictureInPictureMode: ce,
3217
+ burnedInSubtitles: le
3134
3218
  });
3135
3219
  }, [
3136
- X,
3137
- ae,
3138
- de,
3139
- ie,
3220
+ Y,
3140
3221
  oe,
3222
+ fe,
3223
+ ae,
3141
3224
  se,
3142
- ce
3143
- ]), y(() => {
3144
- X({ volumeNormalizer: ne });
3145
- }, [X, ne]), y(() => {
3146
- X({ passThroughPictureInPicture: le });
3147
- }, [X, le]);
3148
- let Z = n?.subtitles?.selection, fe = n?.audioTracks?.selection, pe = x({
3225
+ ce,
3226
+ le
3227
+ ]), x(() => {
3228
+ Y({ volumeNormalizer: re });
3229
+ }, [Y, re]), x(() => {
3230
+ Y({ passThroughPictureInPicture: ue });
3231
+ }, [Y, ue]);
3232
+ let X = n?.subtitles?.selection, Z = n?.audioTracks?.selection, pe = C({
3149
3233
  audio: e.onPreferredAudioLanguageChange,
3150
3234
  subtitles: e.onPreferredSubtitleLanguageChange
3151
3235
  });
3152
3236
  pe.current = {
3153
3237
  audio: e.onPreferredAudioLanguageChange,
3154
3238
  subtitles: e.onPreferredSubtitleLanguageChange
3155
- }, y(() => {
3156
- Z && X({
3157
- subtitleTracks: Z.options.map(({ id: e, label: t, disabled: n }) => ({
3239
+ }, x(() => {
3240
+ X && Y({
3241
+ subtitleTracks: X.options.map(({ id: e, label: t, disabled: n }) => ({
3158
3242
  id: e,
3159
3243
  label: t,
3160
3244
  disabled: n
3161
3245
  })),
3162
- selectedSubtitleTrack: Z.selectedId ?? void 0,
3246
+ selectedSubtitleTrack: X.selectedId ?? void 0,
3163
3247
  selectSubtitleTrack: (e) => {
3164
- let t = e == null ? null : String(e), n = t === null ? void 0 : tn(Z, t), r = Z.selectedId === null;
3165
- return nn(Z.select(t), () => {
3166
- let e = t === null ? null : c(n) ?? (r ? n?.title : void 0);
3248
+ let t = e == null ? null : String(e), n = t === null ? void 0 : bn(X, t), r = X.selectedId === null;
3249
+ return xn(X.select(t), () => {
3250
+ let e = t === null ? null : u(n) ?? (r ? n?.title : void 0);
3167
3251
  e !== void 0 && pe.current.subtitles?.(e);
3168
3252
  });
3169
3253
  },
3170
- subtitleOffLabel: Z.offLabel
3254
+ subtitleOffLabel: X.offLabel
3171
3255
  });
3172
- }, [X, Z]), y(() => {
3173
- fe && X({
3174
- audioTracks: fe.options.map(({ id: e, label: t, disabled: n }) => ({
3256
+ }, [Y, X]), x(() => {
3257
+ Z && Y({
3258
+ audioTracks: Z.options.map(({ id: e, label: t, disabled: n }) => ({
3175
3259
  id: e,
3176
3260
  label: t,
3177
3261
  disabled: n
3178
3262
  })),
3179
- selectedAudioTrack: fe.selectedId ?? void 0,
3180
- selectAudioTrack: (e) => nn(fe.select(String(e)), () => {
3181
- let t = c(tn(fe, String(e)));
3263
+ selectedAudioTrack: Z.selectedId ?? void 0,
3264
+ selectAudioTrack: (e) => xn(Z.select(String(e)), () => {
3265
+ let t = u(bn(Z, String(e)));
3182
3266
  t !== void 0 && pe.current.audio?.(t);
3183
3267
  })
3184
3268
  });
3185
- }, [X, fe]);
3269
+ }, [Y, Z]);
3186
3270
  let me = n?.quality?.selection ?? null;
3187
- return y(() => {
3188
- X({ quality: me });
3189
- }, [X, me]), y(() => {
3190
- a && X({ chapters: a });
3191
- }, [X, a]), /* @__PURE__ */ P(en, {
3271
+ return x(() => {
3272
+ Y({ quality: me });
3273
+ }, [Y, me]), x(() => {
3274
+ a && Y({ chapters: a });
3275
+ }, [Y, a]), /* @__PURE__ */ P(yn, {
3192
3276
  ref: g,
3193
3277
  onVideoRef: n ? void 0 : v,
3194
- onSubtitleRef: w,
3278
+ onSubtitleRef: b,
3195
3279
  overlay: e.overlay,
3196
3280
  controls: e.controls,
3197
3281
  shortcuts: e.shortcuts,
3198
- fullscreen: B,
3282
+ fullscreen: z,
3199
3283
  children: t
3200
3284
  });
3201
- }, an = w`
3285
+ }, Cn = E`
3202
3286
  /**
3203
3287
  * The chrome's whole scale, in one place.
3204
3288
  *
@@ -3268,17 +3352,20 @@ ${mt}
3268
3352
  height: 100%;
3269
3353
  width: 100%;
3270
3354
  overflow: hidden;
3271
- `, on = (e) => /* @__PURE__ */ P("div", {
3272
- css: an,
3273
- children: /* @__PURE__ */ P(oe.Provider, { children: /* @__PURE__ */ P(rn, {
3274
- options: e,
3275
- children: e.children
3355
+ `, wn = (e) => /* @__PURE__ */ P("div", {
3356
+ css: Cn,
3357
+ children: /* @__PURE__ */ P(le.Provider, { children: /* @__PURE__ */ P(ve, {
3358
+ language: e.language,
3359
+ children: /* @__PURE__ */ P(Sn, {
3360
+ options: e,
3361
+ children: e.children
3362
+ })
3276
3363
  }) })
3277
- }), sn = (e) => !!e && typeof e == "object" && "at" in e, cn = (e) => !!e && typeof e == "object" && "selection" in e, ln = ({ blob: e, name: t }) => ({
3364
+ }), Tn = (e) => !!e && typeof e == "object" && "at" in e, En = (e) => !!e && typeof e == "object" && "selection" in e, Dn = ({ blob: e, name: t }) => ({
3278
3365
  length: e.size,
3279
3366
  name: t ?? (e instanceof File ? e.name : void 0),
3280
3367
  read: (t, n) => e.slice(t, t + n).arrayBuffer()
3281
- }), un = async (e, t) => {
3368
+ }), On = async (e, t) => {
3282
3369
  let n = await fetch(e, {
3283
3370
  headers: { Range: "bytes=0-1" },
3284
3371
  credentials: t
@@ -3288,8 +3375,8 @@ ${mt}
3288
3375
  if (!Number.isFinite(i) || i <= 0) throw Error("The source did not report its length");
3289
3376
  if (!r && n.status !== 206) throw Error("The source does not support range requests");
3290
3377
  return i;
3291
- }, dn = async ({ url: e, length: t, name: n, credentials: r }) => {
3292
- let i = t ?? await un(e, r);
3378
+ }, kn = async ({ url: e, length: t, name: n, credentials: r }) => {
3379
+ let i = t ?? await On(e, r);
3293
3380
  return {
3294
3381
  length: i,
3295
3382
  name: n,
@@ -3305,9 +3392,9 @@ ${mt}
3305
3392
  },
3306
3393
  readsDownload: !0
3307
3394
  };
3308
- }, fn = async (e) => {
3309
- if ("blob" in e) return ln(e);
3310
- if ("url" in e) return dn(e);
3395
+ }, An = async (e) => {
3396
+ if ("blob" in e) return Dn(e);
3397
+ if ("url" in e) return kn(e);
3311
3398
  if ("read" in e) return {
3312
3399
  length: e.length,
3313
3400
  name: e.name,
@@ -3316,4 +3403,4 @@ ${mt}
3316
3403
  throw Error(`Unknown source type: ${e}`);
3317
3404
  };
3318
3405
  //#endregion
3319
- export { on as MediaPlayer, on as default, oe as Player, t as SUBTITLES_OFF, o as createPictureInPicture, s as createSubtitleRenderer, i as createThumbnailGenerator, fn as inputToRemuxerInput, cn as isDelegatedTracks, sn as isExternalThumbnails, ae as sourceFeature, a as startPlayback, we as usePictureInPicture, Y as usePlayer, Ce as useSeekThumbnails };
3406
+ export { wn as MediaPlayer, wn as default, le as Player, t as SUBTITLES_OFF, c as createPictureInPicture, l as createSubtitleRenderer, o as createThumbnailGenerator, An as inputToRemuxerInput, En as isDelegatedTracks, Tn as isExternalThumbnails, ce as sourceFeature, s as startPlayback, Re as usePictureInPicture, J as usePlayer, Le as useSeekThumbnails };