@banou/media-player 0.9.0 → 0.10.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
@@ -1,4 +1,4 @@
1
- import { l as e, n as t, o as n, r, s as i, t as a, u as o } from "./engine-DZrYu66u.js";
1
+ import { l as e, n as t, o as n, r, s as i, t as a, u as o } from "./engine-b5_5HscR.js";
2
2
  import { Children as s, Fragment as c, isValidElement as l, useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
3
3
  import { css as h, keyframes as g } from "@emotion/react";
4
4
  import { createPlayer as _, useContainerAttach as v, useMediaAttach as y } from "@videojs/react";
@@ -7,9 +7,11 @@ import { Fragment as S, jsx as C, jsxs as w } from "@emotion/react/jsx-runtime";
7
7
  import { AlertTriangle as T, Check as E, ChevronLeft as D, ChevronRight as O, Copy as k, Maximize as A, Minimize as j, Pause as M, Play as N, RotateCcw as P, Settings as F, Volume1 as I, Volume2 as L, VolumeX as R } from "react-feather";
8
8
  import { Tooltip as z } from "react-tooltip";
9
9
  //#region src/lib/react/source-feature.ts
10
- var ee = {
10
+ var B = {
11
11
  indexes: [],
12
+ chapters: [],
12
13
  thumbnails: [],
14
+ requestThumbnail: () => {},
13
15
  subtitleTracks: [],
14
16
  selectedSubtitleTrack: void 0,
15
17
  selectSubtitleTrack: () => {},
@@ -25,19 +27,19 @@ var ee = {
25
27
  playbackErrors: [],
26
28
  ready: !1,
27
29
  setSourceState: () => {}
28
- }, te = b({
30
+ }, V = b({
29
31
  name: "source",
30
- state: () => ({ ...ee }),
32
+ state: () => ({ ...B }),
31
33
  attach({ set: e }) {
32
34
  e({
33
35
  setSourceState: (t) => e(t),
34
36
  setHideUI: (t) => e({ hideUI: t })
35
37
  });
36
38
  }
37
- }), B = _({
38
- features: [...x, te],
39
+ }), H = _({
40
+ features: [...x, V],
39
41
  displayName: "MediaPlayer"
40
- }), V = B.usePlayer, ne = (e) => {
42
+ }), U = H.usePlayer, W = (e) => {
41
43
  if (!(!e || e === "und")) try {
42
44
  return new Intl.DisplayNames([navigator.language || "en"], {
43
45
  type: "language",
@@ -46,60 +48,62 @@ var ee = {
46
48
  } catch {
47
49
  return;
48
50
  }
49
- }, re = (e) => e?.replace(/_/g, " ").trim() || void 0, ie = (e) => {
50
- let t = e.map((e) => ne(e.language) ?? re(e.title) ?? `Track ${e.streamIndex}`), n = t.reduce((e, t) => ({
51
+ }, G = (e) => e?.replace(/_/g, " ").trim() || void 0, ee = (e) => {
52
+ let t = e.map((e) => W(e.language) ?? G(e.title) ?? `Track ${e.streamIndex}`), n = t.reduce((e, t) => ({
51
53
  ...e,
52
54
  [t]: (e[t] ?? 0) + 1
53
55
  }), {});
54
56
  return e.map((e, r) => {
55
- let i = t[r], a = re(e.title);
57
+ let i = t[r], a = G(e.title);
56
58
  return {
57
59
  track: e,
58
60
  label: (n[i] ?? 0) > 1 && a && a !== i ? `${i} (${a})` : i
59
61
  };
60
62
  });
61
- }, ae = (e) => ie(e).map(({ track: e, label: t }) => ({
63
+ }, te = (e) => ee(e).map(({ track: e, label: t }) => ({
62
64
  id: e.streamIndex,
63
65
  label: t
64
- })), oe = [
66
+ })), ne = [
65
67
  0,
66
68
  250,
67
69
  1e3,
68
70
  3e3,
69
71
  1e4
70
- ], se = 6e4, ce = 500, le = (e) => e instanceof Error ? e.message : String(e), ue = (e) => {
72
+ ], re = 6e4, ie = 500, ae = (e) => e instanceof Error ? e.message : String(e), oe = (e) => {
71
73
  let t = [], n = e?.cause;
72
74
  for (let e = 0; n != null && e < 8; e++) {
73
75
  if (typeof MediaError < "u" && n instanceof MediaError) {
74
76
  t.push(`MediaError code ${n.code}${n.message ? `: ${n.message}` : ""}`);
75
77
  break;
76
78
  }
77
- t.push(le(n)), n = n?.cause;
79
+ t.push(ae(n)), n = n?.cause;
78
80
  }
79
81
  return t.length ? t.join("\n") : void 0;
80
- }, de = (e, t, r) => {
81
- let a = V(), { read: o, size: s, publicPath: c = "", libavWorkerUrl: l = "", jassubWorkerUrl: f = "", jassubWasmUrl: h = "", jassubLegacyWasmUrl: g, defaultFontUrl: _, bufferSize: v, autoplay: y = !1, seekPrepareBudgetMs: b = ce } = r ?? {}, [x, S] = m(void 0), [C, w] = m(0), T = p({
82
+ }, se = (e, t, r) => {
83
+ let a = U(), { read: o, size: s, publicPath: c = "", libavWorkerUrl: l = "", jassubWorkerUrl: f = "", jassubWasmUrl: h = "", jassubLegacyWasmUrl: g, defaultFontUrl: _, bufferSize: v, autoplay: y = !1, chapters: b, seekPrepareBudgetMs: x = ie } = r ?? {}, S = p(b);
84
+ S.current = b;
85
+ let [C, w] = m(void 0), [T, E] = m(0), D = p({
82
86
  count: 0,
83
87
  at: 0
84
- }), E = p(void 0);
85
- d(() => (T.current = {
88
+ }), O = p(void 0);
89
+ d(() => (D.current = {
86
90
  count: 0,
87
91
  at: 0
88
92
  }, a.setSourceState({ playbackErrors: [] }), () => {
89
- E.current && clearTimeout(E.current);
93
+ O.current && clearTimeout(O.current);
90
94
  }), [s]);
91
- let D = p(null), O = p(null), k = p(!1), A = p(o);
92
- A.current = o;
93
- let j = p(r?.onSeek);
94
- j.current = r?.onSeek;
95
- let M = p(r?.onPlaybackError);
96
- M.current = r?.onPlaybackError;
97
- let N = u((e) => {
95
+ let k = p(null), A = p(null), j = p(!1), M = p(o);
96
+ M.current = o;
97
+ let N = p(r?.onSeek);
98
+ N.current = r?.onSeek;
99
+ let P = p(r?.onPlaybackError);
100
+ P.current = r?.onPlaybackError;
101
+ let F = u((e) => {
98
102
  let t = typeof e == "number" ? e : void 0;
99
- k.current = !0, a.setSourceState({ selectedSubtitleTrack: t }), D.current?.selectSubtitleStream(t);
100
- }, [a]), P = u((e) => {
101
- let t = D.current;
102
- if (!t || b <= 0) {
103
+ j.current = !0, a.setSourceState({ selectedSubtitleTrack: t }), k.current?.selectSubtitleStream(t);
104
+ }, [a]), I = u((e) => {
105
+ let t = k.current;
106
+ if (!t || x <= 0) {
103
107
  a.seek(e);
104
108
  return;
105
109
  }
@@ -111,24 +115,24 @@ var ee = {
111
115
  }
112
116
  }, c = setTimeout(() => {
113
117
  o = "deadline", s();
114
- }, b);
118
+ }, x);
115
119
  t.prepareSeek(e).catch(() => {}).finally(() => {
116
120
  clearTimeout(c), s();
117
121
  });
118
- }, [a, b]), F = u((e) => {
119
- typeof e == "number" && (a.setSourceState({ selectedAudioTrack: e }), S(e));
120
- }, [a]), I = V((e) => e.setSourceState);
122
+ }, [a, x]), L = u((e) => {
123
+ typeof e == "number" && (a.setSourceState({ selectedAudioTrack: e }), w(e));
124
+ }, [a]), R = U((e) => e.setSourceState);
121
125
  d(() => {
122
- I({
123
- selectSubtitleTrack: N,
124
- selectAudioTrack: F,
125
- requestSeek: P
126
+ R({
127
+ selectSubtitleTrack: F,
128
+ selectAudioTrack: L,
129
+ requestSeek: I
126
130
  });
127
131
  }, [
128
- I,
129
- N,
132
+ R,
130
133
  F,
131
- P
134
+ L,
135
+ I
132
136
  ]), d(() => {
133
137
  if (!e || !t || !s || !o) return;
134
138
  let r = !1;
@@ -137,7 +141,7 @@ var ee = {
137
141
  ready: !1
138
142
  });
139
143
  let u = (t, n) => {
140
- let r = Date.now(), i = le(t), o = ue(t), s = a.playbackErrors, c = s[s.length - 1];
144
+ let r = Date.now(), i = ae(t), o = oe(t), s = a.playbackErrors, c = s[s.length - 1];
141
145
  if (c && c.message === i && c.detail === o && c.recovered === n) {
142
146
  let e = {
143
147
  ...c,
@@ -162,25 +166,25 @@ var ee = {
162
166
  let t = n(e);
163
167
  if (u(e, t), t) {
164
168
  let t = performance.now();
165
- t - T.current.at > se && (T.current = {
169
+ t - D.current.at > re && (D.current = {
166
170
  count: 0,
167
171
  at: t
168
172
  });
169
- let n = oe[Math.min(T.current.count, oe.length - 1)];
170
- T.current = {
171
- count: T.current.count + 1,
173
+ let n = ne[Math.min(D.current.count, ne.length - 1)];
174
+ D.current = {
175
+ count: D.current.count + 1,
172
176
  at: t
173
- }, console.warn(`the media element failed; rebuilding the pipeline${n ? ` in ${n}ms` : ""}`, e), E.current && clearTimeout(E.current), E.current = setTimeout(() => w((e) => e + 1), n);
177
+ }, console.warn(`the media element failed; rebuilding the pipeline${n ? ` in ${n}ms` : ""}`, e), O.current && clearTimeout(O.current), O.current = setTimeout(() => E((e) => e + 1), n);
174
178
  return;
175
179
  }
176
- console.error("playback failed", e), a.setSourceState({ playbackError: e }), M.current?.(e);
180
+ console.error("playback failed", e), a.setSourceState({ playbackError: e }), P.current?.(e);
177
181
  };
178
182
  return (async () => {
179
183
  try {
180
184
  let n = await i({
181
185
  videoElement: e,
182
186
  subtitleContainer: t,
183
- read: (e, t) => A.current(e, t),
187
+ read: (e, t) => M.current(e, t),
184
188
  length: s,
185
189
  publicPath: c,
186
190
  libavWorkerUrl: l,
@@ -189,27 +193,27 @@ var ee = {
189
193
  jassubLegacyWasmUrl: g,
190
194
  defaultFontUrl: _,
191
195
  bufferSize: v,
192
- audioStreamIndex: x,
196
+ audioStreamIndex: C,
193
197
  onReady: () => {
194
198
  if (r) return;
195
199
  a.setSourceState({ ready: !0 });
196
- let t = O.current;
197
- O.current = null, t && t.size === s && t.time > 0 && (e.currentTime = t.time), y && e.play().catch(() => {});
200
+ let t = A.current;
201
+ A.current = null, t && t.size === s && t.time > 0 && (e.currentTime = t.time), y && e.play().catch(() => {});
198
202
  },
199
203
  onError: d,
200
204
  onRecovered: () => {
201
205
  r || a.setSourceState({ playbackError: null });
202
206
  },
203
- onSeek: (e) => j.current?.(e),
207
+ onSeek: (e) => N.current?.(e),
204
208
  onSubtitleStreams: (e) => {
205
209
  r || a.setSourceState({
206
- subtitleTracks: ae(e),
207
- ...k.current ? {} : { selectedSubtitleTrack: e[0]?.streamIndex }
210
+ subtitleTracks: te(e),
211
+ ...j.current ? {} : { selectedSubtitleTrack: e[0]?.streamIndex }
208
212
  });
209
213
  },
210
214
  onAudioStreams: (e, t) => {
211
215
  r || a.setSourceState({
212
- audioTracks: ae(e),
216
+ audioTracks: te(e),
213
217
  selectedAudioTrack: t
214
218
  });
215
219
  }
@@ -218,17 +222,20 @@ var ee = {
218
222
  n.destroy();
219
223
  return;
220
224
  }
221
- D.current = n, a.setSourceState({ indexes: n.indexes });
225
+ k.current = n, a.setSourceState({
226
+ indexes: n.indexes,
227
+ chapters: S.current ?? n.chapters
228
+ });
222
229
  let o = a.selectedSubtitleTrack;
223
230
  typeof o == "number" && n.selectSubtitleStream(o);
224
231
  } catch (e) {
225
232
  d(e);
226
233
  }
227
234
  })(), () => {
228
- r = !0, O.current = {
235
+ r = !0, A.current = {
229
236
  time: e.currentTime,
230
237
  size: s
231
- }, D.current?.destroy(), D.current = null, a.setSourceState({ ready: !1 });
238
+ }, k.current?.destroy(), k.current = null, a.setSourceState({ ready: !1 });
232
239
  };
233
240
  }, [
234
241
  a,
@@ -242,17 +249,17 @@ var ee = {
242
249
  g,
243
250
  _,
244
251
  v,
245
- x,
252
+ C,
246
253
  y,
247
- C
254
+ T
248
255
  ]);
249
- }, fe = 5e3, pe = 6e4, me = ({ publicPath: e, workerUrl: t, length: n, read: i, downloadedRanges: a }) => {
256
+ }, ce = 5e3, le = 6e4, ue = ({ publicPath: e, workerUrl: t, length: n, read: i, downloadedRanges: a }) => {
250
257
  let [o, s] = m([]), c = p(null), l = p(i);
251
258
  l.current = i;
252
- let u = f(() => a?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [a?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")]), h = p(u);
253
- return h.current = u, d(() => {
259
+ let h = f(() => a?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [a?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")]), g = p(h);
260
+ return g.current = h, d(() => {
254
261
  if (!n || !i || !e || !t) return;
255
- let a = !1, o = null, u, d = fe, f = () => {
262
+ let a = !1, o = null, u, d = ce, f = () => {
256
263
  r({
257
264
  publicPath: e,
258
265
  workerUrl: t,
@@ -266,9 +273,9 @@ var ee = {
266
273
  e.destroy();
267
274
  return;
268
275
  }
269
- o = e, c.current = e, e.update(h.current);
276
+ o = e, c.current = e, e.update(g.current);
270
277
  }, () => {
271
- a || (u = setTimeout(f, d), d = Math.min(d * 2, pe));
278
+ a || (u = setTimeout(f, d), d = Math.min(d * 2, le));
272
279
  });
273
280
  };
274
281
  return f(), () => {
@@ -279,9 +286,14 @@ var ee = {
279
286
  e,
280
287
  t
281
288
  ]), d(() => {
282
- c.current?.update(u);
283
- }, [u]), o;
284
- }, he = (e, n) => {
289
+ c.current?.update(h);
290
+ }, [h]), {
291
+ thumbnails: o,
292
+ requestThumbnail: u((e) => {
293
+ c.current?.prioritize(e);
294
+ }, [])
295
+ };
296
+ }, de = (e, n) => {
285
297
  let r = p(null), [i, o] = m(!1), [s] = m(() => t());
286
298
  d(() => {
287
299
  if (!e || !n || !s) return;
@@ -309,7 +321,7 @@ var ee = {
309
321
  mode: s,
310
322
  burnedIn: i
311
323
  };
312
- }, H = {
324
+ }, K = {
313
325
  headings: {
314
326
  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 ",
315
327
  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 ",
@@ -336,7 +348,7 @@ var ee = {
336
348
  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 ",
337
349
  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 "
338
350
  }
339
- }, ge = h`
351
+ }, fe = h`
340
352
  display: flex;
341
353
  justify-content: center;
342
354
  align-items: center;
@@ -349,7 +361,7 @@ var ee = {
349
361
  margin: auto;
350
362
  pointer-events: none;
351
363
  }
352
- `, _e = h`
364
+ `, pe = h`
353
365
  position: absolute;
354
366
  top: 0;
355
367
  left: 0;
@@ -357,7 +369,7 @@ var ee = {
357
369
  padding: calc(1.2 * var(--mp-unit)) calc(1.6 * var(--mp-unit));
358
370
  /* clears a notch once the player is fullscreen; resolves to zero everywhere else */
359
371
  padding-top: calc(calc(1.2 * var(--mp-unit)) + env(safe-area-inset-top, 0px));
360
- ${H.headings.small}
372
+ ${K.headings.small}
361
373
  color: white;
362
374
  text-shadow: 0 0 4px rgba(0, 0, 0, 1);
363
375
  z-index: 2;
@@ -378,7 +390,7 @@ var ee = {
378
390
 
379
391
  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%);
380
392
  transition: opacity 0.1s cubic-bezier(.4,0,1,1);
381
- `, ve = h`
393
+ `, me = h`
382
394
  position: absolute;
383
395
  inset: 0;
384
396
  z-index: 2;
@@ -398,44 +410,44 @@ var ee = {
398
410
  to { transform: rotate(360deg); }
399
411
  `} 0.8s linear infinite;
400
412
  }
401
- `, ye = h`
413
+ `, he = h`
402
414
  position: absolute;
403
415
  inset: auto 0 20%;
404
416
  z-index: 3;
405
417
  padding: 0 calc(2 * var(--mp-unit));
406
418
  text-align: center;
407
419
  color: #fff;
408
- ${H.bLarge.regular}
420
+ ${K.bLarge.regular}
409
421
  text-shadow: 0 0 4px rgba(0, 0, 0, 1);
410
422
  pointer-events: none;
411
- `, be = (e) => e instanceof Error ? e.message : typeof e == "string" ? e : "Playback failed", xe = ({ onSubtitleRef: e }) => {
412
- let t = V((e) => e.title), n = V((e) => e.hideUI), r = V((e) => e.playbackError), i = V((e) => e.ready), a = V((e) => e.size), o = V((e) => e.waiting);
423
+ `, ge = (e) => e instanceof Error ? e.message : typeof e == "string" ? e : "Playback failed", _e = ({ onSubtitleRef: e }) => {
424
+ let t = U((e) => e.title), n = U((e) => e.hideUI), r = U((e) => e.playbackError), i = U((e) => e.ready), a = U((e) => e.size), o = U((e) => e.waiting);
413
425
  return /* @__PURE__ */ w(S, { children: [
414
426
  t ? /* @__PURE__ */ C("div", {
415
427
  className: "title",
416
- css: _e,
428
+ css: pe,
417
429
  style: { ...n ? {
418
430
  opacity: "0",
419
431
  pointerEvents: "none"
420
432
  } : {} },
421
433
  children: t
422
434
  }) : void 0,
423
- (a ? !i : o) && !r ? /* @__PURE__ */ C("div", { css: ve }) : void 0,
435
+ (a ? !i : o) && !r ? /* @__PURE__ */ C("div", { css: me }) : void 0,
424
436
  r ? /* @__PURE__ */ C("div", {
425
- css: ye,
426
- children: be(r)
437
+ css: he,
438
+ children: ge(r)
427
439
  }) : void 0,
428
440
  /* @__PURE__ */ C("div", {
429
441
  className: "subtitles",
430
442
  ref: e,
431
- css: ge
443
+ css: fe
432
444
  })
433
445
  ] });
434
- }, Se = 1e-4, U = 1, Ce = (e) => Math.max(Se, Math.min(U, e)) ** 2, W = (e) => Math.max(Se, Math.min(U, e)) ** (U / 2), G = (e) => {
446
+ }, ve = 1e-4, q = 1, ye = (e) => Math.max(ve, Math.min(q, e)) ** 2, J = (e) => Math.max(ve, Math.min(q, e)) ** (q / 2), Y = (e) => {
435
447
  if (e === void 0) return "0:00";
436
448
  let t = Math.floor(e / 3600), n = Math.floor(e % 3600 / 60), r = Math.floor(e % 60);
437
449
  return t > 0 ? `${t}:${n < 10 ? "0" : ""}${n}:${r < 10 ? "0" : ""}${r}` : `${n}:${r < 10 ? "0" : ""}${r}`;
438
- }, we = (e, t) => `${G(e)} / ${G(t)}`, Te = (e) => h`
450
+ }, be = (e, t) => `${Y(e)} / ${Y(t)}`, xe = (e) => h`
439
451
  display: flex;
440
452
  justify-content: flex-start;
441
453
 
@@ -467,7 +479,7 @@ var ee = {
467
479
  z-index: 3;
468
480
 
469
481
  * {
470
- ${H.bMedium.regular}
482
+ ${K.bMedium.regular}
471
483
  }
472
484
 
473
485
  ${e === "sm" && h`
@@ -479,25 +491,25 @@ var ee = {
479
491
  ${e === "lg" && h`
480
492
  padding: calc(1.2 * var(--mp-unit))!important;
481
493
  `}
482
- `, K = {
494
+ `, X = {
483
495
  x: -1,
484
496
  y: -1,
485
497
  anchors: 0
486
- }, Ee = (e) => {
487
- K.x = e.clientX, K.y = e.clientY;
488
- }, De = () => (K.anchors++ === 0 && window.addEventListener("pointermove", Ee, {
498
+ }, Se = (e) => {
499
+ X.x = e.clientX, X.y = e.clientY;
500
+ }, Ce = () => (X.anchors++ === 0 && window.addEventListener("pointermove", Se, {
489
501
  capture: !0,
490
502
  passive: !0
491
503
  }), () => {
492
- --K.anchors === 0 && window.removeEventListener("pointermove", Ee, { capture: !0 });
493
- }), 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" }) => {
504
+ --X.anchors === 0 && window.removeEventListener("pointermove", Se, { capture: !0 });
505
+ }), Z = ({ id: e, toolTipText: t, text: n, delayShow: r = 0, closeDelay: i = 0, offset: a = 20, tooltipPlace: o = "top", disabled: s = !1, size: c = "md" }) => {
494
506
  let l = p(null), u = p(null);
495
507
  return d(() => {
496
- let e = De(), t = () => {
508
+ let e = Ce(), t = () => {
497
509
  let e = l.current;
498
510
  if (!e) return;
499
511
  let { left: t, right: n, top: r, bottom: i } = e.getBoundingClientRect();
500
- K.x >= t && K.x < n && K.y >= r && K.y < i || u.current?.close();
512
+ X.x >= t && X.x < n && X.y >= r && X.y < i || u.current?.close();
501
513
  }, n = ["fullscreenchange", "webkitfullscreenchange"];
502
514
  for (let e of n) document.addEventListener(e, t);
503
515
  return () => {
@@ -515,12 +527,12 @@ var ee = {
515
527
  children: n
516
528
  }), !s && /* @__PURE__ */ C(z, {
517
529
  ref: u,
518
- css: Te(c),
530
+ css: xe(c),
519
531
  id: e,
520
532
  noArrow: !0,
521
533
  children: t
522
534
  })] });
523
- }, J = ({ ref: e, onChange: t, orientation: n = "horizontal", disabled: r = !1 }) => {
535
+ }, we = ({ ref: e, onChange: t, orientation: n = "horizontal", disabled: r = !1 }) => {
524
536
  let [i, a] = m(!1), o = p(t);
525
537
  o.current = t;
526
538
  let s = p(null), c = u((t, r) => {
@@ -559,7 +571,118 @@ var ee = {
559
571
  style: { touchAction: "none" }
560
572
  }
561
573
  };
562
- }, Oe = h`
574
+ }, Te = 2, Ee = .005, De = "#000", Oe = "#0000", ke = (e, t) => {
575
+ if (!t) return [];
576
+ let n = /* @__PURE__ */ new Set();
577
+ for (let { start: r, end: i } of e) for (let e of [r, i]) {
578
+ let r = e / t;
579
+ r <= Ee || r >= 1 - Ee || n.add(Number((r * 100).toFixed(4)));
580
+ }
581
+ return n.size ? [
582
+ 0,
583
+ ...[...n].sort((e, t) => e - t),
584
+ 100
585
+ ] : [];
586
+ }, Ae = (e, t) => {
587
+ let n = Te / 2, r = e.length - 2, i = [];
588
+ for (let a = 0; a <= r; a += 1) {
589
+ let o = e[a], s = e[a + 1], c = a === 0 ? "0%" : `calc(${o}% + ${n}px)`, l = a === r ? "100%" : `calc(${s}% - ${n}px)`;
590
+ i.push(`${t(a) ? De : Oe} ${c} ${l}`), a !== r && i.push(`${Oe} calc(${s}% - ${n}px) calc(${s}% + ${n}px)`);
591
+ }
592
+ return `linear-gradient(90deg, ${i.join(", ")})`;
593
+ }, je = /* @__PURE__ */ new Set([
594
+ "op",
595
+ "ops",
596
+ "opening",
597
+ "openings",
598
+ "ncop",
599
+ "オープニング",
600
+ "op主題歌"
601
+ ]), Me = /* @__PURE__ */ new Set([
602
+ "ed",
603
+ "eds",
604
+ "ending",
605
+ "endings",
606
+ "nced",
607
+ "credits",
608
+ "endcard",
609
+ "endroll",
610
+ "エンディング",
611
+ "エンドカード",
612
+ "エンドロール",
613
+ "ed主題歌"
614
+ ]), Ne = /* @__PURE__ */ new Set(["intro", "イントロ"]), Pe = /* @__PURE__ */ new Set(["outro", "アウトロ"]), Fe = {
615
+ "credits start": "ending",
616
+ "credits end": null,
617
+ "preview end": null,
618
+ "end credits": "ending",
619
+ "closing credits": "ending"
620
+ }, Ie = /* @__PURE__ */ new Set([
621
+ "theme",
622
+ "themes",
623
+ "song",
624
+ "sequence",
625
+ "nc",
626
+ "non",
627
+ "credit",
628
+ "creditless",
629
+ "textless",
630
+ "clean",
631
+ "tv",
632
+ "size",
633
+ "version",
634
+ "ver",
635
+ "full",
636
+ "the",
637
+ "主題歌",
638
+ "ノンクレジット"
639
+ ]), Le = /* @__PURE__ */ new Set([
640
+ "post",
641
+ "pre",
642
+ "after",
643
+ "before",
644
+ "non"
645
+ ]), Re = /[-:|~/\\[\]()「」『』【】,.!?"'’]|\s+by\s+/u, ze = (e) => /^chapter\s*\d+$/i.test(e.trim()) || /^\d{1,2}:\d{2}:\d{2}([.,]\d+)?$/.test(e.trim()), Be = (e) => e.replace(/([a-z぀-ヿ一-鿿])\s*\d+\s*$/u, "$1").split(/[\s_]+/u).map((e) => e.replace(/^[^\w぀-ヿ一-鿿]+|[^\w぀-ヿ一-鿿]+$/gu, "")).filter((e) => e && !/^\d+$/.test(e) && !Ie.has(e)), Ve = (e, t) => {
646
+ if (je.has(e)) return "opening";
647
+ if (Me.has(e)) return "ending";
648
+ if (t) {
649
+ if (Ne.has(e)) return "opening";
650
+ if (Pe.has(e)) return "ending";
651
+ }
652
+ }, He = (e, t) => {
653
+ if (ze(e)) return;
654
+ let n = e.trim().toLowerCase().replace(/\s+/gu, " ");
655
+ if (n in Fe) return Fe[n] ?? void 0;
656
+ let r = n.split(Re).map((e) => e.trim()).filter(Boolean);
657
+ if (r.some((e) => e.split(/[\s_]+/u).some((e) => Le.has(e)))) return;
658
+ let i = r.length > 1 ? [r[0], r.at(-1)] : r;
659
+ for (let e of i) {
660
+ let n = Be(e);
661
+ if (n.length !== 1) continue;
662
+ let r = Ve(n[0], t);
663
+ if (r) return r;
664
+ }
665
+ }, Ue = 15, We = 87, Ge = 93, Ke = (e) => {
666
+ let t = e.map(() => void 0), n = e.at(-1)?.end ?? 0;
667
+ if (!n) return t;
668
+ let r = e.map((e, t) => ({
669
+ index: t,
670
+ start: e.start,
671
+ length: e.end - e.start
672
+ })).filter(({ length: e }) => e >= We && e <= Ge), i = n / 2, a = r.filter(({ start: e }) => e < i), o = r.filter(({ start: e }) => e >= i);
673
+ return a.length === 1 && (t[a[0].index] = "opening"), o.length === 1 && (t[o[0].index] = "ending"), t;
674
+ }, qe = (e) => {
675
+ let t = e.map(({ title: e }) => He(e, !1)), n = e.reduce((e, n, r) => e + (t[r] ? n.end - n.start : 0), 0), r = e.reduce((e, t) => e + (t.end - t.start), 0);
676
+ if (r > 0 && n * 2 > r) return e.map(() => void 0);
677
+ let i = e.map((e, n) => {
678
+ if (e.end - e.start < Ue) return;
679
+ let r = t[n];
680
+ if (r) return r;
681
+ let i = He(e.title, !0);
682
+ return i && !t.includes(i) ? i : void 0;
683
+ });
684
+ return i.some(Boolean) ? i : Ke(e);
685
+ }, Je = h`
563
686
  position: relative;
564
687
  height: calc(.4 * var(--mp-unit));
565
688
 
@@ -592,6 +715,37 @@ var ee = {
592
715
  }
593
716
  }
594
717
 
718
+ /*
719
+ * One copy of the track per mask, stacked.
720
+ *
721
+ * The rest track paints every segment except the one under the pointer, the focus track paints only that one and
722
+ * is the only element that grows. Both are full bar width, which is what keeps every percentage
723
+ * and every scaleX inside them meaning exactly what it meant before chapters existed: the gaps are
724
+ * cut by a mask, not by resizing anything.
725
+ *
726
+ * The mask sits HERE and never on .loaded-part or .play. Those two carry a scaleX, and a mask
727
+ * travels with its element's transform, so a gap drawn on them would slide with the fill.
728
+ */
729
+ .track {
730
+ position: absolute;
731
+ inset: 0;
732
+ /* never a hit target: .padding is the only one, and a second would break the drag gesture and
733
+ fire a bubbling mouseout at every boundary crossing */
734
+ pointer-events: none;
735
+ }
736
+
737
+ /*
738
+ * The segment under the pointer, on TOP of the growth the whole bar already got.
739
+ *
740
+ * Measured off YouTube's live player, hovering one chapter of five: every other segment goes 4px
741
+ * to 6px, and the one under the pointer goes to 10px. Both grow about the bar's centre line, so
742
+ * the emphasised segment bulges above and below its neighbours rather than sitting on them. 6 x
743
+ * 1.667 is 10, and the 1.5 the layers inside already carry gets this track from 4 to exactly that.
744
+ */
745
+ .track.focus {
746
+ transform: scaleY(1.667);
747
+ }
748
+
595
749
 
596
750
  .background-bar {
597
751
  position: absolute;
@@ -613,7 +767,24 @@ var ee = {
613
767
  box-shadow: 0 0 calc(1 * var(--mp-unit)) rgba(0, 0, 0, .5);
614
768
 
615
769
  text-shadow: 0 0 4px rgba(0, 0, 0, 1);
616
- ${H.bMedium.bold}
770
+ ${K.bMedium.bold}
771
+
772
+ gap: calc(.6 * var(--mp-unit));
773
+
774
+ /*
775
+ * The chapter under the pointer, next to the time, which is where the reference puts it.
776
+ *
777
+ * It is the one part of this pill whose width the player does not control, so it is capped and
778
+ * ellipsised rather than allowed to push the box outside the picture. The cap and the clamp that
779
+ * positions the pill are set together on the element, since a centred box can only be kept
780
+ * inside the bar if the clamp knows its half width.
781
+ */
782
+ .chapter-title {
783
+ overflow: hidden;
784
+ text-overflow: ellipsis;
785
+ min-width: 0;
786
+ font-weight: normal;
787
+ }
617
788
 
618
789
  position: absolute;
619
790
  /* Anchored on its bottom edge rather than its top: now that it has a background its height
@@ -730,36 +901,38 @@ var ee = {
730
901
  --thumbnail-width: calc(18 * var(--mp-unit));
731
902
  --thumbnail-half: calc(9 * var(--mp-unit));
732
903
  }
733
- `, ke = 4, Ae = () => {
734
- let e = V(), t = V((e) => e.currentTime), n = V((e) => e.requestSeek), r = V((e) => e.duration), i = V((e) => e.size), a = V((e) => e.downloadedRanges), o = V((e) => e.indexes), s = V((e) => e.thumbnails), c = V((e) => e.thumbnailAt), l = p(null), [u, h] = m(void 0), [g, _] = m(void 0), v = p(void 0), y = p(0), b = p(void 0), x = p(void 0), S = p(!1), { dragging: T, handlers: E } = J({
735
- ref: l,
904
+ `, Ye = 4, Xe = () => {
905
+ let e = U(), t = U((e) => e.currentTime), n = U((e) => e.requestSeek), r = U((e) => e.duration), i = U((e) => e.size), a = U((e) => e.downloadedRanges), o = U((e) => e.indexes), s = U((e) => e.thumbnails), c = U((e) => e.thumbnailAt), l = U((e) => e.requestThumbnail), u = U((e) => e.chapters), h = p(null), [g, _] = m(void 0), [v, y] = m(void 0), b = (e) => {
906
+ y(e), l(e);
907
+ }, x = p(void 0), S = p(0), T = p(void 0), E = p(void 0), D = p(!1), { dragging: O, handlers: k } = we({
908
+ ref: h,
736
909
  onChange: (e) => {
737
- if (y.current += 1, b.current = e, x.current === void 0) x.current = e;
738
- else if (!S.current) {
739
- let t = l.current?.getBoundingClientRect().width ?? 0;
740
- Math.abs(e - x.current) * t > ke && (S.current = !0);
910
+ if (S.current += 1, T.current = e, E.current === void 0) E.current = e;
911
+ else if (!D.current) {
912
+ let t = h.current?.getBoundingClientRect().width ?? 0;
913
+ Math.abs(e - E.current) * t > Ye && (D.current = !0);
741
914
  }
742
- h(e), v.current !== "mouse" && _(e * r);
915
+ _(e), x.current !== "mouse" && b(e * r);
743
916
  }
744
- }), D = (e) => {
745
- v.current = e.pointerType, y.current = 0, x.current = void 0, S.current = !1, E.onPointerDown(e);
746
- }, O = (t) => {
747
- E.onPointerUp(t);
748
- let i = y.current > 0 ? b.current : void 0;
917
+ }), A = (e) => {
918
+ x.current = e.pointerType, S.current = 0, E.current = void 0, D.current = !1, k.onPointerDown(e);
919
+ }, j = (t) => {
920
+ k.onPointerUp(t);
921
+ let i = S.current > 0 ? T.current : void 0;
749
922
  if (i !== void 0 && r) {
750
923
  let t = i * r;
751
924
  n ? n(t) : e.seek(t);
752
925
  }
753
- y.current = 0, S.current = !1, x.current = void 0, t.pointerType !== "mouse" && _(void 0);
754
- }, k = (e) => {
755
- if (!l.current) return;
756
- let { left: t, right: n } = l.current.getBoundingClientRect();
926
+ S.current = 0, D.current = !1, E.current = void 0, t.pointerType !== "mouse" && b(void 0);
927
+ }, M = (e) => {
928
+ if (!h.current) return;
929
+ let { left: t, right: n } = h.current.getBoundingClientRect();
757
930
  return Math.min(Math.max((e - t) / (n - t), 0), 1) * r;
758
- }, A = (e) => {
759
- _(k(e.clientX));
760
- }, j = () => {
761
- l.current && _(void 0);
762
- }, M = (e) => r ? e / r * 100 : 0, N = f(() => a?.map((e, t) => {
931
+ }, N = (e) => {
932
+ b(M(e.clientX));
933
+ }, P = () => {
934
+ h.current && b(void 0);
935
+ }, F = (e) => r ? e / r * 100 : 0, I = f(() => a?.map((e, t) => {
763
936
  if (!i || !r) return null;
764
937
  let n = o.filter((t) => e.startByteOffset <= t.pos && t.pos <= e.endByteOffset), a = n.at(0), s = n.at(-1);
765
938
  if (!a || !s) return null;
@@ -775,72 +948,102 @@ var ee = {
775
948
  r,
776
949
  o.length,
777
950
  a?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}/${t}`).join(",")
778
- ]), P = f(() => {
779
- if (!g || g < 0) return;
780
- let e = Math.floor(g / 3600), t = Math.floor((g - e * 3600) / 60), n = Math.floor(g - e * 3600 - t * 60);
781
- return `${e > 0 ? `${e}:` : ""}${t < 10 ? "0" : ""}${t}:${n < 10 ? "0" : ""}${n}`;
782
- }, [g]);
951
+ ]);
783
952
  d(() => {
784
- u === void 0 || !r || !T || !S.current || e.seek(u * r);
953
+ g === void 0 || !r || !O || !D.current || e.seek(g * r);
785
954
  }, [
786
955
  e,
787
- T,
788
- u,
956
+ O,
957
+ g,
789
958
  r
790
959
  ]);
791
- let F = f(() => !r || typeof t != "number" ? 0 : t / r, [r, t]), I = f(() => {
792
- if (g) {
793
- if (c) return c(g);
794
- if (s.length) return s.find(({ startTime: e, endTime: t }) => e <= g && g < t);
960
+ let L = f(() => !r || typeof t != "number" ? 0 : t / r, [r, t]), R = f(() => ke(u, r), [u, r]), z = R.length > 0, B = f(() => {
961
+ if (!z || v === void 0 || !r) return -1;
962
+ let e = v / r * 100, t = R.findIndex((t, n) => n < R.length - 1 && e >= t && e < R[n + 1]);
963
+ return t >= 0 ? t : R.length - 2;
964
+ }, [
965
+ z,
966
+ R,
967
+ v,
968
+ r
969
+ ]), V = f(() => z ? Ae(R, (e) => e !== B) : void 0, [
970
+ z,
971
+ R,
972
+ B
973
+ ]), H = f(() => B >= 0 ? Ae(R, (e) => e === B) : void 0, [R, B]), W = f(() => {
974
+ if (v !== void 0) return u.find(({ start: e, end: t }) => e <= v && v < t);
975
+ }, [u, v]), G = f(() => {
976
+ if (v) {
977
+ if (c) return c(v);
978
+ if (s.length) return s.find(({ startTime: e, endTime: t }) => e <= v && v < t);
795
979
  }
796
980
  }, [
797
981
  s,
798
982
  c,
799
- g
800
- ]);
801
- return /* @__PURE__ */ w("div", {
802
- css: Oe,
803
- ref: l,
804
- className: T ? "progress-bar dragging" : "progress-bar",
805
- onMouseMove: A,
806
- onMouseOut: j,
983
+ v
984
+ ]), ee = (e, t) => /* @__PURE__ */ w("div", {
985
+ className: e ? `track ${e}` : "track",
986
+ style: t ? { maskImage: t } : void 0,
807
987
  children: [
808
988
  /* @__PURE__ */ C("div", { className: "background-bar" }),
809
- g ? /* @__PURE__ */ C("div", {
810
- className: "cursor-time",
811
- style: { left: `clamp(calc(3 * var(--mp-unit)), ${M(g)}%, calc(100% - calc(3 * var(--mp-unit))))` },
812
- children: P
813
- }) : void 0,
814
- /* @__PURE__ */ C("div", { className: "progress" }),
815
989
  /* @__PURE__ */ C("div", {
816
990
  className: "loaded",
817
- children: N
991
+ children: I
818
992
  }),
819
- /* @__PURE__ */ C("div", { className: "hover" }),
820
993
  /* @__PURE__ */ C("div", {
821
994
  className: "play-container",
822
995
  children: /* @__PURE__ */ C("div", {
823
996
  className: "play",
824
- style: { transform: `scaleX(${F})` }
997
+ style: { transform: `scaleX(${L})` }
825
998
  })
826
- }),
827
- /* @__PURE__ */ C("div", { className: "chapters" }),
999
+ })
1000
+ ]
1001
+ });
1002
+ return /* @__PURE__ */ w("div", {
1003
+ css: Je,
1004
+ ref: h,
1005
+ className: [
1006
+ "progress-bar",
1007
+ O ? "dragging" : "",
1008
+ z ? "segmented" : ""
1009
+ ].filter(Boolean).join(" "),
1010
+ onMouseMove: N,
1011
+ onMouseOut: P,
1012
+ children: [
1013
+ ee(void 0, V),
1014
+ v ? /* @__PURE__ */ w("div", {
1015
+ className: "cursor-time",
1016
+ style: {
1017
+ left: W ? `clamp(var(--thumbnail-half), ${F(v)}%, calc(100% - var(--thumbnail-half)))` : `clamp(calc(3 * var(--mp-unit)), ${F(v)}%, calc(100% - calc(3 * var(--mp-unit))))`,
1018
+ maxWidth: W ? "var(--thumbnail-width)" : void 0
1019
+ },
1020
+ children: [/* @__PURE__ */ C("span", {
1021
+ className: "cursor-time-value",
1022
+ children: Y(v)
1023
+ }), W ? /* @__PURE__ */ C("span", {
1024
+ className: "chapter-title",
1025
+ children: W.title
1026
+ }) : void 0]
1027
+ }) : void 0,
1028
+ /* @__PURE__ */ C("div", { className: "progress" }),
1029
+ /* @__PURE__ */ C("div", { className: "hover" }),
1030
+ H ? ee("focus", H) : void 0,
828
1031
  /* @__PURE__ */ C("div", { className: "scrubber" }),
829
1032
  /* @__PURE__ */ C("div", {
830
1033
  className: "padding",
831
- ...E,
832
- onPointerDown: D,
833
- onPointerUp: O,
834
- onPointerCancel: O
1034
+ ...k,
1035
+ onPointerDown: A,
1036
+ onPointerUp: j,
1037
+ onPointerCancel: j
835
1038
  }),
836
1039
  /* @__PURE__ */ C("div", {
837
1040
  className: "thumbnail",
838
- style: { left: `clamp(var(--thumbnail-half), ${M(g ?? 1)}%, calc(100% - var(--thumbnail-half)))` },
839
- children: I?.url ? /* @__PURE__ */ C("img", { src: I.url }) : void 0
1041
+ style: { left: `clamp(var(--thumbnail-half), ${F(v ?? 1)}%, calc(100% - var(--thumbnail-half)))` },
1042
+ children: G?.url ? /* @__PURE__ */ C("img", { src: G.url }) : void 0
840
1043
  })
841
1044
  ]
842
1045
  });
843
- }, je = "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", Y = {
1046
+ }, Ze = "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", Q = {
844
1047
  xmlns: "http://www.w3.org/2000/svg",
845
1048
  width: 24,
846
1049
  height: 24,
@@ -850,8 +1053,8 @@ var ee = {
850
1053
  strokeWidth: 2,
851
1054
  strokeLinecap: "round",
852
1055
  strokeLinejoin: "round"
853
- }, Me = (e) => /* @__PURE__ */ w("svg", {
854
- ...Y,
1056
+ }, Qe = (e) => /* @__PURE__ */ w("svg", {
1057
+ ...Q,
855
1058
  ...e,
856
1059
  children: [/* @__PURE__ */ C("rect", {
857
1060
  x: "3",
@@ -861,8 +1064,8 @@ var ee = {
861
1064
  rx: "2",
862
1065
  ry: "2"
863
1066
  }), /* @__PURE__ */ C("path", { d: "M7 15h4m4 0h2M7 11h2m4 0h4" })]
864
- }), Ne = (e) => /* @__PURE__ */ w("svg", {
865
- ...Y,
1067
+ }), $e = (e) => /* @__PURE__ */ w("svg", {
1068
+ ...Q,
866
1069
  ...e,
867
1070
  children: [
868
1071
  /* @__PURE__ */ C("rect", {
@@ -881,8 +1084,8 @@ var ee = {
881
1084
  y2: "22"
882
1085
  })
883
1086
  ]
884
- }), Pe = (e) => /* @__PURE__ */ w("svg", {
885
- ...Y,
1087
+ }), et = (e) => /* @__PURE__ */ w("svg", {
1088
+ ...Q,
886
1089
  ...e,
887
1090
  children: [
888
1091
  /* @__PURE__ */ C("path", { d: "M21 11V7a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h5" }),
@@ -896,8 +1099,8 @@ var ee = {
896
1099
  }),
897
1100
  /* @__PURE__ */ C("path", { d: "M14.5 18.5h2m2 0h1" })
898
1101
  ]
899
- }), Fe = (e) => /* @__PURE__ */ w("svg", {
900
- ...Y,
1102
+ }), tt = (e) => /* @__PURE__ */ w("svg", {
1103
+ ...Q,
901
1104
  ...e,
902
1105
  children: [
903
1106
  /* @__PURE__ */ C("path", { d: "M21 11V7a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h5" }),
@@ -911,7 +1114,7 @@ var ee = {
911
1114
  }),
912
1115
  /* @__PURE__ */ C("path", { d: "M6 9h3m2 0h2" })
913
1116
  ]
914
- }), X = h`
1117
+ }), nt = h`
915
1118
  .popover {
916
1119
  position: absolute;
917
1120
  /* Anchored to the PLAYER's right edge, never to the gear. The gear is not the last control in the
@@ -950,7 +1153,7 @@ var ee = {
950
1153
 
951
1154
  border-radius: 8px;
952
1155
  background-color: rgba(28,28,28,0.95);
953
- ${H.bMedium.regular}
1156
+ ${K.bMedium.regular}
954
1157
 
955
1158
  z-index: 4;
956
1159
 
@@ -993,7 +1196,7 @@ var ee = {
993
1196
 
994
1197
  .secondary {
995
1198
  color: #eee;
996
- ${H.bSmall.regular}
1199
+ ${K.bSmall.regular}
997
1200
  }
998
1201
  }
999
1202
  }
@@ -1035,10 +1238,10 @@ var ee = {
1035
1238
  .failed {
1036
1239
  border-bottom: 1px solid #4D4D4E;
1037
1240
  color: #f66;
1038
- ${H.bSmall.regular}
1241
+ ${K.bSmall.regular}
1039
1242
  }
1040
1243
  }
1041
- `, Ie = ({ title: e, tracks: t, selected: n, onSelect: r, onBack: i, offLabel: a, pending: o, failed: s }) => {
1244
+ `, rt = ({ title: e, tracks: t, selected: n, onSelect: r, onBack: i, offLabel: a, pending: o, failed: s }) => {
1042
1245
  let c = o !== void 0, l = (e, i, a) => {
1043
1246
  let s = c && o === e, l = c || t.find((t) => t.id === e)?.disabled;
1044
1247
  return /* @__PURE__ */ w("div", {
@@ -1065,7 +1268,7 @@ var ee = {
1065
1268
  t.map(({ id: e, label: t }) => l(e, t, "description"))
1066
1269
  ]
1067
1270
  });
1068
- }, Z = ({ onReset: e } = {}) => {
1271
+ }, it = ({ onReset: e } = {}) => {
1069
1272
  let t = p(null), [n, r] = m(!1), [i, a] = m(void 0), [o, s] = m(!1), c = p(e);
1070
1273
  c.current = e;
1071
1274
  let l = () => {
@@ -1106,7 +1309,7 @@ var ee = {
1106
1309
  });
1107
1310
  }
1108
1311
  };
1109
- }, Le = h`
1312
+ }, at = h`
1110
1313
  /* Not a containing block, for the reason given on popoverStyle: the menu anchors to the control bar,
1111
1314
  which is the width of the player box, so it can be clamped to it. */
1112
1315
  position: static;
@@ -1122,7 +1325,7 @@ position: static;
1122
1325
  }
1123
1326
  }
1124
1327
 
1125
- ${X}
1328
+ ${nt}
1126
1329
 
1127
1330
  .popover.error-list {
1128
1331
  /* Wider than a track menu and taller, because these rows are sentences rather than labels, and a
@@ -1150,7 +1353,7 @@ ${X}
1150
1353
 
1151
1354
  color: #fff;
1152
1355
  cursor: pointer;
1153
- ${H.bSmall.regular}
1356
+ ${K.bSmall.regular}
1154
1357
 
1155
1358
  &:hover {
1156
1359
  background-color: rgba(255,255,255,.1);
@@ -1171,7 +1374,7 @@ ${X}
1171
1374
 
1172
1375
  .when {
1173
1376
  color: #bbb;
1174
- ${H.bSmall.regular}
1377
+ ${K.bSmall.regular}
1175
1378
 
1176
1379
  /* the one part of the line worth scanning for, so it is the one part at full brightness */
1177
1380
  .count {
@@ -1190,29 +1393,29 @@ ${X}
1190
1393
  color: #ddd;
1191
1394
  overflow-wrap: anywhere;
1192
1395
  white-space: pre-wrap;
1193
- ${H.bSmall.regular}
1396
+ ${K.bSmall.regular}
1194
1397
  }
1195
1398
  }
1196
1399
  }
1197
- `, Re = (e) => new Date(e).toLocaleTimeString(), Q = (e) => e === void 0 || !Number.isFinite(e) ? void 0 : G(Math.max(0, e)), ze = (e) => e.reduce((e, t) => e + t.count, 0), Be = (e) => e.map((e, t) => {
1198
- let n = Q(e.atMediaTime), r = e.count > 1 ? `${new Date(e.at).toISOString()} to ${new Date(e.lastAt).toISOString()} ×${e.count}` : new Date(e.at).toISOString();
1400
+ `, ot = (e) => new Date(e).toLocaleTimeString(), st = (e) => e === void 0 || !Number.isFinite(e) ? void 0 : Y(Math.max(0, e)), ct = (e) => e.reduce((e, t) => e + t.count, 0), lt = (e) => e.map((e, t) => {
1401
+ let n = st(e.atMediaTime), r = e.count > 1 ? `${new Date(e.at).toISOString()} to ${new Date(e.lastAt).toISOString()} ×${e.count}` : new Date(e.at).toISOString();
1199
1402
  return [
1200
1403
  `${t + 1}. ${r}${n ? ` (at ${n})` : ""}${e.recovered ? " [recovered]" : ""}`,
1201
1404
  e.message,
1202
1405
  e.detail
1203
1406
  ].filter(Boolean).join("\n");
1204
- }).join("\n\n"), Ve = () => {
1205
- let e = V((e) => e.playbackErrors), { open: t, toggle: n, containerRef: r } = Z(), [i, a] = m(!1);
1407
+ }).join("\n\n"), ut = () => {
1408
+ let e = U((e) => e.playbackErrors), { open: t, toggle: n, containerRef: r } = it(), [i, a] = m(!1);
1206
1409
  if (e.length === 0) return null;
1207
1410
  let o = () => {
1208
- navigator.clipboard?.writeText(Be(e)).then(() => {
1411
+ navigator.clipboard?.writeText(lt(e)).then(() => {
1209
1412
  a(!0), setTimeout(() => a(!1), 2e3);
1210
1413
  }, (e) => console.warn("[media-player] could not copy the errors:", e));
1211
- }, s = `Playback errors (${ze(e)})`;
1414
+ }, s = `Playback errors (${ct(e)})`;
1212
1415
  return /* @__PURE__ */ w("div", {
1213
- css: Le,
1416
+ css: at,
1214
1417
  ref: r,
1215
- children: [/* @__PURE__ */ C(q, {
1418
+ children: [/* @__PURE__ */ C(Z, {
1216
1419
  id: "errors",
1217
1420
  disabled: t,
1218
1421
  text: /* @__PURE__ */ C("button", {
@@ -1241,9 +1444,9 @@ ${X}
1241
1444
  /* @__PURE__ */ w("span", {
1242
1445
  className: "when",
1243
1446
  children: [
1244
- Re(e.at),
1245
- e.count > 1 ? ` to ${Re(e.lastAt)}` : "",
1246
- Q(e.atMediaTime) ? ` at ${Q(e.atMediaTime)}` : "",
1447
+ ot(e.at),
1448
+ e.count > 1 ? ` to ${ot(e.lastAt)}` : "",
1449
+ st(e.atMediaTime) ? ` at ${st(e.atMediaTime)}` : "",
1247
1450
  e.recovered ? " recovered" : "",
1248
1451
  e.count > 1 ? /* @__PURE__ */ C("span", {
1249
1452
  className: "count",
@@ -1263,7 +1466,7 @@ ${X}
1263
1466
  }, `${e.at}-${t}`))]
1264
1467
  })]
1265
1468
  });
1266
- }, He = h`
1469
+ }, dt = h`
1267
1470
  display: flex;
1268
1471
  align-items: center;
1269
1472
  justify-content: center;
@@ -1316,8 +1519,8 @@ width: 100%;
1316
1519
  }
1317
1520
  }
1318
1521
  }
1319
- `, Ue = () => {
1320
- let e = V(), t = V((e) => e.playbackRate), n = p(null), r = p(null), i = .25, a = 3 - i, 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 } = J({
1522
+ `, ft = () => {
1523
+ let e = U(), t = U((e) => e.playbackRate), n = p(null), r = p(null), i = .25, a = 3 - i, 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 } = we({
1321
1524
  ref: r,
1322
1525
  onChange: (t) => e.setPlaybackRate(l(t))
1323
1526
  }), f = (t) => {
@@ -1333,7 +1536,7 @@ width: 100%;
1333
1536
  }, [t]);
1334
1537
  let m = c(s);
1335
1538
  return /* @__PURE__ */ w("div", {
1336
- css: He,
1539
+ css: dt,
1337
1540
  children: [/* @__PURE__ */ w("div", { children: [s.toFixed(2), "x"] }), /* @__PURE__ */ C("div", {
1338
1541
  className: "playback-slider",
1339
1542
  ref: n,
@@ -1351,7 +1554,7 @@ width: 100%;
1351
1554
  })
1352
1555
  })]
1353
1556
  });
1354
- }, We = h`
1557
+ }, pt = h`
1355
1558
  /* Deliberately NOT a containing block. The menu anchors to the control bar instead, which is exactly
1356
1559
  as wide as the player box and can therefore be clamped to it. The outside-click check uses
1357
1560
  \`contains\` on the ref, which is DOM containment and needs no position, and the bar's other
@@ -1369,7 +1572,7 @@ position: static;
1369
1572
  }
1370
1573
  }
1371
1574
 
1372
- ${X}
1575
+ ${nt}
1373
1576
 
1374
1577
  .playback-rate {
1375
1578
  .slider {
@@ -1410,8 +1613,8 @@ ${X}
1410
1613
  }
1411
1614
  }
1412
1615
 
1413
- `, Ge = () => {
1414
- let e = V(), t = V((e) => e.playbackRate), n = V((e) => e.audioTracks), r = V((e) => e.selectedAudioTrack), i = V((e) => e.selectAudioTrack), [a, o] = m(0), { open: s, toggle: c, containerRef: l, pending: u, failed: d, runSelect: f } = Z({ onReset: () => o(0) }), p = (t) => {
1616
+ `, mt = () => {
1617
+ let e = U(), t = U((e) => e.playbackRate), n = U((e) => e.audioTracks), r = U((e) => e.selectedAudioTrack), i = U((e) => e.selectAudioTrack), [a, o] = m(0), { open: s, toggle: c, containerRef: l, pending: u, failed: d, runSelect: f } = it({ onReset: () => o(0) }), p = (t) => {
1415
1618
  e.setPlaybackRate(t), o(0);
1416
1619
  }, h = (e) => {
1417
1620
  e !== void 0 && f(e, () => i(e));
@@ -1419,10 +1622,10 @@ ${X}
1419
1622
  o(e);
1420
1623
  };
1421
1624
  return /* @__PURE__ */ w("div", {
1422
- css: We,
1625
+ css: pt,
1423
1626
  ref: l,
1424
1627
  children: [
1425
- /* @__PURE__ */ C(q, {
1628
+ /* @__PURE__ */ C(Z, {
1426
1629
  id: "settings",
1427
1630
  disabled: s,
1428
1631
  text: /* @__PURE__ */ C("button", {
@@ -1458,7 +1661,7 @@ ${X}
1458
1661
  }),
1459
1662
  /* @__PURE__ */ C("div", {
1460
1663
  className: "slider no-hover",
1461
- children: /* @__PURE__ */ C(Ue, {})
1664
+ children: /* @__PURE__ */ C(ft, {})
1462
1665
  }),
1463
1666
  /* @__PURE__ */ w("div", {
1464
1667
  className: "options no-hover",
@@ -1483,7 +1686,7 @@ ${X}
1483
1686
  })
1484
1687
  ]
1485
1688
  }),
1486
- s && a === 2 && /* @__PURE__ */ C(Ie, {
1689
+ s && a === 2 && /* @__PURE__ */ C(rt, {
1487
1690
  title: "Audio",
1488
1691
  tracks: n,
1489
1692
  selected: r,
@@ -1494,7 +1697,7 @@ ${X}
1494
1697
  })
1495
1698
  ]
1496
1699
  });
1497
- }, Ke = h`
1700
+ }, ht = h`
1498
1701
  /* Not a containing block, for the reason given on popoverStyle: the menu anchors to the control bar,
1499
1702
  which is the width of the player box, so it can be clamped to it. */
1500
1703
  position: static;
@@ -1510,15 +1713,15 @@ position: static;
1510
1713
  }
1511
1714
  }
1512
1715
 
1513
- ${X}
1514
- `, qe = () => {
1515
- let e = V((e) => e.subtitleTracks), t = V((e) => e.selectedSubtitleTrack), n = V((e) => e.selectSubtitleTrack), r = V((e) => e.subtitleOffLabel), { open: i, toggle: a, containerRef: o, pending: s, failed: c, runSelect: l } = Z();
1716
+ ${nt}
1717
+ `, gt = () => {
1718
+ let e = U((e) => e.subtitleTracks), t = U((e) => e.selectedSubtitleTrack), n = U((e) => e.selectSubtitleTrack), r = U((e) => e.subtitleOffLabel), { open: i, toggle: a, containerRef: o, pending: s, failed: c, runSelect: l } = it();
1516
1719
  if (e.length === 0) return null;
1517
1720
  let u = t !== void 0;
1518
1721
  return /* @__PURE__ */ w("div", {
1519
- css: Ke,
1722
+ css: ht,
1520
1723
  ref: o,
1521
- children: [/* @__PURE__ */ C(q, {
1724
+ children: [/* @__PURE__ */ C(Z, {
1522
1725
  id: "subtitles",
1523
1726
  disabled: i,
1524
1727
  text: /* @__PURE__ */ C("button", {
@@ -1528,10 +1731,10 @@ ${X}
1528
1731
  "aria-label": "Subtitles",
1529
1732
  "aria-expanded": i,
1530
1733
  "aria-pressed": u,
1531
- children: u ? /* @__PURE__ */ C(Me, { className: "captions" }) : /* @__PURE__ */ C(Ne, { className: "captions-off" })
1734
+ children: u ? /* @__PURE__ */ C(Qe, { className: "captions" }) : /* @__PURE__ */ C($e, { className: "captions-off" })
1532
1735
  }),
1533
1736
  toolTipText: /* @__PURE__ */ C("span", { children: "Subtitles" })
1534
- }), i && /* @__PURE__ */ C(Ie, {
1737
+ }), i && /* @__PURE__ */ C(rt, {
1535
1738
  title: "Subtitles",
1536
1739
  tracks: e,
1537
1740
  selected: t,
@@ -1541,13 +1744,13 @@ ${X}
1541
1744
  failed: c
1542
1745
  })]
1543
1746
  });
1544
- }, Je = {
1747
+ }, _t = {
1545
1748
  primary: "#EAEBEE",
1546
1749
  secondary: "#D0D0D9",
1547
1750
  hover: "rgba(255, 255, 255, 0.13)",
1548
1751
  borderPrimary: "#384F70",
1549
1752
  backgroundTooltip: "#222222"
1550
- }, Ye = h`
1753
+ }, vt = h`
1551
1754
  display: flex;
1552
1755
  align-items: center;
1553
1756
 
@@ -1590,8 +1793,8 @@ ${X}
1590
1793
  width: 10px;
1591
1794
  height: 10px;
1592
1795
  }
1593
- `, Xe = ({ value: e, onChange: t }) => {
1594
- let n = V((e) => e.volume), r = V((e) => e.muted), i = p(null), a = p(null), { handlers: o } = J({
1796
+ `, yt = ({ value: e, onChange: t }) => {
1797
+ let n = U((e) => e.volume), r = U((e) => e.muted), i = p(null), a = p(null), { handlers: o } = we({
1595
1798
  ref: a,
1596
1799
  onChange: t
1597
1800
  }), s = (n) => {
@@ -1605,12 +1808,12 @@ ${X}
1605
1808
  e && e.removeEventListener("wheel", s);
1606
1809
  };
1607
1810
  }, [e]);
1608
- let c = e * 100, l = f(() => Math.round(r ? 0 : W(n) * 100), [n, r]);
1609
- return /* @__PURE__ */ C(q, {
1811
+ let c = e * 100, l = f(() => Math.round(r ? 0 : J(n) * 100), [n, r]);
1812
+ return /* @__PURE__ */ C(Z, {
1610
1813
  id: "volume-slider",
1611
1814
  text: /* @__PURE__ */ C("div", {
1612
1815
  ref: i,
1613
- css: Ye,
1816
+ css: vt,
1614
1817
  ...o,
1615
1818
  children: /* @__PURE__ */ C("div", {
1616
1819
  ref: a,
@@ -1629,7 +1832,7 @@ ${X}
1629
1832
  children: [l, "%"]
1630
1833
  })
1631
1834
  });
1632
- }, Ze = h`
1835
+ }, bt = h`
1633
1836
  position: relative;
1634
1837
  display: flex;
1635
1838
  align-items: center;
@@ -1654,7 +1857,7 @@ ${X}
1654
1857
  border-radius: 4px;
1655
1858
 
1656
1859
  .volume-value {
1657
- ${H.bMedium.regular};
1860
+ ${K.bMedium.regular};
1658
1861
  color: #ffffff;
1659
1862
  }
1660
1863
  }
@@ -1692,11 +1895,11 @@ ${X}
1692
1895
  }
1693
1896
  }
1694
1897
 
1695
- `, Qe = ({ ref: e }) => {
1696
- let t = V(), n = V((e) => e.volume), r = V((e) => e.muted), i = f(() => W(n), [n]);
1898
+ `, xt = ({ ref: e }) => {
1899
+ let t = U(), n = U((e) => e.volume), r = U((e) => e.muted), i = f(() => J(n), [n]);
1697
1900
  return /* @__PURE__ */ w("div", {
1698
- css: Ze,
1699
- children: [/* @__PURE__ */ C(q, {
1901
+ css: bt,
1902
+ children: [/* @__PURE__ */ C(Z, {
1700
1903
  id: "sound",
1701
1904
  text: /* @__PURE__ */ C("button", {
1702
1905
  className: "sound",
@@ -1715,16 +1918,16 @@ ${X}
1715
1918
  className: "volume-slider-container",
1716
1919
  children: /* @__PURE__ */ C("div", {
1717
1920
  className: "volume-slider-background",
1718
- children: /* @__PURE__ */ C(Xe, {
1921
+ children: /* @__PURE__ */ C(yt, {
1719
1922
  value: r ? 0 : i,
1720
1923
  onChange: (e) => {
1721
- t.setVolume(Ce(e));
1924
+ t.setVolume(ye(e));
1722
1925
  }
1723
1926
  })
1724
1927
  })
1725
1928
  })]
1726
1929
  });
1727
- }, $ = .05, $e = 5, et = h`
1930
+ }, $ = .05, St = 5, Ct = h`
1728
1931
  display: flex;
1729
1932
  flex-direction: column;
1730
1933
  gap: calc(0.4 * var(--mp-unit));
@@ -1733,7 +1936,7 @@ ${X}
1733
1936
  opacity: 0.72;
1734
1937
  font-size: 0.9em;
1735
1938
  }
1736
- `, tt = h`
1939
+ `, wt = h`
1737
1940
  position: absolute;
1738
1941
  bottom: 0;
1739
1942
  width: 100%;
@@ -1823,7 +2026,7 @@ ${X}
1823
2026
  cursor: pointer;
1824
2027
 
1825
2028
  :hover {
1826
- background-color: ${Je.hover};
2029
+ background-color: ${_t.hover};
1827
2030
  }
1828
2031
 
1829
2032
  /* the hit area grows, the icon does not, keyed on the pointer because a narrow desktop
@@ -1840,7 +2043,7 @@ ${X}
1840
2043
 
1841
2044
  .left {
1842
2045
  .time {
1843
- ${H.bMedium.regular}
2046
+ ${K.bMedium.regular}
1844
2047
  text-shadow: 0 0 4px rgba(0, 0, 0, 1);
1845
2048
  }
1846
2049
  }
@@ -1861,10 +2064,10 @@ ${X}
1861
2064
  }
1862
2065
  }
1863
2066
  }
1864
- `, nt = () => {
1865
- let e = V(), t = V((e) => e.paused), n = V((e) => e.currentTime), r = V((e) => e.duration), i = V((e) => e.fullscreen), a = V((e) => e.hideUI), o = V((e) => e.togglePictureInPicture), s = V((e) => e.pictureInPictureMode), c = V((e) => e.burnedInSubtitles), l = V((e) => e.subtitleTracks), f = V((e) => e.requestSeek), [p, h] = m(null), g = s === "burn-in", _ = l.length > 0, v = r > 0 && n === r, y = u(({ direction: t, stepSize: n }) => {
1866
- let r = W(e.volume), i = t === "up" ? n : -n, a = Math.max(0, Math.min(1, r + i)), o = e.muted;
1867
- e.setVolume(Ce(a)), o && !e.muted && e.toggleMuted();
2067
+ `, Tt = () => {
2068
+ let e = U(), t = U((e) => e.paused), n = U((e) => e.currentTime), r = U((e) => e.duration), i = U((e) => e.fullscreen), a = U((e) => e.hideUI), o = U((e) => e.togglePictureInPicture), s = U((e) => e.pictureInPictureMode), c = U((e) => e.burnedInSubtitles), l = U((e) => e.subtitleTracks), f = U((e) => e.requestSeek), [p, h] = m(null), g = s === "burn-in", _ = l.length > 0, v = r > 0 && n === r, y = u(({ direction: t, stepSize: n }) => {
2069
+ let r = J(e.volume), i = t === "up" ? n : -n, a = Math.max(0, Math.min(1, r + i)), o = e.muted;
2070
+ e.setVolume(ye(a)), o && !e.muted && e.toggleMuted();
1868
2071
  }, [e]);
1869
2072
  d(() => {
1870
2073
  let t = (t) => f ? f(t) : e.seek(t), n = (n) => {
@@ -1885,8 +2088,8 @@ ${X}
1885
2088
  });
1886
2089
  else if (n.key === "ArrowRight") {
1887
2090
  if (!e.duration) return;
1888
- t(Math.min(e.currentTime + $e, e.duration));
1889
- } else n.key === "ArrowLeft" ? t(Math.max(e.currentTime - $e, 0)) : i = !1;
2091
+ t(Math.min(e.currentTime + St, e.duration));
2092
+ } else n.key === "ArrowLeft" ? t(Math.max(e.currentTime - St, 0)) : i = !1;
1890
2093
  i && n.preventDefault();
1891
2094
  };
1892
2095
  return window.addEventListener("keydown", n), () => window.removeEventListener("keydown", n);
@@ -1907,17 +2110,17 @@ ${X}
1907
2110
  return d(() => {
1908
2111
  if (p) return p.addEventListener("wheel", b, { passive: !1 }), () => p.removeEventListener("wheel", b);
1909
2112
  }, [p, b]), /* @__PURE__ */ w("div", {
1910
- css: tt,
2113
+ css: wt,
1911
2114
  style: { ...a ? {
1912
2115
  opacity: "0",
1913
2116
  pointerEvents: "none"
1914
2117
  } : {} },
1915
- children: [/* @__PURE__ */ C(Ae, {}), /* @__PURE__ */ w("div", {
2118
+ children: [/* @__PURE__ */ C(Xe, {}), /* @__PURE__ */ w("div", {
1916
2119
  className: "actions",
1917
2120
  children: [/* @__PURE__ */ w("div", {
1918
2121
  className: "left",
1919
2122
  children: [
1920
- /* @__PURE__ */ C(q, {
2123
+ /* @__PURE__ */ C(Z, {
1921
2124
  id: "play",
1922
2125
  tooltipPlace: "top-start",
1923
2126
  text: /* @__PURE__ */ C("button", {
@@ -1929,19 +2132,19 @@ ${X}
1929
2132
  }),
1930
2133
  toolTipText: /* @__PURE__ */ C("span", { children: v ? "Replay (k)" : t ? "Play (k)" : "Pause (k)" })
1931
2134
  }),
1932
- /* @__PURE__ */ C(Qe, { ref: h }),
2135
+ /* @__PURE__ */ C(xt, { ref: h }),
1933
2136
  /* @__PURE__ */ C("div", {
1934
2137
  className: "time",
1935
- children: we(n, r)
2138
+ children: be(n, r)
1936
2139
  })
1937
2140
  ]
1938
2141
  }), /* @__PURE__ */ w("div", {
1939
2142
  className: "right",
1940
2143
  children: [
1941
- /* @__PURE__ */ C(Ve, {}),
1942
- /* @__PURE__ */ C(qe, {}),
1943
- /* @__PURE__ */ C(Ge, {}),
1944
- o ? /* @__PURE__ */ C(q, {
2144
+ /* @__PURE__ */ C(ut, {}),
2145
+ /* @__PURE__ */ C(gt, {}),
2146
+ /* @__PURE__ */ C(mt, {}),
2147
+ o ? /* @__PURE__ */ C(Z, {
1945
2148
  id: "picture-in-picture",
1946
2149
  tooltipPlace: "top-end",
1947
2150
  text: /* @__PURE__ */ C("button", {
@@ -1951,13 +2154,13 @@ ${X}
1951
2154
  disabled: g && !_,
1952
2155
  "aria-label": g ? "Put the subtitles in the video" : "Picture in picture",
1953
2156
  "aria-pressed": g ? c : void 0,
1954
- children: g ? C(c ? Pe : Fe, {}) : /* @__PURE__ */ C("img", {
1955
- src: je,
2157
+ children: g ? C(c ? et : tt, {}) : /* @__PURE__ */ C("img", {
2158
+ src: Ze,
1956
2159
  alt: ""
1957
2160
  })
1958
2161
  }),
1959
2162
  toolTipText: /* @__PURE__ */ w("span", {
1960
- css: et,
2163
+ css: Ct,
1961
2164
  children: [/* @__PURE__ */ C("span", {
1962
2165
  className: "lead",
1963
2166
  children: g ? _ ? c ? "Subtitles are in the picture" : "Put the subtitles in the picture" : "This file has no subtitles" : "Picture in picture"
@@ -1967,7 +2170,7 @@ ${X}
1967
2170
  }) : null]
1968
2171
  })
1969
2172
  }) : null,
1970
- /* @__PURE__ */ C(q, {
2173
+ /* @__PURE__ */ C(Z, {
1971
2174
  id: "full-screen",
1972
2175
  tooltipPlace: "top-end",
1973
2176
  text: /* @__PURE__ */ C("button", {
@@ -1984,7 +2187,7 @@ ${X}
1984
2187
  })]
1985
2188
  })]
1986
2189
  });
1987
- }, rt = 9e3, it = h`
2190
+ }, Et = 9e3, Dt = h`
1988
2191
  position: absolute;
1989
2192
  inset: 0;
1990
2193
  z-index: 2;
@@ -2022,12 +2225,12 @@ ${X}
2022
2225
  }
2023
2226
 
2024
2227
  .title {
2025
- ${H.bMedium.bold}
2228
+ ${K.bMedium.bold}
2026
2229
  color: #fff;
2027
2230
  }
2028
2231
 
2029
2232
  .body {
2030
- ${H.bSmall.regular}
2233
+ ${K.bSmall.regular}
2031
2234
  color: rgba(255, 255, 255, 0.75);
2032
2235
  }
2033
2236
 
@@ -2038,18 +2241,18 @@ ${X}
2038
2241
  line-height: 1;
2039
2242
  color: #fff;
2040
2243
  }
2041
- `, at = () => {
2042
- let e = V((e) => e.burnedInSubtitles), t = V((e) => e.pictureInPictureMode), [n, r] = m(!1);
2244
+ `, Ot = () => {
2245
+ let e = U((e) => e.burnedInSubtitles), t = U((e) => e.pictureInPictureMode), [n, r] = m(!1);
2043
2246
  return d(() => {
2044
2247
  if (t !== "burn-in" || !e) {
2045
2248
  r(!1);
2046
2249
  return;
2047
2250
  }
2048
2251
  r(!0);
2049
- let n = setTimeout(() => r(!1), rt);
2252
+ let n = setTimeout(() => r(!1), Et);
2050
2253
  return () => clearTimeout(n);
2051
2254
  }, [t, e]), t !== "burn-in" || !e ? null : /* @__PURE__ */ C("div", {
2052
- css: it,
2255
+ css: Dt,
2053
2256
  className: n ? "show" : "",
2054
2257
  role: "status",
2055
2258
  children: /* @__PURE__ */ w("div", {
@@ -2070,7 +2273,101 @@ ${X}
2070
2273
  })]
2071
2274
  })
2072
2275
  });
2073
- }, ot = 3e3, st = h`
2276
+ }, kt = 1, At = 6e3, jt = 1, Mt = {
2277
+ opening: "Skip Opening",
2278
+ ending: "Skip Ending"
2279
+ }, Nt = h`
2280
+ position: absolute;
2281
+ inset: 0;
2282
+ z-index: 2;
2283
+ pointer-events: none;
2284
+
2285
+ button {
2286
+ position: absolute;
2287
+ /* clear of the control bar, which is 6 to 8px of padding plus a row of 18 to 28px controls and
2288
+ the seekbar above them */
2289
+ bottom: calc(7 * var(--mp-unit));
2290
+ right: calc(2.4 * var(--mp-unit));
2291
+
2292
+ /* the one thing in this layer that can be pressed */
2293
+ pointer-events: auto;
2294
+ cursor: pointer;
2295
+
2296
+ ${K.bMedium.bold}
2297
+ color: #fff;
2298
+ padding: calc(1 * var(--mp-unit)) calc(1.8 * var(--mp-unit));
2299
+ border: 1px solid rgba(255, 255, 255, .55);
2300
+ border-radius: calc(.4 * var(--mp-unit));
2301
+ background-color: rgba(20, 20, 22, .8);
2302
+ box-shadow: 0 0 calc(1 * var(--mp-unit)) rgba(0, 0, 0, .5);
2303
+
2304
+ opacity: 0;
2305
+ transform: translateY(calc(.6 * var(--mp-unit)));
2306
+ /* visibility as well as opacity, so a faded button cannot be hovered or pressed */
2307
+ visibility: hidden;
2308
+ transition: opacity .18s ease, transform .18s ease, visibility .18s;
2309
+
2310
+ &:hover, &:focus-visible {
2311
+ background-color: rgba(255, 255, 255, .92);
2312
+ color: #111;
2313
+ border-color: transparent;
2314
+ }
2315
+ }
2316
+
2317
+ &.show button {
2318
+ opacity: 1;
2319
+ transform: none;
2320
+ visibility: visible;
2321
+ }
2322
+
2323
+ @media (pointer: coarse) {
2324
+ button {
2325
+ /* a finger needs a target, and the control row below is already 44px */
2326
+ min-height: 44px;
2327
+ bottom: calc(9 * var(--mp-unit));
2328
+ }
2329
+ }
2330
+ `, Pt = () => {
2331
+ let e = U((e) => e.chapters), t = U((e) => e.currentTime), n = U((e) => e.requestSeek), r = U(), i = f(() => qe(e), [e]), a = f(() => {
2332
+ if (typeof t != "number") return;
2333
+ let n = e.findIndex((e, n) => i[n] !== void 0 && e.start - kt <= t && t < e.end), r = n >= 0 ? i[n] : void 0;
2334
+ return r ? {
2335
+ kind: r,
2336
+ end: e[n].end
2337
+ } : void 0;
2338
+ }, [
2339
+ e,
2340
+ i,
2341
+ t
2342
+ ]), o = p(0), [s, c] = m(0);
2343
+ d(() => {
2344
+ let e = typeof t == "number" ? t : 0, n = o.current;
2345
+ o.current = e, e < n - jt && c((e) => e + 1);
2346
+ }, [t]);
2347
+ let [l, u] = m(!1), h = a ? `${a.kind}@${a.end}` : "";
2348
+ return d(() => {
2349
+ if (!h) {
2350
+ u(!1);
2351
+ return;
2352
+ }
2353
+ u(!0);
2354
+ let e = setTimeout(() => u(!1), At);
2355
+ return () => clearTimeout(e);
2356
+ }, [h, s]), d(() => {
2357
+ a || u(!1);
2358
+ }, [a]), a ? /* @__PURE__ */ C("div", {
2359
+ css: Nt,
2360
+ className: l ? "show" : "",
2361
+ children: /* @__PURE__ */ C("button", {
2362
+ type: "button",
2363
+ className: "skip-chapter",
2364
+ onClick: () => {
2365
+ u(!1), n ? n(a.end) : r.seek(a.end);
2366
+ },
2367
+ children: Mt[a.kind]
2368
+ })
2369
+ }) : null;
2370
+ }, Ft = 3e3, It = h`
2074
2371
  position: absolute;
2075
2372
  inset: 0;
2076
2373
  z-index: 2;
@@ -2081,7 +2378,7 @@ ${X}
2081
2378
  hoverable while faded out, popping a tooltip over nothing. It cascades where pointer-events does
2082
2379
  not, and transitioning it holds the item on screen for the length of the fade. */
2083
2380
  transition: opacity 0.1s cubic-bezier(.4,0,1,1), visibility 0.1s;
2084
- `, ct = h`
2381
+ `, Lt = h`
2085
2382
  position: relative;
2086
2383
  background-color: black;
2087
2384
  display: flex;
@@ -2126,14 +2423,14 @@ ${X}
2126
2423
  &.hide {
2127
2424
  cursor: none;
2128
2425
  }
2129
- `, lt = (e, t = "") => s.toArray(e).flatMap((e, n) => {
2426
+ `, Rt = (e, t = "") => s.toArray(e).flatMap((e, n) => {
2130
2427
  let r = `${t}${l(e) && e.key != null ? e.key : n}`;
2131
- return l(e) && e.type === c ? lt(e.props.children, `${r}/`) : [{
2428
+ return l(e) && e.type === c ? Rt(e.props.children, `${r}/`) : [{
2132
2429
  key: r,
2133
2430
  item: e
2134
2431
  }];
2135
- }), ut = ({ ref: e, onVideoRef: t, onSubtitleRef: n, overlay: r, controls: i, children: a }) => {
2136
- let o = V(), s = V((e) => e.hideUI), c = V((e) => e.setHideUI), l = p(void 0), u = p("mouse"), f = p({
2432
+ }), zt = ({ ref: e, onVideoRef: t, onSubtitleRef: n, overlay: r, controls: i, children: a }) => {
2433
+ let o = U(), s = U((e) => e.hideUI), c = U((e) => e.setHideUI), l = p(void 0), u = p("mouse"), f = p({
2137
2434
  x: -1,
2138
2435
  y: -1
2139
2436
  }), m = p(null);
@@ -2148,15 +2445,15 @@ ${X}
2148
2445
  return !!n && m.current.contains(n) && !n.closest(".video");
2149
2446
  }, _ = () => {
2150
2447
  if (g()) {
2151
- l.current = setTimeout(_, ot);
2448
+ l.current = setTimeout(_, Ft);
2152
2449
  return;
2153
2450
  }
2154
2451
  c(!0);
2155
2452
  }, v = () => {
2156
- c(!1), clearTimeout(l.current), l.current = setTimeout(_, ot);
2453
+ c(!1), clearTimeout(l.current), l.current = setTimeout(_, Ft);
2157
2454
  };
2158
2455
  return /* @__PURE__ */ w("div", {
2159
- css: ct,
2456
+ css: Lt,
2160
2457
  ref: h,
2161
2458
  onPointerMove: (e) => {
2162
2459
  u.current = e.pointerType, e.pointerType === "mouse" && (f.current = {
@@ -2175,9 +2472,9 @@ ${X}
2175
2472
  },
2176
2473
  className: s ? "hide" : "",
2177
2474
  children: [
2178
- /* @__PURE__ */ C(xe, { onSubtitleRef: n }),
2179
- lt(r).map(({ key: e, item: t }) => /* @__PURE__ */ C("div", {
2180
- css: st,
2475
+ /* @__PURE__ */ C(_e, { onSubtitleRef: n }),
2476
+ Rt(r).map(({ key: e, item: t }) => /* @__PURE__ */ C("div", {
2477
+ css: It,
2181
2478
  style: { ...s ? {
2182
2479
  opacity: "0",
2183
2480
  visibility: "hidden",
@@ -2185,8 +2482,9 @@ ${X}
2185
2482
  } : {} },
2186
2483
  children: t
2187
2484
  }, e)),
2188
- i === !1 ? null : /* @__PURE__ */ C(nt, {}),
2189
- /* @__PURE__ */ C(at, {}),
2485
+ i === !1 ? null : /* @__PURE__ */ C(Tt, {}),
2486
+ /* @__PURE__ */ C(Ot, {}),
2487
+ /* @__PURE__ */ C(Pt, {}),
2190
2488
  /* @__PURE__ */ w("div", {
2191
2489
  className: "video",
2192
2490
  onClick: () => {
@@ -2203,94 +2501,98 @@ ${X}
2203
2501
  })
2204
2502
  ]
2205
2503
  });
2206
- }, dt = ({ options: e, children: t }) => {
2207
- let n = "media" in e ? e : null, r = n ? null : e, { title: i } = e, { size: a, downloadedRanges: o, publicPath: s, libavWorkerUrl: c, read: l, thumbnailRead: u, thumbnailsEnabled: f } = r ?? {}, h = y(), g = v(), [_, b] = m(null), [x, S] = m(null), w = n?.media ?? _;
2208
- d(() => (h?.(w), () => h?.(null)), [w, h]);
2209
- let { expose: T } = e, E = T === !0 ? {} : T || void 0, D = p(E);
2210
- D.current = E;
2211
- let O = E ? E.id : void 0, k = E ? E.origin : void 0, A = E ? E.channel : void 0;
2504
+ }, Bt = ({ options: e, children: t }) => {
2505
+ 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: u, thumbnailRead: f, thumbnailsEnabled: h } = r ?? {}, g = y(), _ = v(), [b, x] = m(null), [S, w] = m(null), T = n?.media ?? b;
2506
+ d(() => (g?.(T), () => g?.(null)), [T, g]);
2507
+ let { expose: E } = e, D = E === !0 ? {} : E || void 0, O = p(D);
2508
+ O.current = D;
2509
+ let k = D ? D.id : void 0, A = D ? D.origin : void 0, j = D ? D.channel : void 0;
2212
2510
  d(() => {
2213
- if (!T || !w) return;
2511
+ if (!E || !T) return;
2214
2512
  let e, t = !1;
2215
2513
  return import("./remote/index.js").then(({ exposePlayer: n }) => {
2216
- t || (e = n(w, D.current ?? {}));
2514
+ t || (e = n(T, O.current ?? {}));
2217
2515
  }).catch(() => {}), () => {
2218
2516
  t = !0, e?.();
2219
2517
  };
2220
2518
  }, [
2221
- w,
2222
- !!T,
2223
- O,
2519
+ T,
2520
+ !!E,
2224
2521
  k,
2225
- A
2226
- ]), de(_, x, r);
2227
- let j = me({
2228
- publicPath: s,
2229
- workerUrl: c,
2230
- length: f === !1 ? void 0 : a,
2231
- read: u ?? l,
2232
- downloadedRanges: o
2233
- }), M = n?.thumbnails?.all ?? j, { toggle: N, mode: P, burnedIn: F } = he(_, x), I = V((e) => e.setSourceState);
2522
+ A,
2523
+ j
2524
+ ]), se(b, S, r);
2525
+ let { thumbnails: M, requestThumbnail: N } = ue({
2526
+ publicPath: c,
2527
+ workerUrl: l,
2528
+ length: h === !1 ? void 0 : o,
2529
+ read: f ?? u,
2530
+ downloadedRanges: s
2531
+ }), P = n?.thumbnails?.all ?? M, { toggle: F, mode: I, burnedIn: L } = de(b, S), R = U((e) => e.setSourceState);
2234
2532
  d(() => {
2235
- I({
2533
+ R({
2236
2534
  title: i,
2237
- size: a,
2238
- downloadedRanges: o
2535
+ size: o,
2536
+ downloadedRanges: s
2239
2537
  });
2240
2538
  }, [
2241
- I,
2539
+ R,
2242
2540
  i,
2243
- a,
2244
- o
2541
+ o,
2542
+ s
2245
2543
  ]);
2246
- let L = n?.thumbnails?.at;
2544
+ let z = n?.thumbnails?.at;
2247
2545
  d(() => {
2248
- I({
2249
- thumbnails: M,
2250
- thumbnailAt: L,
2251
- togglePictureInPicture: N,
2252
- pictureInPictureMode: P,
2253
- burnedInSubtitles: F
2546
+ R({
2547
+ thumbnails: P,
2548
+ thumbnailAt: z,
2549
+ requestThumbnail: N,
2550
+ togglePictureInPicture: F,
2551
+ pictureInPictureMode: I,
2552
+ burnedInSubtitles: L
2254
2553
  });
2255
2554
  }, [
2256
- I,
2257
- M,
2258
- L,
2259
- N,
2555
+ R,
2260
2556
  P,
2261
- F
2557
+ z,
2558
+ N,
2559
+ F,
2560
+ I,
2561
+ L
2262
2562
  ]);
2263
- let R = n?.subtitles?.selection, z = n?.audioTracks?.selection;
2563
+ let B = n?.subtitles?.selection, V = n?.audioTracks?.selection;
2264
2564
  return d(() => {
2265
- R && I({
2266
- subtitleTracks: R.options.map(({ id: e, label: t, disabled: n }) => ({
2565
+ B && R({
2566
+ subtitleTracks: B.options.map(({ id: e, label: t, disabled: n }) => ({
2267
2567
  id: e,
2268
2568
  label: t,
2269
2569
  disabled: n
2270
2570
  })),
2271
- selectedSubtitleTrack: R.selectedId ?? void 0,
2272
- selectSubtitleTrack: (e) => R.select(e == null ? null : String(e)),
2273
- subtitleOffLabel: R.offLabel
2571
+ selectedSubtitleTrack: B.selectedId ?? void 0,
2572
+ selectSubtitleTrack: (e) => B.select(e == null ? null : String(e)),
2573
+ subtitleOffLabel: B.offLabel
2274
2574
  });
2275
- }, [I, R]), d(() => {
2276
- z && I({
2277
- audioTracks: z.options.map(({ id: e, label: t, disabled: n }) => ({
2575
+ }, [R, B]), d(() => {
2576
+ V && R({
2577
+ audioTracks: V.options.map(({ id: e, label: t, disabled: n }) => ({
2278
2578
  id: e,
2279
2579
  label: t,
2280
2580
  disabled: n
2281
2581
  })),
2282
- selectedAudioTrack: z.selectedId ?? void 0,
2283
- selectAudioTrack: (e) => z.select(String(e))
2582
+ selectedAudioTrack: V.selectedId ?? void 0,
2583
+ selectAudioTrack: (e) => V.select(String(e))
2284
2584
  });
2285
- }, [I, z]), /* @__PURE__ */ C(ut, {
2286
- ref: g,
2287
- onVideoRef: n ? void 0 : b,
2288
- onSubtitleRef: S,
2585
+ }, [R, V]), d(() => {
2586
+ a && R({ chapters: a });
2587
+ }, [R, a]), /* @__PURE__ */ C(zt, {
2588
+ ref: _,
2589
+ onVideoRef: n ? void 0 : x,
2590
+ onSubtitleRef: w,
2289
2591
  overlay: e.overlay,
2290
2592
  controls: e.controls,
2291
2593
  children: t
2292
2594
  });
2293
- }, ft = h`
2595
+ }, Vt = h`
2294
2596
  /**
2295
2597
  * The chrome's whole scale, in one place.
2296
2598
  *
@@ -2360,17 +2662,17 @@ ${X}
2360
2662
  height: 100%;
2361
2663
  width: 100%;
2362
2664
  overflow: hidden;
2363
- `, pt = (e) => /* @__PURE__ */ C("div", {
2364
- css: ft,
2365
- children: /* @__PURE__ */ C(B.Provider, { children: /* @__PURE__ */ C(dt, {
2665
+ `, Ht = (e) => /* @__PURE__ */ C("div", {
2666
+ css: Vt,
2667
+ children: /* @__PURE__ */ C(H.Provider, { children: /* @__PURE__ */ C(Bt, {
2366
2668
  options: e,
2367
2669
  children: e.children
2368
2670
  }) })
2369
- }), mt = (e) => !!e && typeof e == "object" && "at" in e, ht = (e) => !!e && typeof e == "object" && "selection" in e, gt = ({ blob: e, name: t }) => ({
2671
+ }), Ut = (e) => !!e && typeof e == "object" && "at" in e, Wt = (e) => !!e && typeof e == "object" && "selection" in e, Gt = ({ blob: e, name: t }) => ({
2370
2672
  length: e.size,
2371
2673
  name: t ?? (e instanceof File ? e.name : void 0),
2372
2674
  read: (t, n) => e.slice(t, t + n).arrayBuffer()
2373
- }), _t = async (e, t) => {
2675
+ }), Kt = async (e, t) => {
2374
2676
  let n = await fetch(e, {
2375
2677
  headers: { Range: "bytes=0-1" },
2376
2678
  credentials: t
@@ -2380,23 +2682,25 @@ ${X}
2380
2682
  if (!Number.isFinite(i) || i <= 0) throw Error("The source did not report its length");
2381
2683
  if (!r && n.status !== 206) throw Error("The source does not support range requests");
2382
2684
  return i;
2383
- }, vt = async ({ url: e, length: t, name: n, credentials: r }) => {
2384
- let i = t ?? await _t(e, r);
2685
+ }, qt = async ({ url: e, length: t, name: n, credentials: r }) => {
2686
+ let i = t ?? await Kt(e, r);
2385
2687
  return {
2386
2688
  length: i,
2387
2689
  name: n,
2388
2690
  read: async (t, n) => {
2389
- let a = await fetch(e, {
2390
- headers: { Range: `bytes=${t}-${Math.min(t + n, i) - 1}` },
2691
+ let a = Math.min(t + n, i) - 1;
2692
+ if (a < t) return /* @__PURE__ */ new ArrayBuffer(0);
2693
+ let o = await fetch(e, {
2694
+ headers: { Range: `bytes=${t}-${a}` },
2391
2695
  credentials: r
2392
2696
  });
2393
- if (!a.ok) throw Error(`The source could not be read: HTTP ${a.status}`);
2394
- return a.arrayBuffer();
2697
+ if (!o.ok) throw Error(`The source could not be read: HTTP ${o.status}`);
2698
+ return o.arrayBuffer();
2395
2699
  }
2396
2700
  };
2397
- }, yt = async (e) => {
2398
- if ("blob" in e) return gt(e);
2399
- if ("url" in e) return vt(e);
2701
+ }, Jt = async (e) => {
2702
+ if ("blob" in e) return Gt(e);
2703
+ if ("url" in e) return qt(e);
2400
2704
  if ("read" in e) return {
2401
2705
  length: e.length,
2402
2706
  name: e.name,
@@ -2405,4 +2709,4 @@ ${X}
2405
2709
  throw Error(`Unknown source type: ${e}`);
2406
2710
  };
2407
2711
  //#endregion
2408
- export { pt as MediaPlayer, pt as default, B as Player, e as SUBTITLES_OFF, a as createPictureInPicture, o as createSubtitleRenderer, r as createThumbnailGenerator, yt as inputToRemuxerInput, ht as isDelegatedTracks, mt as isExternalThumbnails, te as sourceFeature, i as startPlayback, he as usePictureInPicture, V as usePlayer, me as useSeekThumbnails };
2712
+ export { Ht as MediaPlayer, Ht as default, H as Player, e as SUBTITLES_OFF, a as createPictureInPicture, o as createSubtitleRenderer, r as createThumbnailGenerator, Jt as inputToRemuxerInput, Wt as isDelegatedTracks, Ut as isExternalThumbnails, V as sourceFeature, i as startPlayback, de as usePictureInPicture, U as usePlayer, ue as useSeekThumbnails };