@banou/media-player 0.10.27 → 0.10.29

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