@banou/media-player 0.7.0 → 0.8.1

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.
package/dist/index.js CHANGED
@@ -5,51 +5,76 @@ import { createPlayer as f, useContainerAttach as p, useMediaAttach as m } from
5
5
  import { definePlayerFeature as h, videoFeatures as g } from "@videojs/core/dom";
6
6
  import { Fragment as _, jsx as v, jsxs as y } from "@emotion/react/jsx-runtime";
7
7
  import { ChevronLeft as b, ChevronRight as x, Maximize as S, Minimize as C, Pause as w, Play as T, RotateCcw as E, Settings as D, Volume1 as O, Volume2 as k, VolumeX as A } from "react-feather";
8
- import { Tooltip as ee } from "react-tooltip";
8
+ import { Tooltip as j } from "react-tooltip";
9
9
  //#region src/lib/react/source-feature.ts
10
- var te = {
10
+ var ee = {
11
11
  indexes: [],
12
12
  thumbnails: [],
13
- subtitleStreams: [],
14
- selectedSubtitleStream: void 0,
15
- selectSubtitleStream: () => {},
16
- audioStreams: [],
17
- selectedAudioStream: -1,
18
- selectAudioStream: () => {},
13
+ subtitleTracks: [],
14
+ selectedSubtitleTrack: void 0,
15
+ selectSubtitleTrack: () => {},
16
+ audioTracks: [],
17
+ selectedAudioTrack: void 0,
18
+ selectAudioTrack: () => {},
19
19
  hideUI: !1,
20
20
  setHideUI: () => {},
21
- togglePictureInPicture: () => {},
21
+ togglePictureInPicture: null,
22
22
  playbackError: null,
23
23
  ready: !1,
24
24
  setSourceState: () => {}
25
- }, j = h({
25
+ }, M = h({
26
26
  name: "source",
27
- state: () => ({ ...te }),
27
+ state: () => ({ ...ee }),
28
28
  attach({ set: e }) {
29
29
  e({
30
30
  setSourceState: (t) => e(t),
31
31
  setHideUI: (t) => e({ hideUI: t })
32
32
  });
33
33
  }
34
- }), M = f({
35
- features: [...g, j],
34
+ }), N = f({
35
+ features: [...g, M],
36
36
  displayName: "MediaPlayer"
37
- }), N = M.usePlayer, ne = (t, n, r) => {
38
- let i = N(), { read: s, size: u, publicPath: d, libavWorkerUrl: f, jassubWorkerUrl: p, jassubWasmUrl: m, jassubLegacyWasmUrl: h, defaultFontUrl: g, bufferSize: _, autoplay: v = !1 } = r, [y, b] = l(void 0), x = c(null), S = c(0), C = c(!1), w = c(s);
37
+ }), P = N.usePlayer, te = (e) => {
38
+ if (!(!e || e === "und")) try {
39
+ return new Intl.DisplayNames([navigator.language || "en"], {
40
+ type: "language",
41
+ fallback: "none"
42
+ }).of(e) || void 0;
43
+ } catch {
44
+ return;
45
+ }
46
+ }, F = (e) => e?.replace(/_/g, " ").trim() || void 0, ne = (e) => {
47
+ let t = e.map((e) => te(e.language) ?? F(e.title) ?? `Track ${e.streamIndex}`), n = t.reduce((e, t) => ({
48
+ ...e,
49
+ [t]: (e[t] ?? 0) + 1
50
+ }), {});
51
+ return e.map((e, r) => {
52
+ let i = t[r], a = F(e.title);
53
+ return {
54
+ track: e,
55
+ label: (n[i] ?? 0) > 1 && a && a !== i ? `${i} (${a})` : i
56
+ };
57
+ });
58
+ }, I = (e) => ne(e).map(({ track: e, label: t }) => ({
59
+ id: e.streamIndex,
60
+ label: t
61
+ })), re = (t, n, r) => {
62
+ let i = P(), { read: s, size: u, publicPath: d = "", libavWorkerUrl: f = "", jassubWorkerUrl: p = "", jassubWasmUrl: m = "", jassubLegacyWasmUrl: h, defaultFontUrl: g, bufferSize: _, autoplay: v = !1 } = r ?? {}, [y, b] = l(void 0), x = c(null), S = c(0), C = c(!1), w = c(s);
39
63
  w.current = s;
40
- let T = c(r.onSeek);
41
- T.current = r.onSeek;
42
- let E = c(r.onPlaybackError);
43
- E.current = r.onPlaybackError;
64
+ let T = c(r?.onSeek);
65
+ T.current = r?.onSeek;
66
+ let E = c(r?.onPlaybackError);
67
+ E.current = r?.onPlaybackError;
44
68
  let D = a((e) => {
45
- C.current = !0, i.setSourceState({ selectedSubtitleStream: e }), x.current?.selectSubtitleStream(e);
69
+ let t = typeof e == "number" ? e : void 0;
70
+ C.current = !0, i.setSourceState({ selectedSubtitleTrack: t }), x.current?.selectSubtitleStream(t);
46
71
  }, [i]), O = a((e) => {
47
- i.setSourceState({ selectedAudioStream: e }), b(e);
48
- }, [i]), k = N((e) => e.setSourceState);
72
+ typeof e == "number" && (i.setSourceState({ selectedAudioTrack: e }), b(e));
73
+ }, [i]), k = P((e) => e.setSourceState);
49
74
  o(() => {
50
75
  k({
51
- selectSubtitleStream: D,
52
- selectAudioStream: O
76
+ selectSubtitleTrack: D,
77
+ selectAudioTrack: O
53
78
  });
54
79
  }, [
55
80
  k,
@@ -90,14 +115,14 @@ var te = {
90
115
  onSeek: (e) => T.current?.(e),
91
116
  onSubtitleStreams: (e) => {
92
117
  r || i.setSourceState({
93
- subtitleStreams: e,
94
- ...C.current ? {} : { selectedSubtitleStream: e[0]?.streamIndex }
118
+ subtitleTracks: I(e),
119
+ ...C.current ? {} : { selectedSubtitleTrack: e[0]?.streamIndex }
95
120
  });
96
121
  },
97
122
  onAudioStreams: (e, t) => {
98
123
  r || i.setSourceState({
99
- audioStreams: e,
100
- selectedAudioStream: t
124
+ audioTracks: I(e),
125
+ selectedAudioTrack: t
101
126
  });
102
127
  }
103
128
  });
@@ -106,8 +131,8 @@ var te = {
106
131
  return;
107
132
  }
108
133
  x.current = o, i.setSourceState({ indexes: o.indexes });
109
- let s = i.selectedSubtitleStream;
110
- s !== void 0 && o.selectSubtitleStream(s);
134
+ let s = i.selectedSubtitleTrack;
135
+ typeof s == "number" && o.selectSubtitleStream(s);
111
136
  } catch (e) {
112
137
  a(e);
113
138
  }
@@ -119,7 +144,6 @@ var te = {
119
144
  t,
120
145
  n,
121
146
  u,
122
- s,
123
147
  d,
124
148
  f,
125
149
  p,
@@ -130,13 +154,13 @@ var te = {
130
154
  y,
131
155
  v
132
156
  ]);
