@glitchlab/react-video-player 1.1.1 → 1.3.0

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.mjs CHANGED
@@ -1,53 +1,24 @@
1
1
  "use client";
2
- import { jsx as r, jsxs as m } from "react/jsx-runtime";
3
- import X, { useRef as H, useImperativeHandle as q, useEffect as G, useState as $, useMemo as I, useCallback as b } from "react";
4
- import E from "hls.js";
5
- function _(e) {
6
- var o, n, t = "";
7
- if (typeof e == "string" || typeof e == "number") t += e;
2
+ import { jsxs as v, jsx as t } from "react/jsx-runtime";
3
+ import he, { useState as k, useRef as V, useCallback as S, useEffect as x, useImperativeHandle as me, useMemo as U } from "react";
4
+ import $ from "hls.js";
5
+ function Q(e) {
6
+ var n, s, r = "";
7
+ if (typeof e == "string" || typeof e == "number") r += e;
8
8
  else if (typeof e == "object") if (Array.isArray(e)) {
9
9
  var l = e.length;
10
- for (o = 0; o < l; o++) e[o] && (n = _(e[o])) && (t && (t += " "), t += n);
11
- } else for (n in e) e[n] && (t && (t += " "), t += n);
12
- return t;
10
+ for (n = 0; n < l; n++) e[n] && (s = Q(e[n])) && (r && (r += " "), r += s);
11
+ } else for (s in e) e[s] && (r && (r += " "), r += s);
12
+ return r;
13
13
  }
