@glitchlab/react-video-player 1.1.0 → 1.2.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,50 +1,24 @@
1
1
  "use client";
2
- import { jsx as r, jsxs as y } from "react/jsx-runtime";
3
- import q, { useRef as H, useImperativeHandle as G, useEffect as K, useState as T, useMemo as I, useCallback as w } from "react";
2
+ import { jsxs as v, jsx as t } from "react/jsx-runtime";
3
+ import pe, { useState as k, useRef as V, useCallback as S, useEffect as x, useImperativeHandle as me, useMemo as U } from "react";
4
4
  import $ from "hls.js";
5
- function R(e) {
6
- var o, n, t = "";
7
- if (typeof e == "string" || typeof e == "number") t += e;
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
- var l = e.length;
10
- for (o = 0; o < l; o++) e[o] && (n = R(e[o])) && (t && (t += " "), t += n);
11
- } else for (n in e) e[n] && (t && (t += " "), t += n);
12
- return t;
9
+ var i = e.length;
10
+ for (n = 0; n < i; 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 = R(e)) && (t && (t += " "), t += o);
16
- return t;
14
+ function H() {
15
+ for (var e, n, s = 0, r = "", i = arguments.length; s < i; s++) (e = arguments[s]) && (n = Q(e)) && (r && (r += " "), r += n);
16
+ return r;
17
17
  }