133
- }, re = 5e3, ie = 6e4, P = ({ publicPath: e, workerUrl: n, length: r, read: i, downloadedRanges: a }) => {
157
+ }, L = 5e3, R = 6e4, z = ({ publicPath: e, workerUrl: n, length: r, read: i, downloadedRanges: a }) => {
134
158
  let [u, d] = l([]), f = c(null), p = c(i);
135
159
  p.current = i;
136
160
  let m = s(() => a?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [a?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")]), h = c(m);
137
161
  return h.current = m, o(() => {
138
- if (!r || !i) return;
139
- let a = !1, o = null, s, c = re, l = () => {
162
+ if (!r || !i || !e || !n) return;
163
+ let a = !1, o = null, s, c = L, l = () => {
140
164
  t({
141
165
  publicPath: e,
142
166
  workerUrl: n,
@@ -152,7 +176,7 @@ var te = {
152
176
  }
153
177
  o = e, f.current = e, e.update(h.current);
154
178
  }, () => {
155
- a || (s = setTimeout(l, c), c = Math.min(c * 2, ie));
179
+ a || (s = setTimeout(l, c), c = Math.min(c * 2, R));
156
180
  });
157
181
  };
158
182
  return l(), () => {
@@ -165,9 +189,9 @@ var te = {
165
189
  ]), o(() => {
166
190
  f.current?.update(m);
167
191
  }, [m]), u;
168
- }, F = (e, t) => {
169
- let n = N(), r = c(null);
170
- return o(() => {
192
+ }, B = (e, t) => {
193
+ let n = P(), r = c(null);
194
+ o(() => {
171
195
  if (!e || !t) return;
172
196
  let a = i({
173
197
  video: e,
@@ -181,54 +205,56 @@ var te = {
181
205
  e,
182
206
  t,
183
207
  n
184
- ]), a(() => {
208
+ ]);
209
+ let s = a(() => {
185
210
  r.current?.toggle().catch((e) => {
186
211
  console.warn("picture in picture was refused", e);
187
212
  });
188
213
  }, []);
189
- }, I = {
214
+ return e && t ? s : null;
215
+ }, V = {
190
216
  headings: {
191
- large: "\n font-weight: 600;\n font-size: 2.8rem;\n line-height: 3.4rem;\n @media (min-width: 960px) {\n font-size: 3.4rem;\n line-height: 4.1rem;\n }\n ",
192
- medium: "\n font-weight: 600;\n font-size: 2.4rem;\n line-height: 2.9rem;\n @media (min-width: 960px) {\n font-size: 2.8rem;\n line-height: 3.4rem;\n }\n ",
193
- small: "\n font-weight: 500;\n font-size: 1.8rem;\n line-height: 1.9rem;\n @media (min-width: 960px) {\n font-size: 1.8rem;\n line-height: 2.2rem;\n }\n @media (min-width: 2560px) {\n font-size: 2.2rem;\n line-height: 2.6rem;\n }\n ",
194
- extraSmall: "\n font-weight: 500;\n font-size: 1.4rem;\n line-height: 1.7rem;\n @media (min-width: 960px) {\n font-size: 1.6rem;\n line-height: 1.9rem;\n }\n "
217
+ 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 ",
218
+ 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 ",
219
+ small: "\n font-weight: 500;\n font-size: calc(1.8 * var(--mp-unit));\n line-height: calc(1.9 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.8 * var(--mp-unit));\n line-height: calc(2.2 * var(--mp-unit));\n }\n @media (min-width: 2560px) {\n font-size: calc(2.2 * var(--mp-unit));\n line-height: calc(2.6 * var(--mp-unit));\n }\n ",
220
+ extraSmall: "\n font-weight: 500;\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.6 * var(--mp-unit));\n line-height: calc(1.9 * var(--mp-unit));\n }\n "
195
221
  },
196
222
  bLarge: {
197
- bold: "\n font-weight: 600;\n font-size: 1.4rem;\n line-height: 2rem;\n @media (min-width: 960px) {\n font-size: 1.6rem;\n line-height: 2.2rem;\n }\n ",
198
- medium: "\n font-weight: 500;\n font-size: 1.4rem;\n line-height: 2rem;\n @media (min-width: 960px) {\n font-size: 1.6rem;\n line-height: 2.2rem;\n }\n ",
199
- regular: "\n font-weight: 400;\n font-size: 1.4rem;\n line-height: 2rem;\n @media (min-width: 960px) {\n font-size: 1.6rem;\n line-height: 2.2rem;\n }\n "
223
+ bold: "\n font-weight: 600;\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(2 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.6 * var(--mp-unit));\n line-height: calc(2.2 * var(--mp-unit));\n }\n ",
224
+ medium: "\n font-weight: 500;\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(2 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.6 * var(--mp-unit));\n line-height: calc(2.2 * var(--mp-unit));\n }\n ",
225
+ regular: "\n font-weight: 400;\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(2 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.6 * var(--mp-unit));\n line-height: calc(2.2 * var(--mp-unit));\n }\n "
200
226
  },
201
227
  bMedium: {
202
- bold: "\n font-weight: 600;\n font-size: 1.2rem;\n line-height: 1.7rem;\n @media (min-width: 960px) {\n font-size: 1.4rem;\n line-height: 2rem;\n }\n ",
203
- medium: "\n font-weight: 500;\n font-size: 1.2rem;\n line-height: 1.7rem;\n @media (min-width: 960px) {\n font-size: 1.4rem;\n line-height: 2rem;\n }\n ",
204
- regular: "\n font-weight: 400;\n font-size: 1.2rem;\n line-height: 1.7rem;\n @media (min-width: 960px) {\n font-size: 1.4rem;\n line-height: 2rem;\n }\n "
228
+ bold: "\n font-weight: 600;\n font-size: calc(1.2 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(2 * var(--mp-unit));\n }\n ",
229
+ medium: "\n font-weight: 500;\n font-size: calc(1.2 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(2 * var(--mp-unit));\n }\n ",
230
+ regular: "\n font-weight: 400;\n font-size: calc(1.2 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(2 * var(--mp-unit));\n }\n "
205
231
  },
206
232
  bSmall: {
207
- bold: "\n font-weight: 600;\n font-size: 1rem;\n line-height: 1.4rem;\n @media (min-width: 960px) {\n font-size: 1.2rem;\n line-height: 1.7rem;\n }\n ",
208
- medium: "\n font-weight: 500;\n font-size: 1rem;\n line-height: 1.4rem;\n @media (min-width: 960px) {\n font-size: 1.2rem;\n line-height: 1.7rem;\n }\n ",
209
- regular: "\n font-weight: 400;\n font-size: 1rem;\n line-height: 1.4rem;\n @media (min-width: 960px) {\n font-size: 1.2rem;\n line-height: 1.7rem;\n }\n "
233
+ bold: "\n font-weight: 600;\n font-size: calc(1 * var(--mp-unit));\n line-height: calc(1.4 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.2 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n }\n ",
234
+ medium: "\n font-weight: 500;\n font-size: calc(1 * var(--mp-unit));\n line-height: calc(1.4 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.2 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n }\n ",
235
+ regular: "\n font-weight: 400;\n font-size: calc(1 * var(--mp-unit));\n line-height: calc(1.4 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.2 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n }\n "
210
236
  },
211
237
  bExtraSmall: {
212
- bold: "\n font-weight: 600;\n font-size: 0.8rem;\n line-height: 1.1rem;\n @media (min-width: 960px) {\n font-size: 1rem;\n line-height: 1.4rem;\n }\n ",
213
- medium: "\n font-weight: 500;\n font-size: 0.8rem;\n line-height: 1.1rem;\n @media (min-width: 960px) {\n font-size: 1rem;\n line-height: 1.4rem;\n }\n ",
214
- regular: "\n font-weight: 400;\n font-size: 0.8rem;\n line-height: 1.1rem;\n @media (min-width: 960px) {\n font-size: 1rem;\n line-height: 1.4rem;\n }\n "
238
+ bold: "\n font-weight: 600;\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 ",
239
+ 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 ",
240
+ 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 "
215
241
  }
216
- }, ae = u`
242
+ }, ie = u`
217
243
  top: unset !important;
218
244
  left: unset !important;
219
245
  width: 100%;
220
246
  height: 100%;
221
247
  margin: auto;
222
248
  pointer-events: none;
223
- `, L = u`
249
+ `, ae = u`
224
250
  position: absolute;
225
251
  top: 0;
226
252
  left: 0;
227
253
  width: 100%;
228
- padding: 1.2rem 1.6rem;
254
+ padding: calc(1.2 * var(--mp-unit)) calc(1.6 * var(--mp-unit));
229
255
  /* clears a notch once the player is fullscreen; resolves to zero everywhere else */
230
- padding-top: calc(1.2rem + env(safe-area-inset-top, 0px));
231
- ${I.headings.small}
256
+ padding-top: calc(calc(1.2 * var(--mp-unit)) + env(safe-area-inset-top, 0px));
257
+ ${V.headings.small}
232
258
  color: white;
233
259
  text-shadow: 0 0 4px rgba(0, 0, 0, 1);
234
260
  z-index: 2;
@@ -241,8 +267,8 @@ var te = {
241
267
  text-overflow: ellipsis;
242
268
 
243
269
  @media (min-width: 768px) {
244
- padding: 2.4rem;
245
- padding-top: calc(2.4rem + env(safe-area-inset-top, 0px));
270
+ padding: calc(2.4 * var(--mp-unit));
271
+ padding-top: calc(calc(2.4 * var(--mp-unit)) + env(safe-area-inset-top, 0px));
246
272
  white-space: normal;
247
273
  overflow: visible;
248
274
  }
@@ -260,8 +286,8 @@ var te = {
260
286
 
261
287
  ::after {
262
288
  content: '';
263
- width: 4rem;
264
- height: 4rem;
289
+ width: calc(4 * var(--mp-unit));
290
+ height: calc(4 * var(--mp-unit));
265
291
  border-radius: 50%;
266
292
  border: 3px solid rgba(255, 255, 255, 0.25);
267
293
  border-top-color: #fff;
@@ -273,60 +299,60 @@ var te = {
273
299
  position: absolute;
274
300
  inset: auto 0 20%;
275
301
  z-index: 3;
276
- padding: 0 2rem;
302
+ padding: 0 calc(2 * var(--mp-unit));
277
303
  text-align: center;
278
304
  color: #fff;
279
- ${I.bLarge.regular}
305
+ ${V.bLarge.regular}
280
306
  text-shadow: 0 0 4px rgba(0, 0, 0, 1);
281
307
  pointer-events: none;
282
308
  `, ce = (e) => e instanceof Error ? e.message : typeof e == "string" ? e : "Playback failed", le = ({ onCanvasRef: e }) => {
283
- let t = N((e) => e.title), n = N((e) => e.hideUI), r = N((e) => e.playbackError), i = N((e) => e.ready), a = N((e) => e.size);
309
+ let t = P((e) => e.title), n = P((e) => e.hideUI), r = P((e) => e.playbackError), i = P((e) => e.ready), a = P((e) => e.size), o = P((e) => e.waiting);
284
310
  return /* @__PURE__ */ y(_, { children: [
285
311
  t ? /* @__PURE__ */ v("div", {
286
- css: L,
312
+ css: ae,
287
313
  style: { ...n ? {
288
314
  opacity: "0",
289
315
  pointerEvents: "none"
290
316
  } : {} },
291
317
  children: t
292
318
  }) : void 0,
293
- a && !i && !r ? /* @__PURE__ */ v("div", { css: oe }) : void 0,
319
+ (a ? !i : o) && !r ? /* @__PURE__ */ v("div", { css: oe }) : void 0,
294
320
  r ? /* @__PURE__ */ v("div", {
295
321
  css: se,
296
322
  children: ce(r)
297
323
  }) : void 0,
298
324
  /* @__PURE__ */ v("canvas", {
299
325
  ref: e,
300
- css: ae
326
+ css: ie
301
327
  })
302
328
  ] });
303
- }, R = 1e-4, z = 1, B = (e) => Math.max(R, Math.min(z, e)) ** 2, V = (e) => Math.max(R, Math.min(z, e)) ** (z / 2), H = (e) => {
329
+ }, H = 1e-4, U = 1, W = (e) => Math.max(H, Math.min(U, e)) ** 2, G = (e) => Math.max(H, Math.min(U, e)) ** (U / 2), K = (e) => {
304
330
  if (e === void 0) return "0:00";
305
331
  let t = Math.floor(e / 3600), n = Math.floor(e % 3600 / 60), r = Math.floor(e % 60);
306
332
  return t > 0 ? `${t}:${n < 10 ? "0" : ""}${n}:${r < 10 ? "0" : ""}${r}` : `${n}:${r < 10 ? "0" : ""}${r}`;
307
- }, U = (e, t) => `${H(e)} / ${H(t)}`, W = (e) => u`
333
+ }, ue = (e, t) => `${K(e)} / ${K(t)}`, de = (e) => u`
308
334
  display: flex;
309
335
  justify-content: flex-end;
310
336
 
311
- border-radius: 0.4rem;
337
+ border-radius: calc(0.4 * var(--mp-unit));
312
338
  user-select: none;
313
339
 
314
340
  z-index: 3;
315
341
 
316
342
  * {
317
- ${I.bMedium.regular}
343
+ ${V.bMedium.regular}
318
344
  }
319
345
 
320
346
  ${e === "sm" && u`
321
- padding: 0.4rem!important;
347
+ padding: calc(0.4 * var(--mp-unit))!important;
322
348
  `}
323
349
  ${e === "md" && u`
324
- padding: 0.6rem!important;
350
+ padding: calc(0.6 * var(--mp-unit))!important;
325
351
  `}
326
352
  ${e === "lg" && u`
327
- padding: 1.2rem!important;
353
+ padding: calc(1.2 * var(--mp-unit))!important;
328
354
  `}
329
- `, G = ({ id: e, toolTipText: t, text: n, delayShow: r = 0, closeDelay: i = 0, offset: a = 20, tooltipPlace: o = "top", disabled: s = !1, size: c = "md" }) => /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("div", {
355
+ `, q = ({ id: e, toolTipText: t, text: n, delayShow: r = 0, closeDelay: i = 0, offset: a = 20, tooltipPlace: o = "top", disabled: s = !1, size: c = "md" }) => /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("div", {
330
356
  "data-tooltip-id": e,
331
357
  "data-open": !0,
332
358
  "data-tooltip-offset": a,
@@ -334,12 +360,12 @@ var te = {
334
360
  "data-tooltip-delay-hide": i,
335
361
  "data-tooltip-place": o,
336
362
  children: n
337
- }), !s && /* @__PURE__ */ v(ee, {
338
- css: W(c),
363
+ }), !s && /* @__PURE__ */ v(j, {
364
+ css: de(c),
339
365
  id: e,
340
366
  noArrow: !0,
341
367
  children: t
342
- })] }), K = ({ ref: e, onChange: t, orientation: n = "horizontal", disabled: r = !1 }) => {
368
+ })] }), J = ({ ref: e, onChange: t, orientation: n = "horizontal", disabled: r = !1 }) => {
343
369
  let [i, s] = l(!1), u = c(t);
344
370
  u.current = t;
345
371
  let d = c(null), f = a((t, r) => {
@@ -366,12 +392,12 @@ var te = {
366
392
  style: { touchAction: "none" }
367
393
  }
368
394
  };
369
- }, ue = u`
395
+ }, fe = u`
370
396
  position: relative;
371
- height: .4rem;
397
+ height: calc(.4 * var(--mp-unit));
372
398
 
373
- --thumbnail-width: 25rem;
374
- --thumbnail-half: 12.5rem;
399
+ --thumbnail-width: calc(25 * var(--mp-unit));
400
+ --thumbnail-half: calc(12.5 * var(--mp-unit));
375
401
 
376
402
  transition: transform .2s ease-in-out;
377
403
 
@@ -392,7 +418,7 @@ var te = {
392
418
  }
393
419
  .loaded {
394
420
  transform: scaleY(1.5);
395
- top: -.1rem;
421
+ top: calc(-.1 * var(--mp-unit));
396
422
  }
397
423
  .play-container {
398
424
  transform: scaleY(1.5);
@@ -411,13 +437,13 @@ var te = {
411
437
  justify-content: center;
412
438
 
413
439
  text-shadow: 0 0 4px rgba(0, 0, 0, 1);
414
- ${I.bMedium.bold}
440
+ ${V.bMedium.bold}
415
441
 
416
442
  position: absolute;
417
- top: -2.5rem;
418
- width: 5rem;
443
+ top: calc(-2.5 * var(--mp-unit));
444
+ width: calc(5 * var(--mp-unit));
419
445
 
420
- margin-left: -2.5rem;
446
+ margin-left: calc(-2.5 * var(--mp-unit));
421
447
  pointer-events: none;
422
448
  }
423
449
 
@@ -425,12 +451,12 @@ var te = {
425
451
  transform-origin: 0 0;
426
452
  position: absolute;
427
453
  bottom: 0;
428
- height: .4rem;
454
+ height: calc(.4 * var(--mp-unit));
429
455
  width: 100%;
430
456
  .loaded-part {
431
457
  transform-origin: 0 0;
432
458
  bottom: 0;
433
- height: .4rem;
459
+ height: calc(.4 * var(--mp-unit));
434
460
  width: 100%;
435
461
  position: absolute;
436
462
  background-color: hsla(0, 100%, 100%, .4);
@@ -441,7 +467,7 @@ var te = {
441
467
  position: absolute;
442
468
  bottom: 0;
443
469
  width: 100%;
444
- height: .4rem;
470
+ height: calc(.4 * var(--mp-unit));
445
471
  }
446
472
 
447
473
  .play {
@@ -449,14 +475,14 @@ var te = {
449
475
  background-color: #f03;
450
476
  position: absolute;
451
477
  bottom: 0;
452
- height: .4rem;
478
+ height: calc(.4 * var(--mp-unit));
453
479
  width: 100%;
454
480
  }
455
481
 
456
482
  .padding {
457
483
  position: absolute;
458
484
  bottom: -7.5px;
459
- height: 2rem;
485
+ height: calc(2 * var(--mp-unit));
460
486
  width: 100%;
461
487
  }
462
488
 
@@ -465,7 +491,7 @@ var te = {
465
491
  justify-content: center;
466
492
 
467
493
  position: absolute;
468
- top: calc(-3.4375rem - var(--thumbnail-width) * 9/16);
494
+ top: calc(calc(-3.4375 * var(--mp-unit)) - var(--thumbnail-width) * 9/16);
469
495
  height: calc(var(--thumbnail-width) * 9/16);
470
496
  width: var(--thumbnail-width);
471
497
 
@@ -473,8 +499,8 @@ var te = {
473
499
  pointer-events: none;
474
500
 
475
501
  img {
476
- border-radius: .4rem;
477
- box-shadow: 0 0 1rem rgba(0, 0, 0, .5);
502
+ border-radius: calc(.4 * var(--mp-unit));
503
+ box-shadow: 0 0 calc(1 * var(--mp-unit)) rgba(0, 0, 0, .5);
478
504
 
479
505
  width: 100%;
480
506
  height: 100%;
@@ -482,9 +508,9 @@ var te = {
482
508
  }
483
509
  }
484
510
 
485
- /* a thumb is far wider than a cursor, so the hit strip grows to 44px and the track to .6rem */
511
+ /* a thumb is far wider than a cursor, so the hit strip grows to 44px and the track thickens */
486
512
  @media (pointer: coarse) {
487
- height: .6rem;
513
+ height: calc(.6 * var(--mp-unit));
488
514
 
489
515
  /* press feedback, coarse only: a finger has no hover, so without this the bar gives no sign
490
516
  it is being dragged */
@@ -495,18 +521,18 @@ var te = {
495
521
  }
496
522
 
497
523
  .loaded {
498
- height: .6rem;
524
+ height: calc(.6 * var(--mp-unit));
499
525
  .loaded-part {
500
- height: .6rem;
526
+ height: calc(.6 * var(--mp-unit));
501
527
  }
502
528
  }
503
529
 
504
530
  .play-container {
505
- height: .6rem;
531
+ height: calc(.6 * var(--mp-unit));
506
532
  }
507
533
 
508
534
  .play {
509
- height: .6rem;
535
+ height: calc(.6 * var(--mp-unit));
510
536
  }
511
537
 
512
538
  /* grows upward into the video: centred, it would hang over the control row and win hit
@@ -520,28 +546,28 @@ var te = {
520
546
  /* the clamp only holds the preview inside the bar while the bar is the wider of the two, so
521
547
  below that the preview is narrowed instead */
522
548
  @media (max-width: 480px) {
523
- --thumbnail-width: 18rem;
524
- --thumbnail-half: 9rem;
549
+ --thumbnail-width: calc(18 * var(--mp-unit));
550
+ --thumbnail-half: calc(9 * var(--mp-unit));
525
551
  }
526
- `, de = () => {
527
- let e = N(), t = N((e) => e.currentTime), n = N((e) => e.duration), r = N((e) => e.size), i = N((e) => e.downloadedRanges), a = N((e) => e.indexes), u = N((e) => e.thumbnails), d = c(null), [f, p] = l(void 0), [m, h] = l(void 0), g = c(void 0), { dragging: _, handlers: b } = K({
528
- ref: d,
552
+ `, pe = () => {
553
+ let e = P(), t = P((e) => e.currentTime), n = P((e) => e.duration), r = P((e) => e.size), i = P((e) => e.downloadedRanges), a = P((e) => e.indexes), u = P((e) => e.thumbnails), d = P((e) => e.thumbnailAt), f = c(null), [p, m] = l(void 0), [h, g] = l(void 0), _ = c(void 0), { dragging: b, handlers: x } = J({
554
+ ref: f,
529
555
  onChange: (e) => {
530
- p(e), g.current !== "mouse" && h(e * n);
556
+ m(e), _.current !== "mouse" && g(e * n);
531
557
  }
532
- }), x = (e) => {
533
- g.current = e.pointerType, b.onPointerDown(e);
534
- }, S = (e) => {
535
- b.onPointerUp(e), e.pointerType !== "mouse" && h(void 0);
558
+ }), S = (e) => {
559
+ _.current = e.pointerType, x.onPointerDown(e);
536
560
  }, C = (e) => {
537
- if (!d.current) return;
538
- let { left: t, right: r } = d.current.getBoundingClientRect();
539
- return Math.min(Math.max((e - t) / (r - t), 0), 1) * n;
561
+ x.onPointerUp(e), e.pointerType !== "mouse" && g(void 0);
540
562
  }, w = (e) => {
541
- h(C(e.clientX));
542
- }, T = () => {
543
- d.current && h(void 0);
544
- }, E = (e) => n ? e / n * 100 : 0, D = s(() => i?.map((e, t) => {
563
+ if (!f.current) return;
564
+ let { left: t, right: r } = f.current.getBoundingClientRect();
565
+ return Math.min(Math.max((e - t) / (r - t), 0), 1) * n;
566
+ }, T = (e) => {
567
+ g(w(e.clientX));
568
+ }, E = () => {
569
+ f.current && g(void 0);
570
+ }, D = (e) => n ? e / n * 100 : 0, O = s(() => i?.map((e, t) => {
545
571
  if (!r || !n) return null;
546
572
  let i = a.filter((t) => e.startByteOffset <= t.pos && t.pos <= e.endByteOffset), o = i.at(0), s = i.at(-1);
547
573
  if (!o || !s) return null;
@@ -557,87 +583,73 @@ var te = {
557
583
  n,
558
584
  a.length,
559
585
  i?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}/${t}`).join(",")
560
- ]), O = s(() => {
561
- if (!m || m < 0) return;
562
- let e = Math.floor(m / 3600), t = Math.floor((m - e * 3600) / 60), n = Math.floor(m - e * 3600 - t * 60);
586
+ ]), k = s(() => {
587
+ if (!h || h < 0) return;
588
+ let e = Math.floor(h / 3600), t = Math.floor((h - e * 3600) / 60), n = Math.floor(h - e * 3600 - t * 60);
563
589
  return `${e > 0 ? `${e}:` : ""}${t < 10 ? "0" : ""}${t}:${n < 10 ? "0" : ""}${n}`;
564
- }, [m]);
590
+ }, [h]);
565
591
  o(() => {
566
- if (f === void 0 || !n) return;
567
- let t = f * n;
592
+ if (p === void 0 || !n) return;
593
+ let t = p * n;
568
594
  e.seek(t);
569
595
  }, [
570
596
  e,
571
- f,
597
+ p,
572
598
  n
573
599
  ]);
574
- let k = s(() => !n || typeof t != "number" ? 0 : t / n, [n, t]), A = s(() => {
575
- if (!(!u.length || !m)) return u.find(({ startTime: e, endTime: t }) => e <= m && m < t);
576
- }, [u.length, m]);
600
+ let A = s(() => !n || typeof t != "number" ? 0 : t / n, [n, t]), j = s(() => {
601
+ if (h) {
602
+ if (d) return d(h);
603
+ if (u.length) return u.find(({ startTime: e, endTime: t }) => e <= h && h < t);
604
+ }
605
+ }, [
606
+ u,
607
+ d,
608
+ h
609
+ ]);
577
610
  return /* @__PURE__ */ y("div", {
578
- css: ue,
579
- ref: d,
580
- className: _ ? "progress-bar dragging" : "progress-bar",
581
- onMouseMove: w,
582
- onMouseOut: T,
611
+ css: fe,
612
+ ref: f,
613
+ className: b ? "progress-bar dragging" : "progress-bar",
614
+ onMouseMove: T,
615
+ onMouseOut: E,
583
616
  children: [
584
617
  /* @__PURE__ */ v("div", { className: "background-bar" }),
585
- m ? /* @__PURE__ */ v("div", {
618
+ h ? /* @__PURE__ */ v("div", {
586
619
  className: "cursor-time",
587
- style: { left: `clamp(1.8rem, ${E(m)}%, calc(100% - 1.8rem))` },
588
- children: O
620
+ style: { left: `clamp(calc(1.8 * var(--mp-unit)), ${D(h)}%, calc(100% - calc(1.8 * var(--mp-unit))))` },
621
+ children: k
589
622
  }) : void 0,
590
623
  /* @__PURE__ */ v("div", { className: "progress" }),
591
624
  /* @__PURE__ */ v("div", {
592
625
  className: "loaded",
593
- children: D
626
+ children: O
594
627
  }),
595
628
  /* @__PURE__ */ v("div", { className: "hover" }),
596
629
  /* @__PURE__ */ v("div", {
597
630
  className: "play-container",
598
631
  children: /* @__PURE__ */ v("div", {
599
632
  className: "play",
600
- style: { transform: `scaleX(${k})` }
633
+ style: { transform: `scaleX(${A})` }
601
634
  })
602
635
  }),
603
636
  /* @__PURE__ */ v("div", { className: "chapters" }),
604
637
  /* @__PURE__ */ v("div", { className: "scrubber" }),
605
638
  /* @__PURE__ */ v("div", {
606
639
  className: "padding",
607
- ...b,
608
- onPointerDown: x,
609
- onPointerUp: S,
610
- onPointerCancel: S
640
+ ...x,
641
+ onPointerDown: S,
642
+ onPointerUp: C,
643
+ onPointerCancel: C
611
644
  }),
612
645
  /* @__PURE__ */ v("div", {
613
646
  className: "thumbnail",
614
- style: { left: `clamp(var(--thumbnail-half), ${E(m ?? 1)}%, calc(100% - var(--thumbnail-half)))` },
615
- children: A?.url ? /* @__PURE__ */ v("img", { src: A.url }) : void 0
647
+ style: { left: `clamp(var(--thumbnail-half), ${D(h ?? 1)}%, calc(100% - var(--thumbnail-half)))` },
648
+ children: j?.url ? /* @__PURE__ */ v("img", { src: j.url }) : void 0
616
649
  })
617
650
  ]
618
651
  });
619
- }, fe = "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", pe = (e) => {
620
- if (!(!e || e === "und")) try {
621
- return new Intl.DisplayNames([navigator.language || "en"], {
622
- type: "language",
623
- fallback: "none"
624
- }).of(e) || void 0;
625
- } catch {
626
- return;
627
- }
628
- }, q = (e) => e?.replace(/_/g, " ").trim() || void 0, me = (e) => {
629
- let t = e.map((e) => pe(e.language) ?? q(e.title) ?? `Track ${e.streamIndex}`), n = t.reduce((e, t) => ({
630
- ...e,
631
- [t]: (e[t] ?? 0) + 1
632
- }), {});
633
- return e.map((e, r) => {
634
- let i = t[r], a = q(e.title);
635
- return {
636
- track: e,
637
- label: (n[i] ?? 0) > 1 && a && a !== i ? `${i} (${a})` : i
638
- };
639
- });
640
- }, he = u`
652
+ }, me = "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", he = u`
641
653
  display: flex;
642
654
  align-items: center;
643
655
  justify-content: center;
@@ -691,7 +703,7 @@ width: 100%;
691
703
  }
692
704
  }
693
705
  `, ge = () => {
694
- let e = N(), t = N((e) => e.playbackRate), n = c(null), r = c(null), i = .25, a = 3 - i, s = (e, t = .05) => Math.round(e / t) * t, l = s(t || 1), u = (e) => (e - i) / a * 100, d = (e) => s(i + e * a), { handlers: f } = K({
706
+ let e = P(), t = P((e) => e.playbackRate), n = c(null), r = c(null), i = .25, a = 3 - i, s = (e, t = .05) => Math.round(e / t) * t, l = s(t || 1), u = (e) => (e - i) / a * 100, d = (e) => s(i + e * a), { handlers: f } = J({
695
707
  ref: r,
696
708
  onChange: (t) => e.setPlaybackRate(d(t))
697
709
  }), p = (t) => {
@@ -763,7 +775,7 @@ position: relative;
763
775
 
764
776
  border-radius: 8px;
765
777
  background-color: rgba(28,28,28,0.95);
766
- ${I.bMedium.regular}
778
+ ${V.bMedium.regular}
767
779
 
768
780
  z-index: 4;
769
781
 
@@ -806,7 +818,7 @@ position: relative;
806
818
 
807
819
  .secondary {
808
820
  color: #eee;
809
- ${I.bSmall.regular}
821
+ ${V.bSmall.regular}
810
822
  }
811
823
  }
812
824
  }
@@ -874,10 +886,7 @@ position: relative;
874
886
  word-break: break-word;
875
887
  }
876
888
  }
877
- `, J = (e) => me(e).map(({ track: e, label: t }) => ({
878
- streamIndex: e.streamIndex,
879
- label: t
880
- })), Y = ({ title: e, tracks: t, selected: n, onSelect: r, onBack: i, allowDisable: a }) => /* @__PURE__ */ y("div", {
889
+ `, Y = ({ title: e, tracks: t, selected: n, onSelect: r, onBack: i, allowDisable: a }) => /* @__PURE__ */ y("div", {
881
890
  className: "popover track-list",
882
891
  children: [
883
892
  /* @__PURE__ */ y("div", {
@@ -889,59 +898,59 @@ position: relative;
889
898
  onClick: () => r(void 0),
890
899
  children: [/* @__PURE__ */ v("span", { children: "Disable" }), /* @__PURE__ */ v("span", { children: n === void 0 ? "✓" : "" })]
891
900
  }) : null,
892
- t.map(({ streamIndex: e, label: t }) => /* @__PURE__ */ y("div", {
901
+ t.map(({ id: e, label: t }) => /* @__PURE__ */ y("div", {
893
902
  onClick: () => r(e),
894
903
  className: "description",
895
904
  children: [/* @__PURE__ */ v("span", { children: t }), /* @__PURE__ */ v("span", { children: n === e ? "✓" : "" })]
896
905
  }, e))
897
906
  ]
898
907
  }), ve = () => {
899
- let e = N(), t = N((e) => e.playbackRate), n = N((e) => e.subtitleStreams), r = N((e) => e.selectedSubtitleStream), i = N((e) => e.selectSubtitleStream), a = N((e) => e.audioStreams), u = N((e) => e.selectedAudioStream), d = N((e) => e.selectAudioStream), [f, p] = l(!1), [m, h] = l(0), g = c(null), _ = () => {
900
- p(!f), h(0);
901
- }, S = (t) => {
902
- e.setPlaybackRate(t), h(0);
908
+ let e = P(), t = P((e) => e.playbackRate), n = P((e) => e.subtitleTracks), r = P((e) => e.selectedSubtitleTrack), i = P((e) => e.selectSubtitleTrack), a = P((e) => e.audioTracks), s = P((e) => e.selectedAudioTrack), u = P((e) => e.selectAudioTrack), [d, f] = l(!1), [p, m] = l(0), h = c(null), g = () => {
909
+ f(!d), m(0);
910
+ }, _ = (t) => {
911
+ e.setPlaybackRate(t), m(0);
903
912
  };
904
913
  o(() => {
905
914
  let e = (e) => {
906
- f && g.current && !g.current.contains(e.target) && _();
915
+ d && h.current && !h.current.contains(e.target) && g();
907
916
  };
908
917
  return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
909
- }, [f]);
910
- let C = s(() => J(n), [n]), w = s(() => J(a), [a]), T = (e) => {
911
- i(e), _();
912
- }, E = (e) => {
913
- e !== void 0 && d(e), _();
914
- }, O = (e) => () => {
915
- h(e);
918
+ }, [d]);
919
+ let S = (e) => {
920
+ i(e), g();
921
+ }, C = (e) => {
922
+ e !== void 0 && u(e), g();
923
+ }, w = (e) => () => {
924
+ m(e);
916
925
  };
917
926
  return /* @__PURE__ */ y("div", {
918
927
  css: _e,
919
- ref: g,
928
+ ref: h,
920
929
  children: [
921
- /* @__PURE__ */ v(G, {
930
+ /* @__PURE__ */ v(q, {
922
931
  id: "settings",
923
- disabled: f,
932
+ disabled: d,
924
933
  text: /* @__PURE__ */ v("button", {
925
934
  className: "settings",
926
935
  type: "button",
927
- onClick: _,
936
+ onClick: g,
928
937
  children: /* @__PURE__ */ v(D, {})
929
938
  }),
930
939
  toolTipText: /* @__PURE__ */ v("span", { children: "Settings" })
931
940
  }),
932
- f && m === 0 && /* @__PURE__ */ y("div", {
941
+ d && p === 0 && /* @__PURE__ */ y("div", {
933
942
  className: "popover menu",
934
943
  children: [
935
- w.length > 1 ? /* @__PURE__ */ y("div", {
936
- onClick: O(3),
944
+ a.length > 1 ? /* @__PURE__ */ y("div", {
945
+ onClick: w(3),
937
946
  children: [/* @__PURE__ */ v("div", { children: "Audio" }), /* @__PURE__ */ v("div", { children: /* @__PURE__ */ v(x, {}) })]
938
947
  }) : null,
939
- C.length > 0 ? /* @__PURE__ */ y("div", {
940
- onClick: O(2),
948
+ n.length > 0 ? /* @__PURE__ */ y("div", {
949
+ onClick: w(2),
941
950
  children: [/* @__PURE__ */ v("div", { children: "Subtitles" }), /* @__PURE__ */ v("div", { children: /* @__PURE__ */ v(x, {}) })]
942
951
  }) : null,
943
952
  /* @__PURE__ */ y("div", {
944
- onClick: O(1),
953
+ onClick: w(1),
945
954
  children: [/* @__PURE__ */ v("div", { children: "Playback speed" }), /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("span", {
946
955
  className: "secondary",
947
956
  children: t === 1 ? "(Default)" : t.toFixed(2)
@@ -949,12 +958,12 @@ position: relative;
949
958
  })
950
959
  ]
951
960
  }),
952
- f && m === 1 && /* @__PURE__ */ y("div", {
961
+ d && p === 1 && /* @__PURE__ */ y("div", {
953
962
  className: "popover playback-rate",
954
963
  children: [
955
964
  /* @__PURE__ */ y("div", {
956
965
  className: "back",
957
- onClick: O(0),
966
+ onClick: w(0),
958
967
  children: [/* @__PURE__ */ v(b, {}), /* @__PURE__ */ v("span", { children: "Playback speed" })]
959
968
  }),
960
969
  /* @__PURE__ */ v("div", {
@@ -965,39 +974,39 @@ position: relative;
965
974
  className: "options no-hover",
966
975
  children: [
967
976
  /* @__PURE__ */ v("div", {
968
- onClick: () => S(.5),
977
+ onClick: () => _(.5),
969
978
  children: "0.5x"
970
979
  }),
971
980
  /* @__PURE__ */ v("div", {
972
- onClick: () => S(1),
981
+ onClick: () => _(1),
973
982
  children: "1x"
974
983
  }),
975
984
  /* @__PURE__ */ v("div", {
976
- onClick: () => S(1.5),
985
+ onClick: () => _(1.5),
977
986
  children: "1.5x"
978
987
  }),
979
988
  /* @__PURE__ */ v("div", {
980
- onClick: () => S(2),
989
+ onClick: () => _(2),
981
990
  children: "2x"
982
991
  })
983
992
  ]
984
993
  })
985
994
  ]
986
995
  }),
987
- f && m === 2 && /* @__PURE__ */ v(Y, {
996
+ d && p === 2 && /* @__PURE__ */ v(Y, {
988
997
  title: "Subtitles",
989
- tracks: C,
998
+ tracks: n,
990
999
  selected: r,
991
- onSelect: T,
992
- onBack: O(0),
1000
+ onSelect: S,
1001
+ onBack: w(0),
993
1002
  allowDisable: !0
994
1003
  }),
995
- f && m === 3 && /* @__PURE__ */ v(Y, {
1004
+ d && p === 3 && /* @__PURE__ */ v(Y, {
996
1005
  title: "Audio",
997
- tracks: w,
998
- selected: u,
999
- onSelect: E,
1000
- onBack: O(0)
1006
+ tracks: a,
1007
+ selected: s,
1008
+ onSelect: C,
1009
+ onBack: w(0)
1001
1010
  })
1002
1011
  ]
1003
1012
  });
@@ -1051,7 +1060,7 @@ position: relative;
1051
1060
  height: 10px;
1052
1061
  }
1053
1062
  `, xe = ({ value: e, onChange: t }) => {
1054
- let n = N((e) => e.volume), r = N((e) => e.muted), i = c(null), a = c(null), { handlers: l } = K({
1063
+ let n = P((e) => e.volume), r = P((e) => e.muted), i = c(null), a = c(null), { handlers: l } = J({
1055
1064
  ref: a,
1056
1065
  onChange: t
1057
1066
  }), u = (n) => {
@@ -1065,8 +1074,8 @@ position: relative;
1065
1074
  e && e.removeEventListener("wheel", u);
1066
1075
  };
1067
1076
  }, [e]);
1068
- let d = e * 100, f = s(() => Math.round(r ? 0 : V(n) * 100), [n, r]);
1069
- return /* @__PURE__ */ v(G, {
1077
+ let d = e * 100, f = s(() => Math.round(r ? 0 : G(n) * 100), [n, r]);
1078
+ return /* @__PURE__ */ v(q, {
1070
1079
  id: "volume-slider",
1071
1080
  text: /* @__PURE__ */ v("div", {
1072
1081
  ref: i,
@@ -1114,14 +1123,14 @@ position: relative;
1114
1123
  border-radius: 4px;
1115
1124
 
1116
1125
  .volume-value {
1117
- ${I.bMedium.regular};
1126
+ ${V.bMedium.regular};
1118
1127
  color: #ffffff;
1119
1128
  }
1120
1129
  }
1121
1130
  }
1122
1131
 
1123
1132
  &:hover .volume-slider-container {
1124
- width: 9rem;
1133
+ width: calc(9 * var(--mp-unit));
1125
1134
 
1126
1135
  transition: margin .2s cubic-bezier(0,0,0.2,1), width .2s cubic-bezier(0,0,0.2,1);
1127
1136
  -webkit-transition: margin .2s cubic-bezier(0,0,0.2,1), width .2s cubic-bezier(0,0,0.2,1);
@@ -1153,10 +1162,10 @@ position: relative;
1153
1162
  }
1154
1163
 
1155
1164
  `, Ce = ({ ref: e }) => {
1156
- let t = N(), n = N((e) => e.volume), r = N((e) => e.muted), i = s(() => V(n), [n]);
1165
+ let t = P(), n = P((e) => e.volume), r = P((e) => e.muted), i = s(() => G(n), [n]);
1157
1166
  return /* @__PURE__ */ y("div", {
1158
1167
  css: Se,
1159
- children: [/* @__PURE__ */ v(G, {
1168
+ children: [/* @__PURE__ */ v(q, {
1160
1169
  id: "sound",
1161
1170
  text: /* @__PURE__ */ v("button", {
1162
1171
  className: "sound",
@@ -1176,7 +1185,7 @@ position: relative;
1176
1185
  children: /* @__PURE__ */ v(xe, {
1177
1186
  value: r ? 0 : i,
1178
1187
  onChange: (e) => {
1179
- t.setVolume(B(e));
1188
+ t.setVolume(W(e));
1180
1189
  }
1181
1190
  })
1182
1191
  })
@@ -1283,7 +1292,7 @@ position: relative;
1283
1292
 
1284
1293
  .left {
1285
1294
  .time {
1286
- ${I.bMedium.regular}
1295
+ ${V.bMedium.regular}
1287
1296
  text-shadow: 0 0 4px rgba(0, 0, 0, 1);
1288
1297
  }
1289
1298
  }
@@ -1305,9 +1314,9 @@ position: relative;
1305
1314
  }
1306
1315
  }
1307
1316
  `, Te = () => {
1308
- let e = N(), t = N((e) => e.paused), n = N((e) => e.currentTime), r = N((e) => e.duration), i = N((e) => e.fullscreen), s = N((e) => e.hideUI), c = N((e) => e.togglePictureInPicture), [u, d] = l(null), f = r > 0 && n === r, p = a(({ direction: t, stepSize: n }) => {
1309
- let r = V(e.volume), i = t === "up" ? n : -n, a = Math.max(0, Math.min(1, r + i)), o = e.muted;
1310
- e.setVolume(B(a)), o && !e.muted && e.toggleMuted();
1317
+ let e = P(), t = P((e) => e.paused), n = P((e) => e.currentTime), r = P((e) => e.duration), i = P((e) => e.fullscreen), s = P((e) => e.hideUI), c = P((e) => e.togglePictureInPicture), [u, d] = l(null), f = r > 0 && n === r, p = a(({ direction: t, stepSize: n }) => {
1318
+ let r = G(e.volume), i = t === "up" ? n : -n, a = Math.max(0, Math.min(1, r + i)), o = e.muted;
1319
+ e.setVolume(W(a)), o && !e.muted && e.toggleMuted();
1311
1320
  }, [e]);
1312
1321
  o(() => {
1313
1322
  let t = (t) => {
@@ -1351,12 +1360,12 @@ position: relative;
1351
1360
  opacity: "0",
1352
1361
  pointerEvents: "none"
1353
1362
  } : {} },
1354
- children: [/* @__PURE__ */ v(de, {}), /* @__PURE__ */ y("div", {
1363
+ children: [/* @__PURE__ */ v(pe, {}), /* @__PURE__ */ y("div", {
1355
1364
  className: "actions",
1356
1365
  children: [/* @__PURE__ */ y("div", {
1357
1366
  className: "left",
1358
1367
  children: [
1359
- /* @__PURE__ */ v(G, {
1368
+ /* @__PURE__ */ v(q, {
1360
1369
  id: "play",
1361
1370
  tooltipPlace: "top-start",
1362
1371
  text: /* @__PURE__ */ v("button", {
@@ -1370,24 +1379,24 @@ position: relative;
1370
1379
  /* @__PURE__ */ v(Ce, { ref: d }),
1371
1380
  /* @__PURE__ */ v("div", {
1372
1381
  className: "time",
1373
- children: U(n, r)
1382
+ children: ue(n, r)
1374
1383
  })
1375
1384
  ]
1376
1385
  }), /* @__PURE__ */ y("div", {
1377
1386
  className: "right",
1378
1387
  children: [
1379
1388
  /* @__PURE__ */ v(ve, {}),
1380
- /* @__PURE__ */ v(G, {
1389
+ c ? /* @__PURE__ */ v(q, {
1381
1390
  id: "picture-in-picture",
1382
1391
  text: /* @__PURE__ */ v("button", {
1383
1392
  className: "picture-in-picture",
1384
1393
  type: "button",
1385
1394
  onClick: c,
1386
- children: /* @__PURE__ */ v("img", { src: fe })
1395
+ children: /* @__PURE__ */ v("img", { src: me })
1387
1396
  }),
1388
1397
  toolTipText: /* @__PURE__ */ v("span", { children: "Picture in picture" })
1389
- }),
1390
- /* @__PURE__ */ v(G, {
1398
+ }) : null,
1399
+ /* @__PURE__ */ v(q, {
1391
1400
  id: "full-screen",
1392
1401
  tooltipPlace: "top-end",
1393
1402
  text: /* @__PURE__ */ v("button", {
@@ -1434,84 +1443,121 @@ position: relative;
1434
1443
  &.hide {
1435
1444
  cursor: none;
1436
1445
  }
1437
- `, Oe = ({ ref: e, onVideoRef: t, onCanvasRef: n, children: r }) => {
1438
- let i = N(), a = N((e) => e.hideUI), s = N((e) => e.setHideUI), l = c(void 0), u = c("mouse");
1439
- o(() => () => clearTimeout(l.current), []);
1440
- let d = () => {
1441
- s(!1), clearTimeout(l.current), l.current = setTimeout(() => s(!0), Ee);
1446
+ `, Oe = ({ ref: e, onVideoRef: t, onCanvasRef: n, overlay: r, children: i }) => {
1447
+ let a = P(), s = P((e) => e.hideUI), l = P((e) => e.setHideUI), u = c(void 0), d = c("mouse");
1448
+ o(() => () => clearTimeout(u.current), []);
1449
+ let f = () => {
1450
+ l(!1), clearTimeout(u.current), u.current = setTimeout(() => l(!0), Ee);
1442
1451
  };
1443
1452
  return /* @__PURE__ */ y("div", {
1444
1453
  css: De,
1445
1454
  ref: e,
1446
1455
  onPointerMove: (e) => {
1447
- u.current = e.pointerType, e.pointerType === "mouse" && d();
1456
+ d.current = e.pointerType, e.pointerType === "mouse" && f();
1448
1457
  },
1449
1458
  onPointerDown: (e) => {
1450
- u.current = e.pointerType;
1459
+ d.current = e.pointerType;
1451
1460
  },
1452
1461
  onMouseOut: (e) => {
1453
1462
  let t = e.relatedTarget;
1454
1463
  if (t && e.currentTarget.contains(t)) return;
1455
1464
  let { left: n, right: r, top: i, bottom: a } = e.currentTarget.getBoundingClientRect();
1456
- e.clientX >= n && e.clientX < r && e.clientY >= i && e.clientY < a || (clearTimeout(l.current), s(!0));
1465
+ e.clientX >= n && e.clientX < r && e.clientY >= i && e.clientY < a || (clearTimeout(u.current), l(!0));
1457
1466
  },
1458
- className: a ? "hide" : "",
1467
+ className: s ? "hide" : "",
1459
1468
  children: [
1460
1469
  /* @__PURE__ */ v(le, { onCanvasRef: n }),
1470
+ r,
1461
1471
  /* @__PURE__ */ v(Te, {}),
1462
1472
  /* @__PURE__ */ y("div", {
1463
1473
  className: "video",
1464
1474
  onClick: () => {
1465
- if (u.current === "mouse") {
1466
- i.togglePaused();
1475
+ if (d.current === "mouse") {
1476
+ a.togglePaused();
1467
1477
  return;
1468
1478
  }
1469
- a ? d() : (clearTimeout(l.current), s(!0));
1479
+ s ? f() : (clearTimeout(u.current), l(!0));
1470
1480
  },
1471
- children: [/* @__PURE__ */ v("video", {
1481
+ children: [t ? /* @__PURE__ */ v("video", {
1472
1482
  ref: t,
1473
1483
  playsInline: !0
1474
- }), r]
1484
+ }) : null, i]
1475
1485
  })
1476
1486
  ]
1477
1487
  });
1478
- }, ke = ({ options: e, children: t }) => {
1479
- let { title: n, size: r, downloadedRanges: i, publicPath: a, libavWorkerUrl: s, read: c } = e, u = m(), d = p(), [f, h] = l(null), [g, _] = l(null);
1480
- o(() => (u?.(f), () => u?.(null)), [f, u]), ne(f, g, e);
1481
- let y = P({
1482
- publicPath: a,
1483
- workerUrl: s,
1484
- length: r,
1485
- read: c,
1486
- downloadedRanges: i
1487
- }), b = F(f, g), x = N((e) => e.setSourceState);
1488
- return o(() => {
1489
- x({
1490
- title: n,
1491
- size: r,
1492
- downloadedRanges: i
1488
+ }, Q = ({ options: e, children: t }) => {
1489
+ let n = "media" in e ? e : null, r = n ? null : e, { title: i } = e, { size: a, downloadedRanges: s, publicPath: c, libavWorkerUrl: u, read: d, thumbnailRead: f, thumbnailsEnabled: h } = r ?? {}, g = m(), _ = p(), [y, b] = l(null), [x, S] = l(null), C = n?.media ?? y;
1490
+ o(() => (g?.(C), () => g?.(null)), [C, g]), re(y, x, r);
1491
+ let w = z({
1492
+ publicPath: c,
1493
+ workerUrl: u,
1494
+ length: h === !1 ? void 0 : a,
1495
+ read: f ?? d,
1496
+ downloadedRanges: s
1497
+ }), T = n?.thumbnails?.all ?? w, E = B(y, x), D = P((e) => e.setSourceState);
1498
+ o(() => {
1499
+ D({
1500
+ title: i,
1501
+ size: a,
1502
+ downloadedRanges: s
1493
1503
  });
1494
1504
  }, [
1495
- x,
1496
- n,
1497
- r,
1498
- i
1499
- ]), o(() => {
1500
- x({
1501
- thumbnails: y,
1502
- togglePictureInPicture: b
1505
+ D,
1506
+ i,
1507
+ a,
1508
+ s
1509
+ ]);
1510
+ let O = n?.thumbnails?.at;
1511
+ o(() => {
1512
+ D({
1513
+ thumbnails: T,
1514
+ thumbnailAt: O,
1515
+ togglePictureInPicture: E
1503
1516
  });
1504
1517
  }, [
1505
- x,
1506
- y,
1507
- b
1508
- ]), /* @__PURE__ */ v(Oe, {
1509
- ref: d,
1510
- onVideoRef: h,
1511
- onCanvasRef: _,
1518
+ D,
1519
+ T,
1520
+ O,
1521
+ E
1522
+ ]);
1523
+ let k = n?.subtitles?.selection, A = n?.audioTracks?.selection;
1524
+ return o(() => {
1525
+ k && D({
1526
+ subtitleTracks: k.options.map(({ id: e, label: t }) => ({
1527
+ id: e,
1528
+ label: t
1529
+ })),
1530
+ selectedSubtitleTrack: k.selectedId ?? void 0,
1531
+ selectSubtitleTrack: (e) => k.select(e == null ? null : String(e))
1532
+ });
1533
+ }, [D, k]), o(() => {
1534
+ A && D({
1535
+ audioTracks: A.options.map(({ id: e, label: t }) => ({
1536
+ id: e,
1537
+ label: t
1538
+ })),
1539
+ selectedAudioTrack: A.selectedId ?? void 0,
1540
+ selectAudioTrack: (e) => A.select(String(e))
1541
+ });
1542
+ }, [D, A]), /* @__PURE__ */ v(Oe, {
1543
+ ref: _,
1544
+ onVideoRef: n ? void 0 : b,
1545
+ onCanvasRef: S,
1546
+ overlay: e.overlay,
1512
1547
  children: t
1513
1548
  });
1514
- }, Q = u`
1549
+ }, ke = u`
1550
+ /**
1551
+ * The chrome's whole scale, in one place.
1552
+ *
1553
+ * Everything inside is sized against this rather than against \`rem\`, because \`rem\` is root
1554
+ * relative and a library cannot own the host page's root font. The old contract was that the host
1555
+ * set \`html { font-size: 62.5% }\`, which silently rendered every control 1.6x too large in any app
1556
+ * that did not, and could not be met by an app whose own screens are sized against the default.
1557
+ * Override it on the player element to rescale the whole chrome.
1558
+ */
1559
+ --mp-unit: 10px;
1560
+
1515
1561
  display: flex;
1516
1562
  justify-content: center;
1517
1563
  background-color: #111;
@@ -1519,16 +1565,16 @@ position: relative;
1519
1565
  width: 100%;
1520
1566
  overflow: hidden;
1521
1567
  `, $ = (e) => /* @__PURE__ */ v("div", {
1522
- css: Q,
1523
- children: /* @__PURE__ */ v(M.Provider, { children: /* @__PURE__ */ v(ke, {
1568
+ css: ke,
1569
+ children: /* @__PURE__ */ v(N.Provider, { children: /* @__PURE__ */ v(Q, {
1524
1570
  options: e,
1525
1571
  children: e.children
1526
1572
  }) })
1527
- }), Ae = ({ blob: e, name: t }) => ({
1573
+ }), Ae = (e) => !!e && typeof e == "object" && "at" in e, je = (e) => !!e && typeof e == "object" && "selection" in e, Me = ({ blob: e, name: t }) => ({
1528
1574
  length: e.size,
1529
1575
  name: t ?? (e instanceof File ? e.name : void 0),
1530
1576
  read: (t, n) => e.slice(t, t + n).arrayBuffer()
1531
- }), je = async (e, t) => {
1577
+ }), Ne = async (e, t) => {
1532
1578
  let n = await fetch(e, {
1533
1579
  headers: { Range: "bytes=0-1" },
1534
1580
  credentials: t
@@ -1538,8 +1584,8 @@ position: relative;
1538
1584
  if (!Number.isFinite(i) || i <= 0) throw Error("The source did not report its length");
1539
1585
  if (!r && n.status !== 206) throw Error("The source does not support range requests");
1540
1586
  return i;
1541
- }, Me = async ({ url: e, length: t, name: n, credentials: r }) => {
1542
- let i = t ?? await je(e, r);
1587
+ }, Pe = async ({ url: e, length: t, name: n, credentials: r }) => {
1588
+ let i = t ?? await Ne(e, r);
1543
1589
  return {
1544
1590
  length: i,
1545
1591
  name: n,
@@ -1552,9 +1598,9 @@ position: relative;
1552
1598
  return a.arrayBuffer();
1553
1599
  }
1554
1600
  };
1555
- }, Ne = async (e) => {
1556
- if ("blob" in e) return Ae(e);
1557
- if ("url" in e) return Me(e);
1601
+ }, Fe = async (e) => {
1602
+ if ("blob" in e) return Me(e);
1603
+ if ("url" in e) return Pe(e);
1558
1604
  if ("read" in e) return {
1559
1605
  length: e.length,
1560
1606
  name: e.name,
@@ -1563,4 +1609,4 @@ position: relative;
1563
1609
  throw Error(`Unknown source type: ${e}`);
1564
1610
  };
1565
1611
  //#endregion
1566
- export { $ as MediaPlayer, $ as default, M as Player, n as SUBTITLES_OFF, i as createPictureInPicture, r as createSubtitleRenderer, t as createThumbnailGenerator, Ne as inputToRemuxerInput, j as sourceFeature, e as startPlayback, F as usePictureInPicture, N as usePlayer, P as useSeekThumbnails };
1612
+ export { $ as MediaPlayer, $ as default, N as Player, n as SUBTITLES_OFF, i as createPictureInPicture, r as createSubtitleRenderer, t as createThumbnailGenerator, Fe as inputToRemuxerInput, je as isDelegatedTracks, Ae as isExternalThumbnails, M as sourceFeature, e as startPlayback, B as usePictureInPicture, P as usePlayer, z as useSeekThumbnails };