14
- function Z() {
15
- for (var e, o, n = 0, t = "", l = arguments.length; n < l; n++) (e = arguments[n]) && (o = _(e)) && (t && (t += " "), t += o);
16
- return t;
14
+ function H() {
15
+ for (var e, n, s = 0, r = "", l = arguments.length; s < l; s++) (e = arguments[s]) && (n = Q(e)) && (r && (r += " "), r += n);
16
+ return r;
17
17
  }
18
- const B = X.forwardRef(
19
- ({ src: e, hlsConfig: o, isHls: n, autoPlay: t, children: l, ...f }, d) => {
20
- const a = H(null), c = H(null);
21
- q(d, () => a.current);
22
- const y = globalThis.window !== void 0 && E.isSupported(), C = !!n || y && typeof e == "string" && e.endsWith(".m3u8");
23
- return G(() => {
24
- if (!e) return;
25
- const s = a.current;
26
- if (!s) return;
27
- const u = () => {
28
- t && s.play().catch(() => {
29
- });
30
- };
31
- for (c.current && (c.current.destroy(), c.current = null), s.pause(), s.removeAttribute("src"); s.firstChild; ) s.firstChild.remove();
32
- if (C) {
33
- const i = new E(o);
34
- c.current = i, i.attachMedia(s), i.loadSource(e), i.on(E.Events.MANIFEST_PARSED, u), i.on(E.Events.ERROR, (R, T) => {
35
- T.fatal && (i.destroy(), c.current = null);
36
- });
37
- } else
38
- s.src = e, s.load(), s.addEventListener("loadedmetadata", u, { once: !0 });
39
- return () => {
40
- for (s.removeEventListener("loadedmetadata", u), c.current && (c.current.destroy(), c.current = null), s.pause(), s.removeAttribute("src"); s.firstChild; ) s.firstChild.remove();
41
- s.load();
42
- };
43
- }, [e, C, o, t]), /* @__PURE__ */ r("video", { ref: a, ...f, children: l });
44
- }
45
- );
46
- B.displayName = "HLSPlayer";
47
- const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) => /* @__PURE__ */ m(
18
+ const K = "gvp-icon", L = (e) => e ? `${K} ${e}` : K, fe = ({ className: e }) => /* @__PURE__ */ v(
48
19
  "svg",
49
20
  {
50
- className: M(e),
21
+ className: L(e),
51
22
  width: "20",
52
23
  height: "20",
53
24
  viewBox: "0 0 24 24",
@@ -55,7 +26,7 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
55
26
  xmlns: "http://www.w3.org/2000/svg",
56
27
  "aria-hidden": "true",
57
28
  children: [
58
- /* @__PURE__ */ r(
29
+ /* @__PURE__ */ t(
59
30
  "path",
60
31
  {
61
32
  d: "M14 2H10C6.72077 2 5.08116 2 3.91891 2.81382C3.48891 3.1149 3.1149 3.48891 2.81382 3.91891C2 5.08116 2 6.72077 2 10C2 13.2792 2 14.9188 2.81382 16.0811C3.1149 16.5111 3.48891 16.8851 3.91891 17.1862C5.08116 18 6.72077 18 10 18H14C17.2792 18 18.9188 18 20.0811 17.1862C20.5111 16.8851 20.8851 16.5111 21.1862 16.0811C22 14.9188 22 13.2792 22 10C22 6.72077 22 5.08116 21.1862 3.91891C20.8851 3.48891 20.5111 3.1149 20.0811 2.81382C18.9188 2 17.2792 2 14 2Z",
@@ -64,7 +35,7 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
64
35
  strokeLinecap: "round"
65
36
  }
66
37
  ),
67
- /* @__PURE__ */ r(
38
+ /* @__PURE__ */ t(
68
39
  "path",
69
40
  {
70
41
  d: "M11 15H13",
@@ -74,7 +45,7 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
74
45
  strokeLinejoin: "round"
75
46
  }
76
47
  ),
77
- /* @__PURE__ */ r(
48
+ /* @__PURE__ */ t(
78
49
  "path",
79
50
  {
80
51
  d: "M14.5 22L14.1845 21.5811C13.4733 20.6369 13.2969 19.1944 13.7468 18M9.5 22L9.8155 21.5811C10.5267 20.6369 10.7031 19.1944 10.2532 18",
@@ -83,13 +54,13 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
83
54
  strokeLinecap: "round"
84
55
  }
85
56
  ),
86
- /* @__PURE__ */ r("path", { d: "M7 22H17", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
57
+ /* @__PURE__ */ t("path", { d: "M7 22H17", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
87
58
  ]
88
59
  }
89
- ), Q = ({ className: e }) => /* @__PURE__ */ m(
60
+ ), ge = ({ className: e }) => /* @__PURE__ */ v(
90
61
  "svg",
91
62
  {
92
- className: M(e),
63
+ className: L(e),
93
64
  width: "20",
94
65
  height: "20",
95
66
  viewBox: "0 0 24 24",
@@ -97,7 +68,7 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
97
68
  xmlns: "http://www.w3.org/2000/svg",
98
69
  "aria-hidden": "true",
99
70
  children: [
100
- /* @__PURE__ */ r(
71
+ /* @__PURE__ */ t(
101
72
  "path",
102
73
  {
103
74
  d: "M5 9C5 5.70017 5 4.05025 6.02513 3.02513C7.05025 2 8.70017 2 12 2C15.2998 2 16.9497 2 17.9749 3.02513C19 4.05025 19 5.70017 19 9V15C19 18.2998 19 19.9497 17.9749 20.9749C16.9497 22 15.2998 22 12 22C8.70017 22 7.05025 22 6.02513 20.9749C5 19.9497 5 18.2998 5 15V9Z",
@@ -106,7 +77,7 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
106
77
  strokeLinecap: "round"
107
78
  }
108
79
  ),
109
- /* @__PURE__ */ r(
80
+ /* @__PURE__ */ t(
110
81
  "path",
111
82
  {
112
83
  d: "M11 19H13",
@@ -116,7 +87,7 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
116
87
  strokeLinejoin: "round"
117
88
  }
118
89
  ),
119
- /* @__PURE__ */ r(
90
+ /* @__PURE__ */ t(
120
91
  "path",
121
92
  {
122
93
  d: "M9 2L9.089 2.53402C9.28188 3.69129 9.37832 4.26993 9.77519 4.62204C10.1892 4.98934 10.7761 5 12 5C13.2239 5 13.8108 4.98934 14.2248 4.62204C14.6217 4.26993 14.7181 3.69129 14.911 2.53402L15 2",
@@ -127,17 +98,17 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
127
98
  )
128
99
  ]
129
100
  }
130
- ), F = ({ className: e }) => /* @__PURE__ */ r(
101
+ ), ve = ({ className: e }) => /* @__PURE__ */ t(
131
102
  "svg",
132
103
  {
133
- className: M(e),
104
+ className: L(e),
134
105
  width: "14",
135
106
  height: "14",
136
107
  viewBox: "0 0 14 14",
137
108
  fill: "none",
138
109
  xmlns: "http://www.w3.org/2000/svg",
139
110
  "aria-hidden": "true",
140
- children: /* @__PURE__ */ r(
111
+ children: /* @__PURE__ */ t(
141
112
  "path",
142
113
  {
143
114
  d: "M6.94994 5.53594L12.1929 0.292938C12.5834 -0.0975275 13.2165 -0.0975279 13.6069 0.292938C13.9974 0.683403 13.9974 1.31647 13.6069 1.70694L8.36394 6.94994L13.6069 12.1929C13.9974 12.5834 13.9974 13.2165 13.6069 13.6069C13.2165 13.9974 12.5834 13.9974 12.1929 13.6069L6.94994 8.36394L1.70694 13.6069C1.31647 13.9974 0.683403 13.9974 0.292938 13.6069C-0.0975279 13.2165 -0.0975277 12.5834 0.292938 12.1929L5.53594 6.94994L0.292938 1.70694C-0.0975279 1.31647 -0.0975279 0.683403 0.292938 0.292938C0.683403 -0.0975279 1.31647 -0.0975277 1.70694 0.292938L6.94994 5.53594Z",
@@ -145,17 +116,17 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
145
116
  }
146
117
  )
147
118
  }
148
- ), ee = ({ className: e }) => /* @__PURE__ */ r(
119
+ ), ke = ({ className: e }) => /* @__PURE__ */ t(
149
120
  "svg",
150
121
  {
151
- className: M(e),
122
+ className: L(e),
152
123
  width: "22",
153
124
  height: "22",
154
125
  viewBox: "0 0 16 16",
155
126
  fill: "none",
156
127
  xmlns: "http://www.w3.org/2000/svg",
157
128
  "aria-hidden": "true",
158
- children: /* @__PURE__ */ r(
129
+ children: /* @__PURE__ */ t(
159
130
  "path",
160
131
  {
161
132
  d: "M5.3335 11.45V4.54997C5.3335 4.36108 5.40016 4.20275 5.5335 4.07497C5.66683 3.94719 5.82238 3.8833 6.00016 3.8833C6.05572 3.8833 6.11405 3.89163 6.17516 3.9083C6.23627 3.92497 6.29461 3.94997 6.35016 3.9833L11.7835 7.4333C11.8835 7.49997 11.9585 7.5833 12.0085 7.6833C12.0585 7.7833 12.0835 7.88886 12.0835 7.99997C12.0835 8.11108 12.0585 8.21663 12.0085 8.31663C11.9585 8.41663 11.8835 8.49997 11.7835 8.56663L6.35016 12.0166C6.29461 12.05 6.23627 12.075 6.17516 12.0916C6.11405 12.1083 6.05572 12.1166 6.00016 12.1166C5.82238 12.1166 5.66683 12.0527 5.5335 11.925C5.40016 11.7972 5.3335 11.6389 5.3335 11.45Z",
@@ -163,224 +134,1148 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
163
134
  }
164
135
  )
165
136
  }
137
+ ), we = ({ className: e }) => /* @__PURE__ */ v(
138
+ "svg",
139
+ {
140
+ className: L(e),
141
+ width: "16",
142
+ height: "16",
143
+ viewBox: "0 0 24 24",
144
+ fill: "none",
145
+ xmlns: "http://www.w3.org/2000/svg",
146
+ "aria-hidden": "true",
147
+ children: [
148
+ /* @__PURE__ */ t(
149
+ "path",
150
+ {
151
+ d: "M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",
152
+ stroke: "currentColor",
153
+ strokeWidth: "1.5",
154
+ strokeLinejoin: "round"
155
+ }
156
+ ),
157
+ /* @__PURE__ */ t(
158
+ "path",
159
+ {
160
+ d: "M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16M19 5.5C20.5 7 21.5 9.5 21.5 12C21.5 14.5 20.5 17 19 18.5",
161
+ stroke: "currentColor",
162
+ strokeWidth: "1.5",
163
+ strokeLinecap: "round"
164
+ }
165
+ )
166
+ ]
167
+ }
168
+ ), be = ({ className: e }) => /* @__PURE__ */ t(
169
+ "svg",
170
+ {
171
+ className: L(e),
172
+ width: "16",
173
+ height: "16",
174
+ viewBox: "0 0 24 24",
175
+ fill: "none",
176
+ xmlns: "http://www.w3.org/2000/svg",
177
+ "aria-hidden": "true",
178
+ children: /* @__PURE__ */ t(
179
+ "path",
180
+ {
181
+ d: "M7 5.5V18.5C7 19.2659 7.84856 19.7261 8.4899 19.3071L19.0801 12.4014C19.6644 12.0204 19.6644 11.9796 19.0801 11.5986L8.4899 4.69288C7.84856 4.27388 7 4.73408 7 5.5Z",
182
+ fill: "currentColor"
183
+ }
184
+ )
185
+ }
186
+ ), Ce = ({ className: e }) => /* @__PURE__ */ v(
187
+ "svg",
188
+ {
189
+ className: L(e),
190
+ width: "16",
191
+ height: "16",
192
+ viewBox: "0 0 24 24",
193
+ fill: "none",
194
+ xmlns: "http://www.w3.org/2000/svg",
195
+ "aria-hidden": "true",
196
+ children: [
197
+ /* @__PURE__ */ t("rect", { x: "6", y: "5", width: "4", height: "14", rx: "1", fill: "currentColor" }),
198
+ /* @__PURE__ */ t("rect", { x: "14", y: "5", width: "4", height: "14", rx: "1", fill: "currentColor" })
199
+ ]
200
+ }
201
+ ), Le = ({ className: e }) => /* @__PURE__ */ v(
202
+ "svg",
203
+ {
204
+ className: L(e),
205
+ width: "18",
206
+ height: "18",
207
+ viewBox: "0 0 24 24",
208
+ fill: "none",
209
+ xmlns: "http://www.w3.org/2000/svg",
210
+ "aria-hidden": "true",
211
+ children: [
212
+ /* @__PURE__ */ t(
213
+ "path",
214
+ {
215
+ d: "M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",
216
+ stroke: "currentColor",
217
+ strokeWidth: "1.5",
218
+ strokeLinejoin: "round"
219
+ }
220
+ ),
221
+ /* @__PURE__ */ t(
222
+ "path",
223
+ {
224
+ d: "M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16M19 5.5C20.5 7 21.5 9.5 21.5 12C21.5 14.5 20.5 17 19 18.5",
225
+ stroke: "currentColor",
226
+ strokeWidth: "1.5",
227
+ strokeLinecap: "round"
228
+ }
229
+ )
230
+ ]
231
+ }
232
+ ), Ee = ({ className: e }) => /* @__PURE__ */ v(
233
+ "svg",
234
+ {
235
+ className: L(e),
236
+ width: "18",
237
+ height: "18",
238
+ viewBox: "0 0 24 24",
239
+ fill: "none",
240
+ xmlns: "http://www.w3.org/2000/svg",
241
+ "aria-hidden": "true",
242
+ children: [
243
+ /* @__PURE__ */ t(
244
+ "path",
245
+ {
246
+ d: "M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",
247
+ stroke: "currentColor",
248
+ strokeWidth: "1.5",
249
+ strokeLinejoin: "round"
250
+ }
251
+ ),
252
+ /* @__PURE__ */ t(
253
+ "path",
254
+ {
255
+ d: "M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16",
256
+ stroke: "currentColor",
257
+ strokeWidth: "1.5",
258
+ strokeLinecap: "round"
259
+ }
260
+ )
261
+ ]
262
+ }
263
+ ), ye = ({ className: e }) => /* @__PURE__ */ v(
264
+ "svg",
265
+ {
266
+ className: L(e),
267
+ width: "18",
268
+ height: "18",
269
+ viewBox: "0 0 24 24",
270
+ fill: "none",
271
+ xmlns: "http://www.w3.org/2000/svg",
272
+ "aria-hidden": "true",
273
+ children: [
274
+ /* @__PURE__ */ t(
275
+ "path",
276
+ {
277
+ d: "M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",
278
+ stroke: "currentColor",
279
+ strokeWidth: "1.5",
280
+ strokeLinejoin: "round"
281
+ }
282
+ ),
283
+ /* @__PURE__ */ t(
284
+ "path",
285
+ {
286
+ d: "M16 9L22 15M22 9L16 15",
287
+ stroke: "currentColor",
288
+ strokeWidth: "1.5",
289
+ strokeLinecap: "round"
290
+ }
291
+ )
292
+ ]
293
+ }
294
+ ), xe = ({ className: e }) => /* @__PURE__ */ t(
295
+ "svg",
296
+ {
297
+ className: L(e),
298
+ width: "18",
299
+ height: "18",
300
+ viewBox: "0 0 24 24",
301
+ fill: "none",
302
+ xmlns: "http://www.w3.org/2000/svg",
303
+ "aria-hidden": "true",
304
+ children: /* @__PURE__ */ t(
305
+ "path",
306
+ {
307
+ d: "M4 9V4H9M15 4H20V9M20 15V20H15M9 20H4V15",
308
+ stroke: "currentColor",
309
+ strokeWidth: "1.75",
310
+ strokeLinecap: "round",
311
+ strokeLinejoin: "round"
312
+ }
313
+ )
314
+ }
315
+ ), Ne = ({ className: e }) => /* @__PURE__ */ t(
316
+ "svg",
317
+ {
318
+ className: L(e),
319
+ width: "18",
320
+ height: "18",
321
+ viewBox: "0 0 24 24",
322
+ fill: "none",
323
+ xmlns: "http://www.w3.org/2000/svg",
324
+ "aria-hidden": "true",
325
+ children: /* @__PURE__ */ t(
326
+ "path",
327
+ {
328
+ d: "M9 4V9H4M15 9V4H20M15 20V15H20M9 15H4V20",
329
+ stroke: "currentColor",
330
+ strokeWidth: "1.75",
331
+ strokeLinecap: "round",
332
+ strokeLinejoin: "round"
333
+ }
334
+ )
335
+ }
336
+ ), Me = ({ className: e }) => /* @__PURE__ */ v(
337
+ "svg",
338
+ {
339
+ className: L(e),
340
+ width: "18",
341
+ height: "18",
342
+ viewBox: "0 0 24 24",
343
+ fill: "none",
344
+ xmlns: "http://www.w3.org/2000/svg",
345
+ "aria-hidden": "true",
346
+ children: [
347
+ /* @__PURE__ */ t("rect", { x: "2", y: "4", width: "20", height: "16", rx: "2", stroke: "currentColor", strokeWidth: "1.5" }),
348
+ /* @__PURE__ */ t("rect", { x: "12", y: "12", width: "8", height: "5", rx: "1", fill: "currentColor" })
349
+ ]
350
+ }
351
+ ), Pe = ({ className: e }) => /* @__PURE__ */ v(
352
+ "svg",
353
+ {
354
+ className: L(e),
355
+ width: "18",
356
+ height: "18",
357
+ viewBox: "0 0 24 24",
358
+ fill: "none",
359
+ xmlns: "http://www.w3.org/2000/svg",
360
+ "aria-hidden": "true",
361
+ children: [
362
+ /* @__PURE__ */ t("rect", { x: "2", y: "5", width: "20", height: "14", rx: "3", stroke: "currentColor", strokeWidth: "1.5" }),
363
+ /* @__PURE__ */ t("path", { d: "M7 12H11M13 12H17M7 15H9M11 15H13M15 15H17", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
364
+ ]
365
+ }
366
+ ), Te = ({ className: e }) => /* @__PURE__ */ v(
367
+ "svg",
368
+ {
369
+ className: L(e),
370
+ width: "16",
371
+ height: "16",
372
+ viewBox: "0 0 24 24",
373
+ fill: "none",
374
+ xmlns: "http://www.w3.org/2000/svg",
375
+ "aria-hidden": "true",
376
+ children: [
377
+ /* @__PURE__ */ t(
378
+ "path",
379
+ {
380
+ d: "M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2Z",
381
+ stroke: "currentColor",
382
+ strokeWidth: "1.5"
383
+ }
384
+ ),
385
+ /* @__PURE__ */ t(
386
+ "path",
387
+ {
388
+ d: "M12 8V12L14.5 14.5",
389
+ stroke: "currentColor",
390
+ strokeWidth: "1.5",
391
+ strokeLinecap: "round",
392
+ strokeLinejoin: "round"
393
+ }
394
+ )
395
+ ]
396
+ }
397
+ ), Ie = ({ className: e }) => /* @__PURE__ */ t(
398
+ "svg",
399
+ {
400
+ className: L(e),
401
+ width: "12",
402
+ height: "12",
403
+ viewBox: "0 0 24 24",
404
+ fill: "none",
405
+ xmlns: "http://www.w3.org/2000/svg",
406
+ "aria-hidden": "true",
407
+ children: /* @__PURE__ */ t(
408
+ "path",
409
+ {
410
+ d: "M6 9L12 15L18 9",
411
+ stroke: "currentColor",
412
+ strokeWidth: "2",
413
+ strokeLinecap: "round",
414
+ strokeLinejoin: "round"
415
+ }
416
+ )
417
+ }
418
+ );
419
+ function J(e) {
420
+ if (!Number.isFinite(e) || e < 0) return "--:--";
421
+ const n = Math.floor(e), s = Math.floor(n / 3600), r = Math.floor(n % 3600 / 60), u = (n % 60).toString().padStart(2, "0");
422
+ if (s > 0) {
423
+ const c = r.toString().padStart(2, "0");
424
+ return `${s}:${c}:${u}`;
425
+ }
426
+ return `${r}:${u}`;
427
+ }
428
+ const X = (() => {
429
+ if (typeof navigator > "u") return !1;
430
+ const e = navigator.userAgent;
431
+ return /iPad|iPhone|iPod/.test(e) || e.includes("Mac") && navigator.maxTouchPoints > 1;
432
+ })(), q = typeof navigator > "u" ? !1 : /iPhone|iPod/.test(navigator.userAgent), Se = 3e3, B = {
433
+ isSupported() {
434
+ return typeof document > "u" ? !1 : !!(document.fullscreenEnabled || document.webkitFullscreenEnabled);
435
+ },
436
+ element() {
437
+ return typeof document > "u" ? null : document.fullscreenElement ?? document.webkitFullscreenElement ?? null;
438
+ },
439
+ request(e) {
440
+ const n = e.requestFullscreen ?? e.webkitRequestFullscreen;
441
+ return n ? n.call(e) : Promise.reject(new Error("Fullscreen not supported"));
442
+ },
443
+ exit() {
444
+ const e = document.exitFullscreen ?? document.webkitExitFullscreen;
445
+ return e ? e.call(document) : Promise.reject(new Error("Fullscreen not supported"));
446
+ },
447
+ onChange(e) {
448
+ return document.addEventListener("fullscreenchange", e), document.addEventListener("webkitfullscreenchange", e), () => {
449
+ document.removeEventListener("fullscreenchange", e), document.removeEventListener("webkitfullscreenchange", e);
450
+ };
451
+ }
452
+ }, He = ({
453
+ video: e,
454
+ isPlaying: n,
455
+ container: s,
456
+ onTogglePlay: r
457
+ }) => {
458
+ const [l, u] = k(!0), c = V(null), a = S(() => {
459
+ c.current !== null && (clearTimeout(c.current), c.current = null);
460
+ }, []), i = S(() => {
461
+ a(), n && (c.current = setTimeout(() => u(!1), Se));
462
+ }, [a, n]), m = S(() => {
463
+ u(!0), i();
464
+ }, [i]);
465
+ return x(() => {
466
+ if (!n) {
467
+ a(), u(!0);
468
+ return;
469
+ }
470
+ return i(), a;
471
+ }, [n, i, a]), x(() => {
472
+ if (!s) return;
473
+ const f = () => m();
474
+ return s.addEventListener("mousemove", f), s.addEventListener("touchstart", f), s.addEventListener("focusin", f), () => {
475
+ s.removeEventListener("mousemove", f), s.removeEventListener("touchstart", f), s.removeEventListener("focusin", f);
476
+ };
477
+ }, [s, m]), x(() => {
478
+ if (!s || !e) return;
479
+ const f = (o) => {
480
+ if (!(!s.contains(document.activeElement) || o.target.tagName === "INPUT" && o.key !== " "))
481
+ switch (o.key) {
482
+ case " ":
483
+ case "k":
484
+ o.preventDefault(), r(), m();
485
+ break;
486
+ case "ArrowLeft":
487
+ o.preventDefault(), e.currentTime = Math.max(0, e.currentTime - 5), m();
488
+ break;
489
+ case "ArrowRight":
490
+ o.preventDefault(), e.currentTime = Math.min(e.duration || 0, e.currentTime + 5), m();
491
+ break;
492
+ case "ArrowUp":
493
+ o.preventDefault(), e.volume = Math.min(1, e.volume + 0.1), e.muted && (e.muted = !1), m();
494
+ break;
495
+ case "ArrowDown":
496
+ o.preventDefault(), e.volume = Math.max(0, e.volume - 0.1), m();
497
+ break;
498
+ case "m":
499
+ e.muted = !e.muted, m();
500
+ break;
501
+ case "f":
502
+ B.element() === s ? B.exit().catch(() => {
503
+ }) : B.request(s).catch(() => {
504
+ }), m();
505
+ break;
506
+ case "p":
507
+ document.pictureInPictureElement ? document.exitPictureInPicture().catch(() => {
508
+ }) : document.pictureInPictureEnabled && e.requestPictureInPicture().catch(() => {
509
+ }), m();
510
+ break;
511
+ }
512
+ };
513
+ return document.addEventListener("keydown", f), () => document.removeEventListener("keydown", f);
514
+ }, [s, e, r, m]), /* @__PURE__ */ t(
515
+ "div",
516
+ {
517
+ role: "toolbar",
518
+ "aria-label": "Video controls",
519
+ className: H("gvp-controls", !l && "is-hidden"),
520
+ onMouseEnter: a,
521
+ onMouseLeave: i,
522
+ children: /* @__PURE__ */ v("div", { className: "gvp-controls-row", children: [
523
+ /* @__PURE__ */ t(Ve, { isPlaying: n, onToggle: r }),
524
+ /* @__PURE__ */ t(Be, { video: e }),
525
+ /* @__PURE__ */ t(De, { video: e }),
526
+ /* @__PURE__ */ t(Re, { video: e }),
527
+ /* @__PURE__ */ t(We, { video: e }),
528
+ /* @__PURE__ */ t(Ae, { video: e }),
529
+ /* @__PURE__ */ t(je, { video: e }),
530
+ /* @__PURE__ */ t(Ze, { container: s, video: e })
531
+ ] })
532
+ }
533
+ );
534
+ }, Ve = ({
535
+ isPlaying: e,
536
+ onToggle: n
537
+ }) => /* @__PURE__ */ t(
538
+ "button",
539
+ {
540
+ type: "button",
541
+ className: "gvp-ctrl-btn",
542
+ "aria-label": e ? "Pause" : "Play",
543
+ "aria-pressed": e,
544
+ onClick: n,
545
+ children: e ? /* @__PURE__ */ t(Ce, {}) : /* @__PURE__ */ t(be, {})
546
+ }
547
+ ), Be = ({ video: e }) => {
548
+ const [n, s] = k(0), [r, l] = k(0), [u, c] = k(0);
549
+ x(() => {
550
+ if (!e) return;
551
+ const o = () => s(e.currentTime), h = () => l(Number.isFinite(e.duration) ? e.duration : 0), g = () => {
552
+ const d = e.buffered;
553
+ if (!d || d.length === 0) {
554
+ c(0);
555
+ return;
556
+ }
557
+ let w = d.end(d.length - 1);
558
+ for (let C = 0; C < d.length; C++)
559
+ if (d.start(C) <= e.currentTime && e.currentTime <= d.end(C)) {
560
+ w = d.end(C);
561
+ break;
562
+ }
563
+ c(w);
564
+ };
565
+ return o(), h(), g(), e.addEventListener("timeupdate", o), e.addEventListener("durationchange", h), e.addEventListener("loadedmetadata", h), e.addEventListener("progress", g), e.addEventListener("timeupdate", g), () => {
566
+ e.removeEventListener("timeupdate", o), e.removeEventListener("durationchange", h), e.removeEventListener("loadedmetadata", h), e.removeEventListener("progress", g), e.removeEventListener("timeupdate", g);
567
+ };
568
+ }, [e]);
569
+ const a = r > 0, i = a ? n / r * 100 : 0, m = a ? u / r * 100 : 0, f = (o) => {
570
+ if (!e || !a) return;
571
+ const h = Number(o.target.value) / 100 * r;
572
+ e.currentTime = h, s(h);
573
+ };
574
+ return /* @__PURE__ */ v("div", { className: "gvp-seek", children: [
575
+ /* @__PURE__ */ v("div", { className: "gvp-seek-track", children: [
576
+ /* @__PURE__ */ t(
577
+ "div",
578
+ {
579
+ className: "gvp-seek-buffered",
580
+ style: { width: `${m}%` }
581
+ }
582
+ ),
583
+ /* @__PURE__ */ t(
584
+ "div",
585
+ {
586
+ className: "gvp-seek-progress",
587
+ style: { width: `${i}%` }
588
+ }
589
+ )
590
+ ] }),
591
+ /* @__PURE__ */ t(
592
+ "input",
593
+ {
594
+ type: "range",
595
+ className: "gvp-seek-input",
596
+ min: 0,
597
+ max: 100,
598
+ step: 0.1,
599
+ value: i,
600
+ onChange: f,
601
+ disabled: !a,
602
+ "aria-label": "Seek",
603
+ "aria-valuemin": 0,
604
+ "aria-valuemax": Math.floor(r),
605
+ "aria-valuenow": Math.floor(n)
606
+ }
607
+ )
608
+ ] });
609
+ }, De = ({ video: e }) => {
610
+ const [n, s] = k(0), [r, l] = k(0);
611
+ return x(() => {
612
+ if (!e) return;
613
+ const u = () => s(e.currentTime), c = () => l(Number.isFinite(e.duration) ? e.duration : 0);
614
+ return u(), c(), e.addEventListener("timeupdate", u), e.addEventListener("durationchange", c), e.addEventListener("loadedmetadata", c), () => {
615
+ e.removeEventListener("timeupdate", u), e.removeEventListener("durationchange", c), e.removeEventListener("loadedmetadata", c);
616
+ };
617
+ }, [e]), /* @__PURE__ */ v("span", { className: "gvp-time", "aria-live": "off", children: [
618
+ J(n),
619
+ " / ",
620
+ J(r)
621
+ ] });
622
+ }, Ae = ({ video: e }) => {
623
+ const [n, s] = k(1), [r, l] = k(!1);
624
+ x(() => {
625
+ if (!e) return;
626
+ const m = () => {
627
+ s(e.volume), l(e.muted);
628
+ };
629
+ return m(), e.addEventListener("volumechange", m), () => e.removeEventListener("volumechange", m);
630
+ }, [e]);
631
+ const u = () => {
632
+ e && (e.muted = !e.muted);
633
+ }, c = (m) => {
634
+ if (!e) return;
635
+ const f = Number(m.target.value) / 100;
636
+ e.volume = f, f > 0 && e.muted && (e.muted = !1);
637
+ };
638
+ let a = Le;
639
+ r || n === 0 ? a = ye : n < 0.5 && (a = Ee);
640
+ const i = r ? 0 : Math.round(n * 100);
641
+ return /* @__PURE__ */ v("div", { className: H("gvp-volume", !X && "is-expandable"), children: [
642
+ /* @__PURE__ */ t(
643
+ "button",
644
+ {
645
+ type: "button",
646
+ className: "gvp-ctrl-btn",
647
+ "aria-label": r ? "Unmute" : "Mute",
648
+ "aria-pressed": r,
649
+ onClick: u,
650
+ children: /* @__PURE__ */ t(a, {})
651
+ }
652
+ ),
653
+ !X && /* @__PURE__ */ v("div", { className: "gvp-volume-slider-wrap", children: [
654
+ /* @__PURE__ */ t("div", { className: "gvp-volume-track", children: /* @__PURE__ */ t(
655
+ "div",
656
+ {
657
+ className: "gvp-volume-fill",
658
+ style: { width: `${i}%` }
659
+ }
660
+ ) }),
661
+ /* @__PURE__ */ t(
662
+ "input",
663
+ {
664
+ type: "range",
665
+ className: "gvp-volume-input",
666
+ min: 0,
667
+ max: 100,
668
+ step: 1,
669
+ value: i,
670
+ onChange: c,
671
+ "aria-label": "Volume",
672
+ "aria-valuemin": 0,
673
+ "aria-valuemax": 100,
674
+ "aria-valuenow": i
675
+ }
676
+ )
677
+ ] })
678
+ ] });
679
+ }, $e = [0.5, 0.75, 1, 1.25, 1.5, 2], Re = ({ video: e }) => {
680
+ const [n, s] = k(1), [r, l] = k(!1), u = V(null);
681
+ x(() => {
682
+ if (!e) return;
683
+ const i = () => s(e.playbackRate);
684
+ return i(), e.addEventListener("ratechange", i), () => e.removeEventListener("ratechange", i);
685
+ }, [e]), x(() => {
686
+ if (!r) return;
687
+ const i = (f) => {
688
+ u.current && !u.current.contains(f.target) && l(!1);
689
+ }, m = (f) => {
690
+ f.key === "Escape" && l(!1);
691
+ };
692
+ return document.addEventListener("mousedown", i), document.addEventListener("keydown", m), () => {
693
+ document.removeEventListener("mousedown", i), document.removeEventListener("keydown", m);
694
+ };
695
+ }, [r]);
696
+ const c = (i) => {
697
+ e && (e.playbackRate = i), s(i), l(!1);
698
+ }, a = n === 1 ? "1×" : `${n}×`;
699
+ return /* @__PURE__ */ v("div", { className: "gvp-speed", ref: u, children: [
700
+ /* @__PURE__ */ v(
701
+ "button",
702
+ {
703
+ type: "button",
704
+ className: "gvp-ctrl-btn gvp-speed-btn",
705
+ "aria-haspopup": "listbox",
706
+ "aria-expanded": r,
707
+ "aria-label": `Playback speed: ${a}`,
708
+ onClick: () => l((i) => !i),
709
+ children: [
710
+ /* @__PURE__ */ t(Te, {}),
711
+ /* @__PURE__ */ t("span", { className: "gvp-speed-label", children: a })
712
+ ]
713
+ }
714
+ ),
715
+ r && // NOSONAR: typescript:S6819
716
+ /* @__PURE__ */ t("ul", { className: "gvp-speed-menu", role: "listbox", "aria-label": "Playback speed", children: $e.map((i) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
717
+ "button",
718
+ {
719
+ type: "button",
720
+ role: "option",
721
+ "aria-selected": i === n,
722
+ className: H("gvp-speed-menu-item", i === n && "is-active"),
723
+ onClick: () => c(i),
724
+ children: i === 1 ? "Normal" : `${i}×`
725
+ }
726
+ ) }, i)) })
727
+ ] });
728
+ }, We = ({ video: e }) => {
729
+ const [n, s] = k([]), [r, l] = k(-1), [u, c] = k(!1), a = V(null), i = S((o) => {
730
+ const h = [];
731
+ for (let d = 0; d < o.length; d++) {
732
+ const w = o[d];
733
+ (w.kind === "subtitles" || w.kind === "captions") && h.push({ index: d, label: w.label || w.language || `Track ${d + 1}`, language: w.language });
734
+ }
735
+ s(h);
736
+ let g = -1;
737
+ for (let d = 0; d < o.length; d++)
738
+ if (o[d].mode === "showing") {
739
+ g = d;
740
+ break;
741
+ }
742
+ l(g);
743
+ }, []);
744
+ x(() => {
745
+ if (!e) {
746
+ s([]), l(-1);
747
+ return;
748
+ }
749
+ const o = e.textTracks;
750
+ i(o);
751
+ const h = () => i(o);
752
+ if (typeof o.addEventListener == "function")
753
+ return o.addEventListener("addtrack", h), o.addEventListener("removetrack", h), o.addEventListener("change", h), () => {
754
+ o.removeEventListener("addtrack", h), o.removeEventListener("removetrack", h), o.removeEventListener("change", h);
755
+ };
756
+ }, [e, i]), x(() => {
757
+ if (!u) return;
758
+ const o = (g) => {
759
+ a.current && !a.current.contains(g.target) && c(!1);
760
+ }, h = (g) => {
761
+ g.key === "Escape" && c(!1);
762
+ };
763
+ return document.addEventListener("mousedown", o), document.addEventListener("keydown", h), () => {
764
+ document.removeEventListener("mousedown", o), document.removeEventListener("keydown", h);
765
+ };
766
+ }, [u]);
767
+ const m = (o) => {
768
+ if (!e) return;
769
+ const h = e.textTracks;
770
+ for (let g = 0; g < h.length; g++)
771
+ h[g].mode = g === o ? "showing" : "hidden";
772
+ l(o), c(!1);
773
+ }, f = () => {
774
+ if (!e) return;
775
+ const o = e.textTracks;
776
+ for (let h = 0; h < o.length; h++) o[h].mode = "hidden";
777
+ l(-1), c(!1);
778
+ };
779
+ return n.length === 0 ? null : /* @__PURE__ */ v("div", { className: "gvp-captions", ref: a, children: [
780
+ /* @__PURE__ */ t(
781
+ "button",
782
+ {
783
+ type: "button",
784
+ className: H("gvp-ctrl-btn", r >= 0 && "is-active"),
785
+ "aria-haspopup": "listbox",
786
+ "aria-expanded": u,
787
+ "aria-label": "Captions",
788
+ "aria-pressed": r >= 0,
789
+ onClick: () => c((o) => !o),
790
+ children: /* @__PURE__ */ t(Pe, {})
791
+ }
792
+ ),
793
+ u && // NOSONAR: typescript:S6819
794
+ /* @__PURE__ */ v("ul", { className: "gvp-captions-menu", role: "listbox", "aria-label": "Captions", children: [
795
+ /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
796
+ "button",
797
+ {
798
+ type: "button",
799
+ role: "option",
800
+ "aria-selected": r === -1,
801
+ className: H("gvp-captions-menu-item", r === -1 && "is-active"),
802
+ onClick: f,
803
+ children: "Off"
804
+ }
805
+ ) }),
806
+ n.map((o) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
807
+ "button",
808
+ {
809
+ type: "button",
810
+ role: "option",
811
+ "aria-selected": o.index === r,
812
+ className: H("gvp-captions-menu-item", o.index === r && "is-active"),
813
+ onClick: () => m(o.index),
814
+ children: o.label
815
+ }
816
+ ) }, o.index))
817
+ ] })
818
+ ] });
819
+ }, je = ({ video: e }) => {
820
+ const [n, s] = k(!1);
821
+ if (x(() => {
822
+ if (!e) return;
823
+ const l = () => s(!0), u = () => s(!1);
824
+ return e.addEventListener("enterpictureinpicture", l), e.addEventListener("leavepictureinpicture", u), () => {
825
+ e.removeEventListener("enterpictureinpicture", l), e.removeEventListener("leavepictureinpicture", u);
826
+ };
827
+ }, [e]), !document.pictureInPictureEnabled) return null;
828
+ const r = () => {
829
+ document.pictureInPictureElement ? document.exitPictureInPicture().catch(() => {
830
+ }) : e == null || e.requestPictureInPicture().catch(() => {
831
+ });
832
+ };
833
+ return /* @__PURE__ */ t(
834
+ "button",
835
+ {
836
+ type: "button",
837
+ className: H("gvp-ctrl-btn", n && "is-active"),
838
+ "aria-label": n ? "Exit picture-in-picture" : "Picture-in-picture",
839
+ "aria-pressed": n,
840
+ onClick: r,
841
+ children: /* @__PURE__ */ t(Me, {})
842
+ }
843
+ );
844
+ }, Ze = ({ container: e, video: n }) => {
845
+ const [s, r] = k(!1);
846
+ return x(() => {
847
+ if (q) return;
848
+ const i = () => r(B.element() === e);
849
+ return i(), B.onChange(i);
850
+ }, [e]), B.isSupported() || q && n !== null && typeof n.webkitEnterFullscreen == "function" ? /* @__PURE__ */ t(
851
+ "button",
852
+ {
853
+ type: "button",
854
+ className: "gvp-ctrl-btn",
855
+ "aria-label": s ? "Exit fullscreen" : "Enter fullscreen",
856
+ "aria-pressed": s,
857
+ onClick: () => {
858
+ var i;
859
+ if (q) {
860
+ (i = n == null ? void 0 : n.webkitEnterFullscreen) == null || i.call(n);
861
+ return;
862
+ }
863
+ s ? B.exit().catch(() => {
864
+ }) : e && B.request(e).catch(() => {
865
+ });
866
+ },
867
+ children: /* @__PURE__ */ t(s ? Ne : xe, {})
868
+ }
869
+ ) : null;
870
+ };
871
+ function G(e, n, s) {
872
+ const r = e == null ? void 0 : e.trim();
873
+ if (r) return r;
874
+ if (n) {
875
+ try {
876
+ const u = new Intl.DisplayNames(void 0, { type: "language" }).of(n);
877
+ if (u && u !== n) return u;
878
+ } catch {
879
+ }
880
+ return n;
881
+ }
882
+ return `Audio ${s + 1}`;
883
+ }
884
+ const ee = he.forwardRef(
885
+ ({
886
+ src: e,
887
+ hlsConfig: n,
888
+ isHls: s,
889
+ autoPlay: r,
890
+ children: l,
891
+ onAudioTracks: u,
892
+ audioTrackIndex: c,
893
+ ...a
894
+ }, i) => {
895
+ const m = V(null), f = V(null), o = V(u);
896
+ o.current = u, me(i, () => m.current);
897
+ const h = globalThis.window !== void 0 && $.isSupported(), g = !!s || h && typeof e == "string" && e.endsWith(".m3u8");
898
+ return x(() => {
899
+ var P, R, D;
900
+ if (!e) return;
901
+ const d = m.current;
902
+ if (!d) return;
903
+ const w = (p) => {
904
+ var E;
905
+ (E = o.current) == null || E.call(o, p);
906
+ }, C = () => {
907
+ r && d.play().catch(() => {
908
+ });
909
+ };
910
+ for (f.current && (f.current.destroy(), f.current = null), d.pause(), d.removeAttribute("src"); d.firstChild; ) d.firstChild.remove();
911
+ w([]);
912
+ let N;
913
+ if (g) {
914
+ const p = new $(n);
915
+ f.current = p;
916
+ const E = () => {
917
+ const M = p.audioTracks.map((b, T) => ({
918
+ index: T,
919
+ label: G(b.name, b.lang, T),
920
+ lang: b.lang || void 0
921
+ }));
922
+ w(M);
923
+ };
924
+ p.on($.Events.MANIFEST_PARSED, C), p.on($.Events.AUDIO_TRACKS_UPDATED, E), p.on($.Events.AUDIO_TRACK_SWITCHED, E), p.on($.Events.ERROR, (M, b) => {
925
+ b.fatal && (p.destroy(), f.current = null);
926
+ }), p.attachMedia(d), p.loadSource(e);
927
+ } else {
928
+ d.src = e, d.load(), d.addEventListener("loadedmetadata", C, { once: !0 });
929
+ const p = d.audioTracks;
930
+ if (p) {
931
+ const E = () => {
932
+ const M = [];
933
+ for (let b = 0; b < p.length; b++) {
934
+ const T = p[b];
935
+ M.push({
936
+ index: b,
937
+ label: G(T.label, T.language, b),
938
+ lang: T.language || void 0
939
+ });
940
+ }
941
+ w(M);
942
+ };
943
+ (P = p.addEventListener) == null || P.call(p, "addtrack", E), (R = p.addEventListener) == null || R.call(p, "removetrack", E), (D = p.addEventListener) == null || D.call(p, "change", E), p.length > 0 && E(), N = () => {
944
+ var M, b, T;
945
+ (M = p.removeEventListener) == null || M.call(p, "addtrack", E), (b = p.removeEventListener) == null || b.call(p, "removetrack", E), (T = p.removeEventListener) == null || T.call(p, "change", E);
946
+ };
947
+ }
948
+ }
949
+ return () => {
950
+ for (d.removeEventListener("loadedmetadata", C), N == null || N(), f.current && (f.current.destroy(), f.current = null), d.pause(), d.removeAttribute("src"); d.firstChild; ) d.firstChild.remove();
951
+ d.load(), w([]);
952
+ };
953
+ }, [e, g, n, r]), x(() => {
954
+ var C;
955
+ if (c == null || c < 0) return;
956
+ const d = f.current;
957
+ if (d) {
958
+ d.audioTrack !== c && (d.audioTrack = c);
959
+ return;
960
+ }
961
+ const w = (C = m.current) == null ? void 0 : C.audioTracks;
962
+ if (w)
963
+ for (let N = 0; N < w.length; N++)
964
+ w[N].enabled = N === c;
965
+ }, [c]), // Captions are the consumer's responsibility — pass <track> elements as children.
966
+ // NOSONAR: typescript:S4084
967
+ /* @__PURE__ */ t("video", { ref: m, ...a, children: l });
968
+ }
166
969
  );
167
- function te(e) {
970
+ ee.displayName = "HLSPlayer";
971
+ function Ue(e) {
168
972
  if (!e) return null;
169
973
  if (/^[A-Za-z0-9_-]{11}$/.test(e)) return e;
170
- let o;
974
+ let n;
171
975
  try {
172
- o = new URL(e);
976
+ n = new URL(e);
173
977
  } catch {
174
978
  return null;
175
979
  }
176
- const n = o.hostname.replace(/^www\./, "");
177
- if (n === "youtu.be") {
178
- const t = o.pathname.slice(1).split("/")[0];
179
- return /^[A-Za-z0-9_-]{11}$/.test(t) ? t : null;
980
+ const s = n.hostname.replace(/^www\./, "");
981
+ if (s === "youtu.be") {
982
+ const r = n.pathname.slice(1).split("/")[0];
983
+ return /^[A-Za-z0-9_-]{11}$/.test(r) ? r : null;
180
984
  }
181
- if (n === "youtube.com" || n === "m.youtube.com" || n === "music.youtube.com" || n === "youtube-nocookie.com") {
182
- const t = o.searchParams.get("v");
183
- if (t && /^[A-Za-z0-9_-]{11}$/.test(t)) return t;
985
+ if (s === "youtube.com" || s === "m.youtube.com" || s === "music.youtube.com" || s === "youtube-nocookie.com") {
986
+ const r = n.searchParams.get("v");
987
+ if (r && /^[A-Za-z0-9_-]{11}$/.test(r)) return r;
184
988
  const l = /^\/(?:embed|shorts|v|live)\/([A-Za-z0-9_-]{11})/.exec(
185
- o.pathname
989
+ n.pathname
186
990
  );
187
991
  if (l) return l[1];
188
992
  }
189
993
  return null;
190
994
  }
191
- function re(e) {
995
+ function _e(e) {
192
996
  try {
193
- const o = new URL(e), n = o.searchParams.get("t") ?? o.searchParams.get("start");
194
- if (!n) return null;
195
- if (/^\d+s?$/.test(n)) return Number.parseInt(n, 10);
196
- const t = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(n);
197
- if (t) {
198
- const l = Number.parseInt(t[1] ?? "0", 10), f = Number.parseInt(t[2] ?? "0", 10), d = Number.parseInt(t[3] ?? "0", 10), a = l * 3600 + f * 60 + d;
997
+ const n = new URL(e), s = n.searchParams.get("t") ?? n.searchParams.get("start");
998
+ if (!s) return null;
999
+ if (/^\d+s?$/.test(s)) return Number.parseInt(s, 10);
1000
+ const r = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(s);
1001
+ if (r) {
1002
+ const l = Number.parseInt(r[1] ?? "0", 10), u = Number.parseInt(r[2] ?? "0", 10), c = Number.parseInt(r[3] ?? "0", 10), a = l * 3600 + u * 60 + c;
199
1003
  return a > 0 ? a : null;
200
1004
  }
201
1005
  } catch {
202
1006
  }
203
1007
  return null;
204
1008
  }
205
- function ne(e, o = {}) {
206
- const { autoPlay: n = !1, muted: t = !0, loop: l = !1, controls: f = !0, startSeconds: d } = o, a = new URLSearchParams({
1009
+ function Oe(e, n = {}) {
1010
+ const { autoPlay: s = !1, muted: r = !0, loop: l = !1, controls: u = !0, startSeconds: c } = n, a = new URLSearchParams({
207
1011
  rel: "0",
208
1012
  modestbranding: "1",
209
1013
  playsinline: "1",
210
- controls: f ? "1" : "0"
1014
+ controls: u ? "1" : "0"
211
1015
  });
212
- return n ? (a.set("autoplay", "1"), a.set("mute", "1")) : t && a.set("mute", "1"), l && (a.set("loop", "1"), a.set("playlist", e)), d && d > 0 && a.set("start", String(d)), `https://www.youtube-nocookie.com/embed/${e}?${a.toString()}`;
1016
+ return s ? (a.set("autoplay", "1"), a.set("mute", "1")) : r && a.set("mute", "1"), l && (a.set("loop", "1"), a.set("playlist", e)), c && c > 0 && a.set("start", String(c)), `https://www.youtube-nocookie.com/embed/${e}?${a.toString()}`;
213
1017
  }
214
- const ae = ({
1018
+ const Fe = ({
1019
+ tracks: e,
1020
+ activeIndex: n,
1021
+ onSelect: s
1022
+ }) => {
1023
+ const [r, l] = k(!1), u = V(null);
1024
+ x(() => {
1025
+ if (!r) return;
1026
+ const a = (m) => {
1027
+ u.current && !u.current.contains(m.target) && l(!1);
1028
+ }, i = (m) => {
1029
+ m.key === "Escape" && l(!1);
1030
+ };
1031
+ return document.addEventListener("mousedown", a), document.addEventListener("keydown", i), () => {
1032
+ document.removeEventListener("mousedown", a), document.removeEventListener("keydown", i);
1033
+ };
1034
+ }, [r]);
1035
+ const c = e.find((a) => a.index === n) ?? e[0];
1036
+ return /* @__PURE__ */ v("div", { className: "gvp-audio", ref: u, children: [
1037
+ /* @__PURE__ */ v(
1038
+ "button",
1039
+ {
1040
+ type: "button",
1041
+ className: "gvp-audio-btn",
1042
+ "aria-haspopup": "listbox",
1043
+ "aria-expanded": r,
1044
+ "aria-label": "Audio track",
1045
+ onClick: () => l((a) => !a),
1046
+ children: [
1047
+ /* @__PURE__ */ t(we, {}),
1048
+ /* @__PURE__ */ t("span", { className: "gvp-audio-label", children: c == null ? void 0 : c.label }),
1049
+ /* @__PURE__ */ t(Ie, {})
1050
+ ]
1051
+ }
1052
+ ),
1053
+ r && // A native <select> can't be styled to sit inside the player overlay
1054
+ // (it renders the OS dropdown chrome), so this is a custom listbox with
1055
+ // full keyboard + ARIA support.
1056
+ // NOSONAR: typescript:S6819
1057
+ /* @__PURE__ */ t("ul", { className: "gvp-audio-menu", role: "listbox", "aria-label": "Audio tracks", children: e.map((a) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
1058
+ "button",
1059
+ {
1060
+ type: "button",
1061
+ role: "option",
1062
+ "aria-selected": a.index === n,
1063
+ className: H(
1064
+ "gvp-audio-menu-item",
1065
+ a.index === n && "is-active"
1066
+ ),
1067
+ onClick: () => {
1068
+ s(a.index), l(!1);
1069
+ },
1070
+ children: a.label
1071
+ }
1072
+ ) }, a.index)) })
1073
+ ] });
1074
+ }, Ke = ({
215
1075
  src: e,
216
- poster: o,
217
- showDeviceToggle: n = !0,
218
- defaultDevice: t = "desktop",
1076
+ poster: n,
1077
+ showDeviceToggle: s = !0,
1078
+ defaultDevice: r = "desktop",
219
1079
  hoverPlay: l = !1,
220
- tooltipText: f,
221
- onClose: d,
1080
+ tooltipText: u,
1081
+ onClose: c,
222
1082
  className: a = "",
223
- muted: c = !0,
224
- loop: y = !1,
225
- controls: C = !1,
226
- autoPlay: s = !1,
227
- frameMaxWidth: u,
228
- aspectRatio: i,
229
- hlsConfig: R,
230
- children: T
1083
+ muted: i = !0,
1084
+ loop: m = !1,
1085
+ controls: f = !0,
1086
+ autoPlay: o = !1,
1087
+ frameMaxWidth: h,
1088
+ aspectRatio: g,
1089
+ hlsConfig: d,
1090
+ children: w
231
1091
  }) => {
232
- const w = H(null), k = H(null), [h, j] = $(t), [V, g] = $(!1), [z, L] = $(!1), N = I(() => te(e), [e]), v = N !== null, D = I(() => h === "mobile" ? (i == null ? void 0 : i.mobile) ?? "9/16" : (i == null ? void 0 : i.desktop) ?? "16/9", [h, i]), Y = I(() => h === "mobile" ? (u == null ? void 0 : u.mobile) ?? "420px" : (u == null ? void 0 : u.desktop) ?? "960px", [h, u]), A = I(
233
- () => N ? ne(N, {
234
- autoPlay: s,
235
- muted: c,
236
- loop: y,
237
- controls: C,
238
- startSeconds: re(e)
1092
+ const C = V(null), N = V(null), [P, R] = k(r), [D, p] = k(!1), [E, M] = k(!1), [b, T] = k([]), [_, z] = k(-1), [te, ne] = k(null), [re, se] = k(null), oe = S((y) => {
1093
+ C.current = y, se(y);
1094
+ }, []), A = f === !0 || f === "custom", O = f === "native", W = U(() => Ue(e), [e]), I = W !== null, ae = U(() => P === "mobile" ? (g == null ? void 0 : g.mobile) ?? "9/16" : (g == null ? void 0 : g.desktop) ?? "16/9", [P, g]), ie = U(() => P === "mobile" ? (h == null ? void 0 : h.mobile) ?? "420px" : (h == null ? void 0 : h.desktop) ?? "960px", [P, h]), le = U(
1095
+ () => W ? Oe(W, {
1096
+ autoPlay: o,
1097
+ muted: i,
1098
+ loop: m,
1099
+ // Custom controls can't drive an iframe, so YouTube falls
1100
+ // back to its own controls in that mode.
1101
+ controls: A ? !0 : O,
1102
+ startSeconds: _e(e)
239
1103
  }) : null,
240
- [N, e, s, c, y, C]
241
- ), S = b(async () => {
242
- const p = w.current;
243
- if (p) {
244
- if (k.current)
1104
+ [W, e, o, i, m, A, O]
1105
+ ), ce = S((y) => {
1106
+ T(y), z(-1);
1107
+ }, []), j = S(async () => {
1108
+ const y = C.current;
1109
+ if (y) {
1110
+ if (N.current)
245
1111
  try {
246
- await k.current;
1112
+ await N.current;
247
1113
  } catch {
248
1114
  }
249
- p.pause();
1115
+ y.pause();
250
1116
  }
251
- }, []), P = b(async () => {
252
- const p = w.current;
253
- if (p)
1117
+ }, []), Z = S(async () => {
1118
+ const y = C.current;
1119
+ if (y)
254
1120
  try {
255
- p.readyState < 2 && p.load();
256
- const x = p.play();
257
- k.current = x, await x, g(!0);
1121
+ y.readyState < 2 && y.load();
1122
+ const Y = y.play();
1123
+ N.current = Y, await Y, p(!0);
258
1124
  } catch {
259
- g(!1);
1125
+ p(!1);
260
1126
  } finally {
261
- k.current = null;
1127
+ N.current = null;
262
1128
  }
263
- }, []), J = b(() => {
264
- !l || v || P();
265
- }, [l, v, P]), O = b(() => {
266
- !l || v || S().then(() => g(!1));
267
- }, [l, v, S]), W = b(async () => {
268
- const p = w.current;
269
- p && (p.paused ? await P() : (await S(), g(!1)));
270
- }, [P, S]);
1129
+ }, []), ue = S(() => {
1130
+ !l || I || Z();
1131
+ }, [l, I, Z]), de = S(() => {
1132
+ !l || I || j().then(() => p(!1));
1133
+ }, [l, I, j]), F = S(async () => {
1134
+ const y = C.current;
1135
+ y && (y.paused ? await Z() : (await j(), p(!1)));
1136
+ }, [Z, j]), pe = !I && b.length > 1;
271
1137
  return (
272
1138
  // The mouse handlers are a progressive enhancement (hoverPlay + tooltip).
273
1139
  // Keyboard/click users reach the same actions via the inner <button> elements,
274
1140
  // so the outer container is intentionally non-interactive at the role level.
275
1141
  // NOSONAR: typescript:S6848
276
- /* @__PURE__ */ m(
1142
+ /* @__PURE__ */ v(
277
1143
  "div",
278
1144
  {
279
- className: Z("gvp-root", a),
280
- style: { width: Y, aspectRatio: D },
1145
+ ref: ne,
1146
+ className: H("gvp-root", a),
1147
+ style: { width: ie, aspectRatio: ae },
281
1148
  onMouseEnter: () => {
282
- L(!0), J();
1149
+ M(!0), ue();
283
1150
  },
284
1151
  onMouseLeave: () => {
285
- L(!1), O();
1152
+ M(!1), de();
286
1153
  },
287
1154
  children: [
288
- v ? /* @__PURE__ */ r(
1155
+ I ? /* @__PURE__ */ t(
289
1156
  "iframe",
290
1157
  {
291
1158
  className: "gvp-video gvp-youtube",
292
- src: A ?? void 0,
1159
+ src: le ?? void 0,
293
1160
  title: "YouTube video player",
294
1161
  allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",
295
1162
  allowFullScreen: !0,
296
1163
  referrerPolicy: "strict-origin-when-cross-origin"
297
1164
  }
298
- ) : /* @__PURE__ */ r(
299
- B,
1165
+ ) : /* @__PURE__ */ t(
1166
+ ee,
300
1167
  {
301
- ref: w,
1168
+ ref: oe,
302
1169
  src: e,
303
- poster: o,
304
- muted: c,
305
- loop: y,
1170
+ poster: n,
1171
+ muted: i,
1172
+ loop: m,
306
1173
  playsInline: !0,
307
1174
  preload: "metadata",
308
- controls: C,
309
- autoPlay: s,
310
- hlsConfig: R,
1175
+ controls: O,
1176
+ autoPlay: o,
1177
+ hlsConfig: d,
311
1178
  className: "gvp-video",
312
- onPlay: () => g(!0),
313
- onPause: () => g(!1),
314
- children: T
1179
+ onPlay: () => p(!0),
1180
+ onPause: () => p(!1),
1181
+ onAudioTracks: ce,
1182
+ audioTrackIndex: _,
1183
+ children: w
315
1184
  }
316
1185
  ),
317
- !v && /* @__PURE__ */ r("div", { className: "gvp-vignette" }),
318
- n && /* @__PURE__ */ r("div", { className: "gvp-toggle", children: /* @__PURE__ */ m("div", { className: "gvp-toggle-pill", children: [
319
- /* @__PURE__ */ r(
1186
+ !I && /* @__PURE__ */ t("div", { className: "gvp-vignette" }),
1187
+ s && /* @__PURE__ */ t("div", { className: "gvp-toggle", children: /* @__PURE__ */ v("div", { className: "gvp-toggle-pill", children: [
1188
+ /* @__PURE__ */ t(
320
1189
  "button",
321
1190
  {
322
1191
  type: "button",
323
- onClick: () => j("desktop"),
324
- className: Z(
1192
+ onClick: () => R("desktop"),
1193
+ className: H(
325
1194
  "gvp-toggle-btn",
326
- h === "desktop" && "is-active"
1195
+ P === "desktop" && "is-active"
327
1196
  ),
328
1197
  "aria-label": "Desktop view",
329
- "aria-pressed": h === "desktop",
330
- children: /* @__PURE__ */ r(K, {})
1198
+ "aria-pressed": P === "desktop",
1199
+ children: /* @__PURE__ */ t(fe, {})
331
1200
  }
332
1201
  ),
333
- /* @__PURE__ */ r("div", { className: "gvp-toggle-divider" }),
334
- /* @__PURE__ */ r(
1202
+ /* @__PURE__ */ t("div", { className: "gvp-toggle-divider" }),
1203
+ /* @__PURE__ */ t(
335
1204
  "button",
336
1205
  {
337
1206
  type: "button",
338
- onClick: () => j("mobile"),
339
- className: Z(
1207
+ onClick: () => R("mobile"),
1208
+ className: H(
340
1209
  "gvp-toggle-btn",
341
- h === "mobile" && "is-active"
1210
+ P === "mobile" && "is-active"
342
1211
  ),
343
1212
  "aria-label": "Mobile view",
344
- "aria-pressed": h === "mobile",
345
- children: /* @__PURE__ */ r(Q, {})
1213
+ "aria-pressed": P === "mobile",
1214
+ children: /* @__PURE__ */ t(ge, {})
346
1215
  }
347
1216
  )
348
1217
  ] }) }),
349
- d && /* @__PURE__ */ r(
1218
+ c && /* @__PURE__ */ t(
350
1219
  "button",
351
1220
  {
352
1221
  type: "button",
353
- onClick: d,
1222
+ onClick: c,
354
1223
  className: "gvp-close",
355
1224
  "aria-label": "Close",
356
- children: /* @__PURE__ */ r(F, {})
1225
+ children: /* @__PURE__ */ t(ve, {})
1226
+ }
1227
+ ),
1228
+ pe && /* @__PURE__ */ t(
1229
+ Fe,
1230
+ {
1231
+ tracks: b,
1232
+ activeIndex: _ >= 0 ? _ : b[0].index,
1233
+ onSelect: z
357
1234
  }
358
1235
  ),
359
- !v && !V && /* @__PURE__ */ r("div", { className: "gvp-play-wrap", children: /* @__PURE__ */ m(
1236
+ !I && A && /* @__PURE__ */ t(
360
1237
  "button",
361
1238
  {
362
1239
  type: "button",
363
- onClick: () => void W(),
364
- onMouseEnter: () => L(!0),
365
- onMouseLeave: () => L(!1),
1240
+ className: "gvp-click-layer",
1241
+ onClick: () => void F(),
1242
+ "aria-label": D ? "Pause" : "Play"
1243
+ }
1244
+ ),
1245
+ !I && !A && !D && /* @__PURE__ */ t("div", { className: "gvp-play-wrap", children: /* @__PURE__ */ v(
1246
+ "button",
1247
+ {
1248
+ type: "button",
1249
+ onClick: () => void F(),
1250
+ onMouseEnter: () => M(!0),
1251
+ onMouseLeave: () => M(!1),
366
1252
  className: "gvp-play",
367
1253
  "aria-label": "Play",
368
1254
  children: [
369
- /* @__PURE__ */ r(ee, {}),
370
- f && z && /* @__PURE__ */ r("span", { className: "gvp-tooltip", role: "tooltip", children: f })
1255
+ /* @__PURE__ */ t(ke, {}),
1256
+ u && E && /* @__PURE__ */ t("span", { className: "gvp-tooltip", role: "tooltip", children: u })
371
1257
  ]
372
1258
  }
373
1259
  ) }),
374
- !v && /* @__PURE__ */ r("div", { className: "gvp-bottom-fade" })
1260
+ !I && A && /* @__PURE__ */ t(
1261
+ He,
1262
+ {
1263
+ video: re,
1264
+ isPlaying: D,
1265
+ container: te,
1266
+ onTogglePlay: () => void F()
1267
+ }
1268
+ ),
1269
+ !I && !A && /* @__PURE__ */ t("div", { className: "gvp-bottom-fade" })
375
1270
  ]
376
1271
  }
377
1272
  )
378
1273
  );
379
1274
  };
380
1275
  export {
381
- ae as ReactVideoPlayer,
382
- te as parseYouTubeId,
383
- re as parseYouTubeStart,
384
- ne as youTubeEmbedUrl
1276
+ Ke as ReactVideoPlayer,
1277
+ Ue as parseYouTubeId,
1278
+ _e as parseYouTubeStart,
1279
+ Oe as youTubeEmbedUrl
385
1280
  };
386
1281
  //# sourceMappingURL=index.mjs.map