18
- const U = q.forwardRef(
19
- ({ src: e, hlsConfig: o, isHls: n, children: t, ...l }, p) => {
20
- const i = H(null), s = H(null);
21
- G(p, () => i.current);
22
- const b = globalThis.window !== void 0 && $.isSupported(), C = !!n || b && typeof e == "string" && e.endsWith(".m3u8");
23
- return K(() => {
24
- if (!e) return;
25
- const a = i.current;
26
- if (a) {
27
- for (s.current && (s.current.destroy(), s.current = null), a.pause(), a.removeAttribute("src"); a.firstChild; ) a.firstChild.remove();
28
- if (C) {
29
- const c = new $(o);
30
- s.current = c, c.attachMedia(a), c.loadSource(e), c.on($.Events.ERROR, (f, d) => {
31
- d.fatal && (c.destroy(), s.current = null);
32
- });
33
- } else
34
- a.src = e, a.load();
35
- return () => {
36
- for (s.current && (s.current.destroy(), s.current = null), a.pause(), a.removeAttribute("src"); a.firstChild; ) a.firstChild.remove();
37
- a.load();
38
- };
39
- }
40
- }, [e, C, o]), /* @__PURE__ */ r("video", { ref: i, ...l, children: t });
41
- }
42
- );
43
- U.displayName = "HLSPlayer";
44
- const x = "gvp-icon", M = (e) => e ? `${x} ${e}` : x, Q = ({ className: e }) => /* @__PURE__ */ y(
18
+ const K = "gvp-icon", L = (e) => e ? `${K} ${e}` : K, fe = ({ className: e }) => /* @__PURE__ */ v(
45
19
  "svg",
46
20
  {
47
- className: M(e),
21
+ className: L(e),
48
22
  width: "20",
49
23
  height: "20",
50
24
  viewBox: "0 0 24 24",
@@ -52,7 +26,7 @@ const x = "gvp-icon", M = (e) => e ? `${x} ${e}` : x, Q = ({ className: e }) =>
52
26
  xmlns: "http://www.w3.org/2000/svg",
53
27
  "aria-hidden": "true",
54
28
  children: [
55
- /* @__PURE__ */ r(
29
+ /* @__PURE__ */ t(
56
30
  "path",
57
31
  {
58
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",
@@ -61,7 +35,7 @@ const x = "gvp-icon", M = (e) => e ? `${x} ${e}` : x, Q = ({ className: e }) =>
61
35
  strokeLinecap: "round"
62
36
  }
63
37
  ),
64
- /* @__PURE__ */ r(
38
+ /* @__PURE__ */ t(
65
39
  "path",
66
40
  {
67
41
  d: "M11 15H13",
@@ -71,7 +45,7 @@ const x = "gvp-icon", M = (e) => e ? `${x} ${e}` : x, Q = ({ className: e }) =>
71
45
  strokeLinejoin: "round"
72
46
  }
73
47
  ),
74
- /* @__PURE__ */ r(
48
+ /* @__PURE__ */ t(
75
49
  "path",
76
50
  {
77
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",
@@ -80,13 +54,13 @@ const x = "gvp-icon", M = (e) => e ? `${x} ${e}` : x, Q = ({ className: e }) =>
80
54
  strokeLinecap: "round"
81
55
  }
82
56
  ),
83
- /* @__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" })
84
58
  ]
85
59
  }
86
- ), A = ({ className: e }) => /* @__PURE__ */ y(
60
+ ), ge = ({ className: e }) => /* @__PURE__ */ v(
87
61
  "svg",
88
62
  {
89
- className: M(e),
63
+ className: L(e),
90
64
  width: "20",
91
65
  height: "20",
92
66
  viewBox: "0 0 24 24",
@@ -94,7 +68,7 @@ const x = "gvp-icon", M = (e) => e ? `${x} ${e}` : x, Q = ({ className: e }) =>
94
68
  xmlns: "http://www.w3.org/2000/svg",
95
69
  "aria-hidden": "true",
96
70
  children: [
97
- /* @__PURE__ */ r(
71
+ /* @__PURE__ */ t(
98
72
  "path",
99
73
  {
100
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",
@@ -103,7 +77,7 @@ const x = "gvp-icon", M = (e) => e ? `${x} ${e}` : x, Q = ({ className: e }) =>
103
77
  strokeLinecap: "round"
104
78
  }
105
79
  ),
106
- /* @__PURE__ */ r(
80
+ /* @__PURE__ */ t(
107
81
  "path",
108
82
  {
109
83
  d: "M11 19H13",
@@ -113,7 +87,7 @@ const x = "gvp-icon", M = (e) => e ? `${x} ${e}` : x, Q = ({ className: e }) =>
113
87
  strokeLinejoin: "round"
114
88
  }
115
89
  ),
116
- /* @__PURE__ */ r(
90
+ /* @__PURE__ */ t(
117
91
  "path",
118
92
  {
119
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",
@@ -124,17 +98,17 @@ const x = "gvp-icon", M = (e) => e ? `${x} ${e}` : x, Q = ({ className: e }) =>
124
98
  )
125
99
  ]
126
100
  }
127
- ), F = ({ className: e }) => /* @__PURE__ */ r(
101
+ ), ve = ({ className: e }) => /* @__PURE__ */ t(
128
102
  "svg",
129
103
  {
130
- className: M(e),
104
+ className: L(e),
131
105
  width: "14",
132
106
  height: "14",
133
107
  viewBox: "0 0 14 14",
134
108
  fill: "none",
135
109
  xmlns: "http://www.w3.org/2000/svg",
136
110
  "aria-hidden": "true",
137
- children: /* @__PURE__ */ r(
111
+ children: /* @__PURE__ */ t(
138
112
  "path",
139
113
  {
140
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",
@@ -142,17 +116,17 @@ const x = "gvp-icon", M = (e) => e ? `${x} ${e}` : x, Q = ({ className: e }) =>
142
116
  }
143
117
  )
144
118
  }
145
- ), ee = ({ className: e }) => /* @__PURE__ */ r(
119
+ ), ke = ({ className: e }) => /* @__PURE__ */ t(
146
120
  "svg",
147
121
  {
148
- className: M(e),
122
+ className: L(e),
149
123
  width: "22",
150
124
  height: "22",
151
125
  viewBox: "0 0 16 16",
152
126
  fill: "none",
153
127
  xmlns: "http://www.w3.org/2000/svg",
154
128
  "aria-hidden": "true",
155
- children: /* @__PURE__ */ r(
129
+ children: /* @__PURE__ */ t(
156
130
  "path",
157
131
  {
158
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",
@@ -160,224 +134,1147 @@ const x = "gvp-icon", M = (e) => e ? `${x} ${e}` : x, Q = ({ className: e }) =>
160
134
  }
161
135
  )
162
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 [i, u] = k(!0), c = V(null), a = S(() => {
459
+ c.current !== null && (clearTimeout(c.current), c.current = null);
460
+ }, []), l = S(() => {
461
+ a(), n && (c.current = setTimeout(() => u(!1), Se));
462
+ }, [a, n]), m = S(() => {
463
+ u(!0), l();
464
+ }, [l]);
465
+ return x(() => {
466
+ if (!n) {
467
+ a(), u(!0);
468
+ return;
469
+ }
470
+ return l(), a;
471
+ }, [n, l, 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", !i && "is-hidden"),
520
+ onMouseEnter: a,
521
+ onMouseLeave: l,
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, i] = k(0), [u, c] = k(0);
549
+ x(() => {
550
+ if (!e) return;
551
+ const o = () => s(e.currentTime), p = () => i(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(), p(), g(), e.addEventListener("timeupdate", o), e.addEventListener("durationchange", p), e.addEventListener("loadedmetadata", p), e.addEventListener("progress", g), e.addEventListener("timeupdate", g), () => {
566
+ e.removeEventListener("timeupdate", o), e.removeEventListener("durationchange", p), e.removeEventListener("loadedmetadata", p), e.removeEventListener("progress", g), e.removeEventListener("timeupdate", g);
567
+ };
568
+ }, [e]);
569
+ const a = r > 0, l = a ? n / r * 100 : 0, m = a ? u / r * 100 : 0, f = (o) => {
570
+ if (!e || !a) return;
571
+ const p = Number(o.target.value) / 100 * r;
572
+ e.currentTime = p, s(p);
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: `${l}%` }
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: l,
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, i] = k(0);
611
+ return x(() => {
612
+ if (!e) return;
613
+ const u = () => s(e.currentTime), c = () => i(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, i] = k(!1);
624
+ x(() => {
625
+ if (!e) return;
626
+ const m = () => {
627
+ s(e.volume), i(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 l = 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: `${l}%` }
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: l,
670
+ onChange: c,
671
+ "aria-label": "Volume",
672
+ "aria-valuemin": 0,
673
+ "aria-valuemax": 100,
674
+ "aria-valuenow": l
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, i] = k(!1), u = V(null);
681
+ x(() => {
682
+ if (!e) return;
683
+ const l = () => s(e.playbackRate);
684
+ return l(), e.addEventListener("ratechange", l), () => e.removeEventListener("ratechange", l);
685
+ }, [e]), x(() => {
686
+ if (!r) return;
687
+ const l = (f) => {
688
+ u.current && !u.current.contains(f.target) && i(!1);
689
+ }, m = (f) => {
690
+ f.key === "Escape" && i(!1);
691
+ };
692
+ return document.addEventListener("mousedown", l), document.addEventListener("keydown", m), () => {
693
+ document.removeEventListener("mousedown", l), document.removeEventListener("keydown", m);
694
+ };
695
+ }, [r]);
696
+ const c = (l) => {
697
+ e && (e.playbackRate = l), s(l), i(!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: () => i((l) => !l),
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((l) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
717
+ "button",
718
+ {
719
+ type: "button",
720
+ role: "option",
721
+ "aria-selected": l === n,
722
+ className: H("gvp-speed-menu-item", l === n && "is-active"),
723
+ onClick: () => c(l),
724
+ children: l === 1 ? "Normal" : `${l}×`
725
+ }
726
+ ) }, l)) })
727
+ ] });
728
+ }, We = ({ video: e }) => {
729
+ const [n, s] = k([]), [r, i] = k(-1), [u, c] = k(!1), a = V(null), l = S((o) => {
730
+ const p = [];
731
+ for (let d = 0; d < o.length; d++) {
732
+ const w = o[d];
733
+ (w.kind === "subtitles" || w.kind === "captions") && p.push({ index: d, label: w.label || w.language || `Track ${d + 1}`, language: w.language });
734
+ }
735
+ s(p);
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
+ i(g);
743
+ }, []);
744
+ x(() => {
745
+ if (!e) {
746
+ s([]), i(-1);
747
+ return;
748
+ }
749
+ const o = e.textTracks;
750
+ l(o);
751
+ const p = () => l(o);
752
+ return o.addEventListener("addtrack", p), o.addEventListener("removetrack", p), o.addEventListener("change", p), () => {
753
+ o.removeEventListener("addtrack", p), o.removeEventListener("removetrack", p), o.removeEventListener("change", p);
754
+ };
755
+ }, [e, l]), x(() => {
756
+ if (!u) return;
757
+ const o = (g) => {
758
+ a.current && !a.current.contains(g.target) && c(!1);
759
+ }, p = (g) => {
760
+ g.key === "Escape" && c(!1);
761
+ };
762
+ return document.addEventListener("mousedown", o), document.addEventListener("keydown", p), () => {
763
+ document.removeEventListener("mousedown", o), document.removeEventListener("keydown", p);
764
+ };
765
+ }, [u]);
766
+ const m = (o) => {
767
+ if (!e) return;
768
+ const p = e.textTracks;
769
+ for (let g = 0; g < p.length; g++)
770
+ p[g].mode = g === o ? "showing" : "hidden";
771
+ i(o), c(!1);
772
+ }, f = () => {
773
+ if (!e) return;
774
+ const o = e.textTracks;
775
+ for (let p = 0; p < o.length; p++) o[p].mode = "hidden";
776
+ i(-1), c(!1);
777
+ };
778
+ return n.length === 0 ? null : /* @__PURE__ */ v("div", { className: "gvp-captions", ref: a, children: [
779
+ /* @__PURE__ */ t(
780
+ "button",
781
+ {
782
+ type: "button",
783
+ className: H("gvp-ctrl-btn", r >= 0 && "is-active"),
784
+ "aria-haspopup": "listbox",
785
+ "aria-expanded": u,
786
+ "aria-label": "Captions",
787
+ "aria-pressed": r >= 0,
788
+ onClick: () => c((o) => !o),
789
+ children: /* @__PURE__ */ t(Pe, {})
790
+ }
791
+ ),
792
+ u && // NOSONAR: typescript:S6819
793
+ /* @__PURE__ */ v("ul", { className: "gvp-captions-menu", role: "listbox", "aria-label": "Captions", children: [
794
+ /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
795
+ "button",
796
+ {
797
+ type: "button",
798
+ role: "option",
799
+ "aria-selected": r === -1,
800
+ className: H("gvp-captions-menu-item", r === -1 && "is-active"),
801
+ onClick: f,
802
+ children: "Off"
803
+ }
804
+ ) }),
805
+ n.map((o) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
806
+ "button",
807
+ {
808
+ type: "button",
809
+ role: "option",
810
+ "aria-selected": o.index === r,
811
+ className: H("gvp-captions-menu-item", o.index === r && "is-active"),
812
+ onClick: () => m(o.index),
813
+ children: o.label
814
+ }
815
+ ) }, o.index))
816
+ ] })
817
+ ] });
818
+ }, je = ({ video: e }) => {
819
+ const [n, s] = k(!1);
820
+ if (x(() => {
821
+ if (!e) return;
822
+ const i = () => s(!0), u = () => s(!1);
823
+ return e.addEventListener("enterpictureinpicture", i), e.addEventListener("leavepictureinpicture", u), () => {
824
+ e.removeEventListener("enterpictureinpicture", i), e.removeEventListener("leavepictureinpicture", u);
825
+ };
826
+ }, [e]), !document.pictureInPictureEnabled) return null;
827
+ const r = () => {
828
+ document.pictureInPictureElement ? document.exitPictureInPicture().catch(() => {
829
+ }) : e == null || e.requestPictureInPicture().catch(() => {
830
+ });
831
+ };
832
+ return /* @__PURE__ */ t(
833
+ "button",
834
+ {
835
+ type: "button",
836
+ className: H("gvp-ctrl-btn", n && "is-active"),
837
+ "aria-label": n ? "Exit picture-in-picture" : "Picture-in-picture",
838
+ "aria-pressed": n,
839
+ onClick: r,
840
+ children: /* @__PURE__ */ t(Me, {})
841
+ }
842
+ );
843
+ }, Ze = ({ container: e, video: n }) => {
844
+ const [s, r] = k(!1);
845
+ return x(() => {
846
+ if (q) return;
847
+ const l = () => r(B.element() === e);
848
+ return l(), B.onChange(l);
849
+ }, [e]), B.isSupported() || q && n !== null && typeof n.webkitEnterFullscreen == "function" ? /* @__PURE__ */ t(
850
+ "button",
851
+ {
852
+ type: "button",
853
+ className: "gvp-ctrl-btn",
854
+ "aria-label": s ? "Exit fullscreen" : "Enter fullscreen",
855
+ "aria-pressed": s,
856
+ onClick: () => {
857
+ var l;
858
+ if (q) {
859
+ (l = n == null ? void 0 : n.webkitEnterFullscreen) == null || l.call(n);
860
+ return;
861
+ }
862
+ s ? B.exit().catch(() => {
863
+ }) : e && B.request(e).catch(() => {
864
+ });
865
+ },
866
+ children: /* @__PURE__ */ t(s ? Ne : xe, {})
867
+ }
868
+ ) : null;
869
+ };
870
+ function G(e, n, s) {
871
+ const r = e == null ? void 0 : e.trim();
872
+ if (r) return r;
873
+ if (n) {
874
+ try {
875
+ const u = new Intl.DisplayNames(void 0, { type: "language" }).of(n);
876
+ if (u && u !== n) return u;
877
+ } catch {
878
+ }
879
+ return n;
880
+ }
881
+ return `Audio ${s + 1}`;
882
+ }
883
+ const ee = pe.forwardRef(
884
+ ({
885
+ src: e,
886
+ hlsConfig: n,
887
+ isHls: s,
888
+ autoPlay: r,
889
+ children: i,
890
+ onAudioTracks: u,
891
+ audioTrackIndex: c,
892
+ ...a
893
+ }, l) => {
894
+ const m = V(null), f = V(null), o = V(u);
895
+ o.current = u, me(l, () => m.current);
896
+ const p = globalThis.window !== void 0 && $.isSupported(), g = !!s || p && typeof e == "string" && e.endsWith(".m3u8");
897
+ return x(() => {
898
+ var P, R, D;
899
+ if (!e) return;
900
+ const d = m.current;
901
+ if (!d) return;
902
+ const w = (h) => {
903
+ var E;
904
+ (E = o.current) == null || E.call(o, h);
905
+ }, C = () => {
906
+ r && d.play().catch(() => {
907
+ });
908
+ };
909
+ for (f.current && (f.current.destroy(), f.current = null), d.pause(), d.removeAttribute("src"); d.firstChild; ) d.firstChild.remove();
910
+ w([]);
911
+ let N;
912
+ if (g) {
913
+ const h = new $(n);
914
+ f.current = h;
915
+ const E = () => {
916
+ const M = h.audioTracks.map((b, T) => ({
917
+ index: T,
918
+ label: G(b.name, b.lang, T),
919
+ lang: b.lang || void 0
920
+ }));
921
+ w(M);
922
+ };
923
+ h.on($.Events.MANIFEST_PARSED, C), h.on($.Events.AUDIO_TRACKS_UPDATED, E), h.on($.Events.AUDIO_TRACK_SWITCHED, E), h.on($.Events.ERROR, (M, b) => {
924
+ b.fatal && (h.destroy(), f.current = null);
925
+ }), h.attachMedia(d), h.loadSource(e);
926
+ } else {
927
+ d.src = e, d.load(), d.addEventListener("loadedmetadata", C, { once: !0 });
928
+ const h = d.audioTracks;
929
+ if (h) {
930
+ const E = () => {
931
+ const M = [];
932
+ for (let b = 0; b < h.length; b++) {
933
+ const T = h[b];
934
+ M.push({
935
+ index: b,
936
+ label: G(T.label, T.language, b),
937
+ lang: T.language || void 0
938
+ });
939
+ }
940
+ w(M);
941
+ };
942
+ (P = h.addEventListener) == null || P.call(h, "addtrack", E), (R = h.addEventListener) == null || R.call(h, "removetrack", E), (D = h.addEventListener) == null || D.call(h, "change", E), h.length > 0 && E(), N = () => {
943
+ var M, b, T;
944
+ (M = h.removeEventListener) == null || M.call(h, "addtrack", E), (b = h.removeEventListener) == null || b.call(h, "removetrack", E), (T = h.removeEventListener) == null || T.call(h, "change", E);
945
+ };
946
+ }
947
+ }
948
+ return () => {
949
+ 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();
950
+ d.load(), w([]);
951
+ };
952
+ }, [e, g, n, r]), x(() => {
953
+ var C;
954
+ if (c == null || c < 0) return;
955
+ const d = f.current;
956
+ if (d) {
957
+ d.audioTrack !== c && (d.audioTrack = c);
958
+ return;
959
+ }
960
+ const w = (C = m.current) == null ? void 0 : C.audioTracks;
961
+ if (w)
962
+ for (let N = 0; N < w.length; N++)
963
+ w[N].enabled = N === c;
964
+ }, [c]), // Captions are the consumer's responsibility — pass <track> elements as children.
965
+ // NOSONAR: typescript:S4084
966
+ /* @__PURE__ */ t("video", { ref: m, ...a, children: i });
967
+ }
163
968
  );
164
- function te(e) {
969
+ ee.displayName = "HLSPlayer";
970
+ function Ue(e) {
165
971
  if (!e) return null;
166
972
  if (/^[A-Za-z0-9_-]{11}$/.test(e)) return e;
167
- let o;
973
+ let n;
168
974
  try {
169
- o = new URL(e);
975
+ n = new URL(e);
170
976
  } catch {
171
977
  return null;
172
978
  }
173
- const n = o.hostname.replace(/^www\./, "");
174
- if (n === "youtu.be") {
175
- const t = o.pathname.slice(1).split("/")[0];
176
- return /^[A-Za-z0-9_-]{11}$/.test(t) ? t : null;
979
+ const s = n.hostname.replace(/^www\./, "");
980
+ if (s === "youtu.be") {
981
+ const r = n.pathname.slice(1).split("/")[0];
982
+ return /^[A-Za-z0-9_-]{11}$/.test(r) ? r : null;
177
983
  }
178
- if (n === "youtube.com" || n === "m.youtube.com" || n === "music.youtube.com" || n === "youtube-nocookie.com") {
179
- const t = o.searchParams.get("v");
180
- if (t && /^[A-Za-z0-9_-]{11}$/.test(t)) return t;
181
- const l = /^\/(?:embed|shorts|v|live)\/([A-Za-z0-9_-]{11})/.exec(
182
- o.pathname
984
+ if (s === "youtube.com" || s === "m.youtube.com" || s === "music.youtube.com" || s === "youtube-nocookie.com") {
985
+ const r = n.searchParams.get("v");
986
+ if (r && /^[A-Za-z0-9_-]{11}$/.test(r)) return r;
987
+ const i = /^\/(?:embed|shorts|v|live)\/([A-Za-z0-9_-]{11})/.exec(
988
+ n.pathname
183
989
  );
184
- if (l) return l[1];
990
+ if (i) return i[1];
185
991
  }
186
992
  return null;
187
993
  }
188
- function re(e) {
994
+ function _e(e) {
189
995
  try {
190
- const o = new URL(e), n = o.searchParams.get("t") ?? o.searchParams.get("start");
191
- if (!n) return null;
192
- if (/^\d+s?$/.test(n)) return Number.parseInt(n, 10);
193
- const t = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(n);
194
- if (t) {
195
- const l = Number.parseInt(t[1] ?? "0", 10), p = Number.parseInt(t[2] ?? "0", 10), i = Number.parseInt(t[3] ?? "0", 10), s = l * 3600 + p * 60 + i;
196
- return s > 0 ? s : null;
996
+ const n = new URL(e), s = n.searchParams.get("t") ?? n.searchParams.get("start");
997
+ if (!s) return null;
998
+ if (/^\d+s?$/.test(s)) return Number.parseInt(s, 10);
999
+ const r = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(s);
1000
+ if (r) {
1001
+ const i = Number.parseInt(r[1] ?? "0", 10), u = Number.parseInt(r[2] ?? "0", 10), c = Number.parseInt(r[3] ?? "0", 10), a = i * 3600 + u * 60 + c;
1002
+ return a > 0 ? a : null;
197
1003
  }
198
1004
  } catch {
199
1005
  }
200
1006
  return null;
201
1007
  }
202
- function ne(e, o = {}) {
203
- const { autoPlay: n = !1, muted: t = !0, loop: l = !1, controls: p = !0, startSeconds: i } = o, s = new URLSearchParams({
1008
+ function Oe(e, n = {}) {
1009
+ const { autoPlay: s = !1, muted: r = !0, loop: i = !1, controls: u = !0, startSeconds: c } = n, a = new URLSearchParams({
204
1010
  rel: "0",
205
1011
  modestbranding: "1",
206
1012
  playsinline: "1",
207
- controls: p ? "1" : "0"
1013
+ controls: u ? "1" : "0"
208
1014
  });
209
- return n ? (s.set("autoplay", "1"), s.set("mute", "1")) : t && s.set("mute", "1"), l && (s.set("loop", "1"), s.set("playlist", e)), i && i > 0 && s.set("start", String(i)), `https://www.youtube-nocookie.com/embed/${e}?${s.toString()}`;
1015
+ return s ? (a.set("autoplay", "1"), a.set("mute", "1")) : r && a.set("mute", "1"), i && (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()}`;
210
1016
  }
211
- const ae = ({
1017
+ const Fe = ({
1018
+ tracks: e,
1019
+ activeIndex: n,
1020
+ onSelect: s
1021
+ }) => {
1022
+ const [r, i] = k(!1), u = V(null);
1023
+ x(() => {
1024
+ if (!r) return;
1025
+ const a = (m) => {
1026
+ u.current && !u.current.contains(m.target) && i(!1);
1027
+ }, l = (m) => {
1028
+ m.key === "Escape" && i(!1);
1029
+ };
1030
+ return document.addEventListener("mousedown", a), document.addEventListener("keydown", l), () => {
1031
+ document.removeEventListener("mousedown", a), document.removeEventListener("keydown", l);
1032
+ };
1033
+ }, [r]);
1034
+ const c = e.find((a) => a.index === n) ?? e[0];
1035
+ return /* @__PURE__ */ v("div", { className: "gvp-audio", ref: u, children: [
1036
+ /* @__PURE__ */ v(
1037
+ "button",
1038
+ {
1039
+ type: "button",
1040
+ className: "gvp-audio-btn",
1041
+ "aria-haspopup": "listbox",
1042
+ "aria-expanded": r,
1043
+ "aria-label": "Audio track",
1044
+ onClick: () => i((a) => !a),
1045
+ children: [
1046
+ /* @__PURE__ */ t(we, {}),
1047
+ /* @__PURE__ */ t("span", { className: "gvp-audio-label", children: c == null ? void 0 : c.label }),
1048
+ /* @__PURE__ */ t(Ie, {})
1049
+ ]
1050
+ }
1051
+ ),
1052
+ r && // A native <select> can't be styled to sit inside the player overlay
1053
+ // (it renders the OS dropdown chrome), so this is a custom listbox with
1054
+ // full keyboard + ARIA support.
1055
+ // NOSONAR: typescript:S6819
1056
+ /* @__PURE__ */ t("ul", { className: "gvp-audio-menu", role: "listbox", "aria-label": "Audio tracks", children: e.map((a) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
1057
+ "button",
1058
+ {
1059
+ type: "button",
1060
+ role: "option",
1061
+ "aria-selected": a.index === n,
1062
+ className: H(
1063
+ "gvp-audio-menu-item",
1064
+ a.index === n && "is-active"
1065
+ ),
1066
+ onClick: () => {
1067
+ s(a.index), i(!1);
1068
+ },
1069
+ children: a.label
1070
+ }
1071
+ ) }, a.index)) })
1072
+ ] });
1073
+ }, Ke = ({
212
1074
  src: e,
213
- poster: o,
214
- showDeviceToggle: n = !0,
215
- defaultDevice: t = "desktop",
216
- hoverPlay: l = !1,
217
- tooltipText: p,
218
- onClose: i,
219
- className: s = "",
220
- muted: b = !0,
221
- loop: C = !1,
222
- controls: a = !1,
223
- autoPlay: c = !1,
224
- frameMaxWidth: f,
225
- aspectRatio: d,
226
- hlsConfig: B,
227
- children: V
1075
+ poster: n,
1076
+ showDeviceToggle: s = !0,
1077
+ defaultDevice: r = "desktop",
1078
+ hoverPlay: i = !1,
1079
+ tooltipText: u,
1080
+ onClose: c,
1081
+ className: a = "",
1082
+ muted: l = !0,
1083
+ loop: m = !1,
1084
+ controls: f = !1,
1085
+ autoPlay: o = !1,
1086
+ frameMaxWidth: p,
1087
+ aspectRatio: g,
1088
+ hlsConfig: d,
1089
+ children: w
228
1090
  }) => {
229
- const m = H(null), k = H(null), [h, E] = T(t), [_, g] = T(!1), [z, L] = T(!1), N = I(() => te(e), [e]), v = N !== null, Y = I(() => h === "mobile" ? (d == null ? void 0 : d.mobile) ?? "9/16" : (d == null ? void 0 : d.desktop) ?? "16/9", [h, d]), D = I(() => h === "mobile" ? (f == null ? void 0 : f.mobile) ?? "420px" : (f == null ? void 0 : f.desktop) ?? "960px", [h, f]), J = I(
230
- () => N ? ne(N, {
231
- autoPlay: c,
232
- muted: b,
233
- loop: C,
234
- controls: a,
235
- startSeconds: re(e)
1091
+ const C = V(null), N = V(null), [P, R] = k(r), [D, h] = k(!1), [E, M] = k(!1), [b, T] = k([]), [_, z] = k(-1), [te, ne] = k(null), [re, se] = k(null), oe = S((y) => {
1092
+ C.current = y, se(y);
1093
+ }, []), A = f === "custom", O = f === !0, 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]), le = U(() => P === "mobile" ? (p == null ? void 0 : p.mobile) ?? "420px" : (p == null ? void 0 : p.desktop) ?? "960px", [P, p]), ie = U(
1094
+ () => W ? Oe(W, {
1095
+ autoPlay: o,
1096
+ muted: l,
1097
+ loop: m,
1098
+ // Custom controls can't drive an iframe, so YouTube falls
1099
+ // back to its own controls in that mode.
1100
+ controls: A ? !0 : O,
1101
+ startSeconds: _e(e)
236
1102
  }) : null,
237
- [N, e, c, b, C, a]
238
- ), S = w(async () => {
239
- const u = m.current;
240
- if (u) {
241
- if (k.current)
1103
+ [W, e, o, l, m, A, O]
1104
+ ), ce = S((y) => {
1105
+ T(y), z(-1);
1106
+ }, []), j = S(async () => {
1107
+ const y = C.current;
1108
+ if (y) {
1109
+ if (N.current)
242
1110
  try {
243
- await k.current;
1111
+ await N.current;
244
1112
  } catch {
245
1113
  }
246
- u.pause();
1114
+ y.pause();
247
1115
  }
248
- }, []), P = w(async () => {
249
- const u = m.current;
250
- if (u)
1116
+ }, []), Z = S(async () => {
1117
+ const y = C.current;
1118
+ if (y)
251
1119
  try {
252
- u.readyState < 2 && u.load();
253
- const j = u.play();
254
- k.current = j, await j, g(!0);
1120
+ y.readyState < 2 && y.load();
1121
+ const Y = y.play();
1122
+ N.current = Y, await Y, h(!0);
255
1123
  } catch {
256
- g(!1);
1124
+ h(!1);
257
1125
  } finally {
258
- k.current = null;
1126
+ N.current = null;
259
1127
  }
260
- }, []), O = w(() => {
261
- !l || v || P();
262
- }, [l, v, P]), W = w(() => {
263
- !l || v || S().then(() => g(!1));
264
- }, [l, v, S]), X = w(async () => {
265
- const u = m.current;
266
- u && (u.paused ? await P() : (await S(), g(!1)));
267
- }, [P, S]);
1128
+ }, []), ue = S(() => {
1129
+ !i || I || Z();
1130
+ }, [i, I, Z]), de = S(() => {
1131
+ !i || I || j().then(() => h(!1));
1132
+ }, [i, I, j]), F = S(async () => {
1133
+ const y = C.current;
1134
+ y && (y.paused ? await Z() : (await j(), h(!1)));
1135
+ }, [Z, j]), he = !I && b.length > 1;
268
1136
  return (
269
1137
  // The mouse handlers are a progressive enhancement (hoverPlay + tooltip).
270
1138
  // Keyboard/click users reach the same actions via the inner <button> elements,
271
1139
  // so the outer container is intentionally non-interactive at the role level.
272
1140
  // NOSONAR: typescript:S6848
273
- /* @__PURE__ */ y(
1141
+ /* @__PURE__ */ v(
274
1142
  "div",
275
1143
  {
276
- className: Z("gvp-root", s),
277
- style: { width: D, aspectRatio: Y },
1144
+ ref: ne,
1145
+ className: H("gvp-root", a),
1146
+ style: { width: le, aspectRatio: ae },
278
1147
  onMouseEnter: () => {
279
- L(!0), O();
1148
+ M(!0), ue();
280
1149
  },
281
1150
  onMouseLeave: () => {
282
- L(!1), W();
1151
+ M(!1), de();
283
1152
  },
284
1153
  children: [
285
- v ? /* @__PURE__ */ r(
1154
+ I ? /* @__PURE__ */ t(
286
1155
  "iframe",
287
1156
  {
288
1157
  className: "gvp-video gvp-youtube",
289
- src: J ?? void 0,
1158
+ src: ie ?? void 0,
290
1159
  title: "YouTube video player",
291
1160
  allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",
292
1161
  allowFullScreen: !0,
293
1162
  referrerPolicy: "strict-origin-when-cross-origin"
294
1163
  }
295
- ) : /* @__PURE__ */ r(
296
- U,
1164
+ ) : /* @__PURE__ */ t(
1165
+ ee,
297
1166
  {
298
- ref: m,
1167
+ ref: oe,
299
1168
  src: e,
300
- poster: o,
301
- muted: b,
302
- loop: C,
1169
+ poster: n,
1170
+ muted: l,
1171
+ loop: m,
303
1172
  playsInline: !0,
304
1173
  preload: "metadata",
305
- controls: a,
306
- autoPlay: c,
307
- hlsConfig: B,
1174
+ controls: O,
1175
+ autoPlay: o,
1176
+ hlsConfig: d,
308
1177
  className: "gvp-video",
309
- onPlay: () => g(!0),
310
- onPause: () => g(!1),
311
- children: V
1178
+ onPlay: () => h(!0),
1179
+ onPause: () => h(!1),
1180
+ onAudioTracks: ce,
1181
+ audioTrackIndex: _,
1182
+ children: w
312
1183
  }
313
1184
  ),
314
- !v && /* @__PURE__ */ r("div", { className: "gvp-vignette" }),
315
- n && /* @__PURE__ */ r("div", { className: "gvp-toggle", children: /* @__PURE__ */ y("div", { className: "gvp-toggle-pill", children: [
316
- /* @__PURE__ */ r(
1185
+ !I && /* @__PURE__ */ t("div", { className: "gvp-vignette" }),
1186
+ s && /* @__PURE__ */ t("div", { className: "gvp-toggle", children: /* @__PURE__ */ v("div", { className: "gvp-toggle-pill", children: [
1187
+ /* @__PURE__ */ t(
317
1188
  "button",
318
1189
  {
319
1190
  type: "button",
320
- onClick: () => E("desktop"),
321
- className: Z(
1191
+ onClick: () => R("desktop"),
1192
+ className: H(
322
1193
  "gvp-toggle-btn",
323
- h === "desktop" && "is-active"
1194
+ P === "desktop" && "is-active"
324
1195
  ),
325
1196
  "aria-label": "Desktop view",
326
- "aria-pressed": h === "desktop",
327
- children: /* @__PURE__ */ r(Q, {})
1197
+ "aria-pressed": P === "desktop",
1198
+ children: /* @__PURE__ */ t(fe, {})
328
1199
  }
329
1200
  ),
330
- /* @__PURE__ */ r("div", { className: "gvp-toggle-divider" }),
331
- /* @__PURE__ */ r(
1201
+ /* @__PURE__ */ t("div", { className: "gvp-toggle-divider" }),
1202
+ /* @__PURE__ */ t(
332
1203
  "button",
333
1204
  {
334
1205
  type: "button",
335
- onClick: () => E("mobile"),
336
- className: Z(
1206
+ onClick: () => R("mobile"),
1207
+ className: H(
337
1208
  "gvp-toggle-btn",
338
- h === "mobile" && "is-active"
1209
+ P === "mobile" && "is-active"
339
1210
  ),
340
1211
  "aria-label": "Mobile view",
341
- "aria-pressed": h === "mobile",
342
- children: /* @__PURE__ */ r(A, {})
1212
+ "aria-pressed": P === "mobile",
1213
+ children: /* @__PURE__ */ t(ge, {})
343
1214
  }
344
1215
  )
345
1216
  ] }) }),
346
- i && /* @__PURE__ */ r(
1217
+ c && /* @__PURE__ */ t(
347
1218
  "button",
348
1219
  {
349
1220
  type: "button",
350
- onClick: i,
1221
+ onClick: c,
351
1222
  className: "gvp-close",
352
1223
  "aria-label": "Close",
353
- children: /* @__PURE__ */ r(F, {})
1224
+ children: /* @__PURE__ */ t(ve, {})
1225
+ }
1226
+ ),
1227
+ he && /* @__PURE__ */ t(
1228
+ Fe,
1229
+ {
1230
+ tracks: b,
1231
+ activeIndex: _ >= 0 ? _ : b[0].index,
1232
+ onSelect: z
354
1233
  }
355
1234
  ),
356
- !v && !_ && /* @__PURE__ */ r("div", { className: "gvp-play-wrap", children: /* @__PURE__ */ y(
1235
+ !I && A && /* @__PURE__ */ t(
357
1236
  "button",
358
1237
  {
359
1238
  type: "button",
360
- onClick: () => void X(),
361
- onMouseEnter: () => L(!0),
362
- onMouseLeave: () => L(!1),
1239
+ className: "gvp-click-layer",
1240
+ onClick: () => void F(),
1241
+ "aria-label": D ? "Pause" : "Play"
1242
+ }
1243
+ ),
1244
+ !I && !A && !D && /* @__PURE__ */ t("div", { className: "gvp-play-wrap", children: /* @__PURE__ */ v(
1245
+ "button",
1246
+ {
1247
+ type: "button",
1248
+ onClick: () => void F(),
1249
+ onMouseEnter: () => M(!0),
1250
+ onMouseLeave: () => M(!1),
363
1251
  className: "gvp-play",
364
1252
  "aria-label": "Play",
365
1253
  children: [
366
- /* @__PURE__ */ r(ee, {}),
367
- p && z && /* @__PURE__ */ r("span", { className: "gvp-tooltip", role: "tooltip", children: p })
1254
+ /* @__PURE__ */ t(ke, {}),
1255
+ u && E && /* @__PURE__ */ t("span", { className: "gvp-tooltip", role: "tooltip", children: u })
368
1256
  ]
369
1257
  }
370
1258
  ) }),
371
- !v && /* @__PURE__ */ r("div", { className: "gvp-bottom-fade" })
1259
+ !I && A && /* @__PURE__ */ t(
1260
+ He,
1261
+ {
1262
+ video: re,
1263
+ isPlaying: D,
1264
+ container: te,
1265
+ onTogglePlay: () => void F()
1266
+ }
1267
+ ),
1268
+ !I && !A && /* @__PURE__ */ t("div", { className: "gvp-bottom-fade" })
372
1269
  ]
373
1270
  }
374
1271
  )
375
1272
  );
376
1273
  };
377
1274
  export {
378
- ae as ReactVideoPlayer,
379
- te as parseYouTubeId,
380
- re as parseYouTubeStart,
381
- ne as youTubeEmbedUrl
1275
+ Ke as ReactVideoPlayer,
1276
+ Ue as parseYouTubeId,
1277
+ _e as parseYouTubeStart,
1278
+ Oe as youTubeEmbedUrl
382
1279
  };
383
1280
  //# sourceMappingURL=index.mjs.map