@glitchlab/react-video-player 1.4.1 → 1.5.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/README.md +113 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +126 -2
- package/dist/index.mjs +1006 -656
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,9 +16,13 @@ A lightweight, HLS-capable React video player with a polished overlay UI, device
|
|
|
16
16
|
- **HLS streaming** via `hls.js` with automatic native fallback (Safari)
|
|
17
17
|
- **YouTube support** — pass a YouTube URL and it embeds automatically, no extra config
|
|
18
18
|
- **Custom control bar** (default) — play/seek/time/speed/quality/captions/volume/PiP/fullscreen, consistent across every browser and OS. Or use `"native"` controls, or none.
|
|
19
|
+
- **Thumbnail seek preview** — hover the seek bar to see a frame preview from a WebVTT storyboard sprite
|
|
20
|
+
- **Chapters** — named timeline segments with tick marks on the seek bar, from a WebVTT file or an inline array
|
|
21
|
+
- **Playlist** — play a list of videos in sequence with auto-advance and prev/next buttons
|
|
19
22
|
- **Quality selector** — `Auto` + per-resolution switching for multi-rendition HLS streams
|
|
20
23
|
- **Audio-track switcher** — pick between multiple audio tracks (e.g. languages) when the stream provides them
|
|
21
24
|
- **Captions** — `<track>` subtitles/captions with an in-bar menu
|
|
25
|
+
- **Event hooks** — `onPlay`, `onPause`, `onEnded`, `onTimeUpdate`, `onSeeked`, `onVolumeChange`, `onMilestone`, `onError`
|
|
22
26
|
- **Keyboard shortcuts** — space, arrows, `M`, `F`, `P`
|
|
23
27
|
- **Next.js App Router compatible** — `"use client"` is preserved in the build
|
|
24
28
|
- **Scoped CSS, no preflight** — all styles live under `.gvp-root`. No `*` resets, no theme tokens leaked into your design system
|
|
@@ -95,8 +99,14 @@ No client-component wrapper required.
|
|
|
95
99
|
|
|
96
100
|
| Prop | Type | Default | Description |
|
|
97
101
|
|--------------------|---------------------------------------------------|-----------------------------------------|------------------------------------------------------------------------------------------|
|
|
98
|
-
| `src` | `string` | — |
|
|
102
|
+
| `src` | `string` | — | Video URL. `.m3u8` is routed through HLS automatically. Optional when `playlist` is set. |
|
|
99
103
|
| `poster` | `string` | — | Poster image shown before playback starts. |
|
|
104
|
+
| `playlist` | `PlaylistItem[]` | — | A list of videos to play in sequence. Auto-advances on end; prev/next buttons appear. Takes precedence over `src`. See [Playlist](#playlist). |
|
|
105
|
+
| `defaultIndex` | `number` | `0` | Index of the playlist item to start on. |
|
|
106
|
+
| `autoAdvance` | `boolean` | `true` | Auto-advance to the next playlist item when one ends. |
|
|
107
|
+
| `onPlaylistChange` | `(index, item) => void` | — | Called when the active playlist item changes. |
|
|
108
|
+
| `thumbnails` | `string` | — | URL of a WebVTT storyboard for seek-bar thumbnail previews. See [Thumbnails](#thumbnail-seek-preview). |
|
|
109
|
+
| `chapters` | `string \| Chapter[]` | — | WebVTT chapters URL, or an inline array of `{ start, title }`. See [Chapters](#chapters). |
|
|
100
110
|
| `showDeviceToggle` | `boolean` | `true` | Show the desktop/mobile toggle pill in the top-left. |
|
|
101
111
|
| `defaultDevice` | `"desktop" \| "mobile"` | `"desktop"` | Initial device mode. |
|
|
102
112
|
| `hoverPlay` | `boolean` | `false` | Start playback on mouse-enter, pause on mouse-leave. |
|
|
@@ -110,6 +120,14 @@ No client-component wrapper required.
|
|
|
110
120
|
| `frameMaxWidth` | `{ desktop?: string; mobile?: string }` | `{ desktop: "960px", mobile: "420px" }` | Max width of the player in each device mode. |
|
|
111
121
|
| `aspectRatio` | `{ desktop?: AspectRatio; mobile?: AspectRatio }` | `{ desktop: "16/9", mobile: "9/16" }` | Aspect ratio per device mode. `AspectRatio` is `` `${number}/${number}` ``. |
|
|
112
122
|
| `hlsConfig` | `Hls.HlsConfig` | — | Optional hls.js config. Pass a stable reference (e.g. `useMemo`) to avoid HLS rebuilds. |
|
|
123
|
+
| `onPlay` | `() => void` | — | Fired when playback starts or resumes. |
|
|
124
|
+
| `onPause` | `() => void` | — | Fired when playback is paused. |
|
|
125
|
+
| `onEnded` | `() => void` | — | Fired when the current video reaches its end. |
|
|
126
|
+
| `onTimeUpdate` | `(currentTime, duration) => void` | — | Fired on every `timeupdate` (~4×/sec) with current time and duration in seconds. |
|
|
127
|
+
| `onSeeked` | `(currentTime) => void` | — | Fired after a seek completes, with the new time in seconds. |
|
|
128
|
+
| `onVolumeChange` | `(volume, muted) => void` | — | Fired when volume or mute state changes. |
|
|
129
|
+
| `onMilestone` | `(percent) => void` | — | Fired once when watch progress crosses 25%, 50%, 75% and 100%. |
|
|
130
|
+
| `onError` | `() => void` | — | Fired when the underlying media element reports an error. |
|
|
113
131
|
| `children` | `React.ReactNode` | — | Rendered inside the underlying `<video>`. Use for `<track>` elements (captions/subs). |
|
|
114
132
|
|
|
115
133
|
---
|
|
@@ -180,6 +198,100 @@ Every part has a `.gvp-*` class hook — override what you need:
|
|
|
180
198
|
|
|
181
199
|
---
|
|
182
200
|
|
|
201
|
+
## Thumbnail seek preview
|
|
202
|
+
|
|
203
|
+
Hover the seek bar to see a frame preview. Pass `thumbnails` a URL to a **WebVTT storyboard** file — the format YouTube and Vimeo use. Each cue maps a time range to a region of a sprite image:
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
WEBVTT
|
|
207
|
+
|
|
208
|
+
00:00:00.000 --> 00:00:05.000
|
|
209
|
+
storyboard.jpg#xywh=0,0,160,90
|
|
210
|
+
|
|
211
|
+
00:00:05.000 --> 00:00:10.000
|
|
212
|
+
storyboard.jpg#xywh=160,0,160,90
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
<ReactVideoPlayer src="/videos/movie.m3u8" thumbnails="/videos/storyboard.vtt" />
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
The `#xywh=x,y,w,h` fragment crops a tile out of the sprite; relative image paths resolve against the VTT's own URL. A cue with no `#xywh` uses the whole image. You can generate a storyboard from a video with `ffmpeg`:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
ffmpeg -i video.mp4 -vf "fps=1/5,scale=160:90,tile=5x100" storyboard.jpg
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Only used with the custom control bar.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Chapters
|
|
230
|
+
|
|
231
|
+
Segment the timeline into named chapters. They add tick marks to the seek bar and show the chapter title in the hover preview. Pass either a WebVTT chapters URL or an inline array:
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
{/* Inline */}
|
|
235
|
+
<ReactVideoPlayer
|
|
236
|
+
src="/videos/tutorial.m3u8"
|
|
237
|
+
chapters={[
|
|
238
|
+
{ start: 0, title: "Introduction" },
|
|
239
|
+
{ start: 150, title: "Getting started" },
|
|
240
|
+
{ start: 600, title: "Advanced topics" },
|
|
241
|
+
]}
|
|
242
|
+
/>
|
|
243
|
+
|
|
244
|
+
{/* From a WebVTT chapters file */}
|
|
245
|
+
<ReactVideoPlayer src="/videos/tutorial.m3u8" chapters="/videos/chapters.vtt" />
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Inline items may omit `end` — it's filled from the next chapter's `start` (or the video duration). Only used with the custom control bar.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Playlist
|
|
253
|
+
|
|
254
|
+
Pass `playlist` an array of items to play videos in sequence. The player auto-advances when one ends and shows prev/next buttons in the control bar. Each item can carry its own `poster`, `thumbnails` and `chapters`:
|
|
255
|
+
|
|
256
|
+
```tsx
|
|
257
|
+
<ReactVideoPlayer
|
|
258
|
+
playlist={[
|
|
259
|
+
{ src: "/videos/ep1.m3u8", title: "Episode 1", thumbnails: "/videos/ep1.vtt" },
|
|
260
|
+
{ src: "/videos/ep2.m3u8", title: "Episode 2" },
|
|
261
|
+
{ src: "/videos/ep3.m3u8", title: "Episode 3" },
|
|
262
|
+
]}
|
|
263
|
+
defaultIndex={0}
|
|
264
|
+
autoAdvance
|
|
265
|
+
onPlaylistChange={(index, item) => console.log("Now playing", item.title)}
|
|
266
|
+
/>
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
`playlist` takes precedence over `src`. Set `autoAdvance={false}` to require a manual next click. `PlaylistItem` is exported for typing.
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Event hooks
|
|
274
|
+
|
|
275
|
+
Wire the player's playback events into your own analytics or UI without a separate timer:
|
|
276
|
+
|
|
277
|
+
```tsx
|
|
278
|
+
<ReactVideoPlayer
|
|
279
|
+
src="/videos/movie.m3u8"
|
|
280
|
+
onPlay={() => track("video_play")}
|
|
281
|
+
onPause={() => track("video_pause")}
|
|
282
|
+
onEnded={() => track("video_complete")}
|
|
283
|
+
onTimeUpdate={(time, duration) => setProgress(time / duration)}
|
|
284
|
+
onSeeked={(time) => track("video_seek", { time })}
|
|
285
|
+
onVolumeChange={(volume, muted) => console.log(volume, muted)}
|
|
286
|
+
onMilestone={(percent) => track(`watched_${percent}`)}
|
|
287
|
+
onError={() => showRetry()}
|
|
288
|
+
/>
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
`onMilestone` fires exactly once each as watch progress crosses 25%, 50%, 75% and 100% — handy for completion analytics. Milestone tracking resets per source (including playlist advances).
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
183
295
|
## YouTube URLs
|
|
184
296
|
|
|
185
297
|
Pass any common YouTube URL as `src` and the player swaps the `<video>` element for a privacy-enhanced (`youtube-nocookie.com`) embed inside the same styled frame — no extra prop needed:
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),o=require("react"),H=require("hls.js");function te(e){var n,r,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(n=0;n<i;n++)e[n]&&(r=te(e[n]))&&(s&&(s+=" "),s+=r)}else for(r in e)e[r]&&(s&&(s+=" "),s+=r);return s}function N(){for(var e,n,r=0,s="",i=arguments.length;r<i;r++)(e=arguments[r])&&(n=te(e))&&(s&&(s+=" "),s+=n);return s}const J="gvp-icon",L=e=>e?`${J} ${e}`:J,be=({className:e})=>t.jsxs("svg",{className:L(e),width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),t.jsx("path",{d:"M11 15H13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),t.jsx("path",{d:"M7 22H17",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),ke=({className:e})=>t.jsxs("svg",{className:L(e),width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),t.jsx("path",{d:"M11 19H13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{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",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"})]}),Ce=({className:e})=>t.jsx("svg",{className:L(e),width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{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",fill:"currentColor"})}),we=({className:e})=>t.jsx("svg",{className:L(e),width:"22",height:"22",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{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",fill:"currentColor"})}),je=({className:e})=>t.jsxs("svg",{className:L(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Le=({className:e})=>t.jsx("svg",{className:L(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{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",fill:"currentColor"})}),Ee=({className:e})=>t.jsxs("svg",{className:L(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1",fill:"currentColor"}),t.jsx("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1",fill:"currentColor"})]}),ye=({className:e})=>t.jsxs("svg",{className:L(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Ne=({className:e})=>t.jsxs("svg",{className:L(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Se=({className:e})=>t.jsxs("svg",{className:L(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M16 9L22 15M22 9L16 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Me=({className:e})=>t.jsx("svg",{className:L(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M4 9V4H9M15 4H20V9M20 15V20H15M9 20H4V15",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})}),Te=({className:e})=>t.jsx("svg",{className:L(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M9 4V9H4M15 9V4H20M15 20V15H20M9 15H4V20",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})}),Pe=({className:e})=>t.jsxs("svg",{className:L(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("rect",{x:"12",y:"12",width:"8",height:"5",rx:"1",fill:"currentColor"})]}),Ie=({className:e})=>t.jsxs("svg",{className:L(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"3",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M7 12H11M13 12H17M7 15H9M11 15H13M15 15H17",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),He=({className:e})=>t.jsxs("svg",{className:L(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M12 8V12L14.5 14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),Ve=({className:e})=>t.jsxs("svg",{className:L(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15Z",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M3 12C3 12.6 3.08 13.18 3.23 13.73L4.6 14.5C4.86 14.65 5.02 14.94 5 15.24C4.98 15.58 4.96 15.92 5.07 16.24C5.18 16.56 5.39 16.83 5.62 17.08C5.83 17.3 6.13 17.4 6.42 17.36L7.99 17.13C8.28 17.09 8.57 17.21 8.74 17.45C9.07 17.93 9.49 18.34 9.97 18.66C10.21 18.83 10.34 19.11 10.31 19.4L10.13 20.97C10.1 21.26 10.21 21.55 10.43 21.74C10.91 22.16 11.45 22 12 22C12.55 22 13.09 22.16 13.57 21.74C13.79 21.55 13.9 21.26 13.87 20.97L13.69 19.4C13.66 19.11 13.79 18.83 14.03 18.66",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Ae=({className:e})=>t.jsx("svg",{className:L(e),width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M6 9L12 15L18 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})});function X(e){if(!Number.isFinite(e)||e<0)return"--:--";const n=Math.floor(e),r=Math.floor(n/3600),s=Math.floor(n%3600/60),u=(n%60).toString().padStart(2,"0");if(r>0){const d=s.toString().padStart(2,"0");return`${r}:${d}:${u}`}return`${s}:${u}`}const Re={index:-1};function De(e,n){return e>0?`${e}p`:`Level ${n+1}`}const G=(()=>{if(typeof navigator>"u")return!1;const e=navigator.userAgent;return/iPad|iPhone|iPod/.test(e)||e.includes("Mac")&&navigator.maxTouchPoints>1})(),Q=typeof navigator>"u"?!1:/iPhone|iPod/.test(navigator.userAgent),Be=3e3,D={isSupported(){return typeof document>"u"?!1:!!(document.fullscreenEnabled||document.webkitFullscreenEnabled)},element(){return typeof document>"u"?null:document.fullscreenElement??document.webkitFullscreenElement??null},request(e){const n=e.requestFullscreen??e.webkitRequestFullscreen;return n?n.call(e):Promise.reject(new Error("Fullscreen not supported"))},exit(){const e=document.exitFullscreen??document.webkitExitFullscreen;return e?e.call(document):Promise.reject(new Error("Fullscreen not supported"))},onChange(e){return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e)}}},$e=({video:e,isPlaying:n,container:r,onTogglePlay:s,qualityLevels:i=[],currentLevel:u=-1,selectedLevel:d=-1,onSelectLevel:c})=>{const[m,h]=o.useState(!0),b=o.useRef(null),x=o.useCallback(()=>{b.current!==null&&(clearTimeout(b.current),b.current=null)},[]),a=o.useCallback(()=>{x(),n&&(b.current=setTimeout(()=>h(!1),Be))},[x,n]),l=o.useCallback(()=>{h(!0),a()},[a]);return o.useEffect(()=>{if(!n){x(),h(!0);return}return a(),x},[n,a,x]),o.useEffect(()=>{if(!r)return;const f=()=>l();return r.addEventListener("mousemove",f),r.addEventListener("touchstart",f),r.addEventListener("focusin",f),()=>{r.removeEventListener("mousemove",f),r.removeEventListener("touchstart",f),r.removeEventListener("focusin",f)}},[r,l]),o.useEffect(()=>{if(!r||!e)return;const f=g=>{if(!(!r.contains(document.activeElement)||g.target.tagName==="INPUT"&&g.key!==" "))switch(g.key){case" ":case"k":g.preventDefault(),s(),l();break;case"ArrowLeft":g.preventDefault(),e.currentTime=Math.max(0,e.currentTime-5),l();break;case"ArrowRight":g.preventDefault(),e.currentTime=Math.min(e.duration||0,e.currentTime+5),l();break;case"ArrowUp":g.preventDefault(),e.volume=Math.min(1,e.volume+.1),e.muted&&(e.muted=!1),l();break;case"ArrowDown":g.preventDefault(),e.volume=Math.max(0,e.volume-.1),l();break;case"m":e.muted=!e.muted,l();break;case"f":D.element()===r?D.exit().catch(()=>{}):D.request(r).catch(()=>{}),l();break;case"p":document.pictureInPictureElement?document.exitPictureInPicture().catch(()=>{}):document.pictureInPictureEnabled&&e.requestPictureInPicture().catch(()=>{}),l();break}};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[r,e,s,l]),t.jsx("div",{role:"toolbar","aria-label":"Video controls",className:N("gvp-controls",!m&&"is-hidden"),onMouseEnter:x,onMouseLeave:a,children:t.jsxs("div",{className:"gvp-controls-row",children:[t.jsx(We,{isPlaying:n,onToggle:s}),t.jsx(_e,{video:e}),t.jsx(Ue,{video:e}),t.jsx(Ze,{video:e}),t.jsx(Fe,{levels:i,currentLevel:u,selectedLevel:d,onSelect:c}),t.jsx(Ye,{video:e}),t.jsx(qe,{video:e}),t.jsx(Qe,{video:e}),t.jsx(ze,{container:r,video:e})]})})};function z(e,n,r){o.useEffect(()=>{if(!e)return;const s=u=>{n.current&&!n.current.contains(u.target)&&r()},i=u=>{u.key==="Escape"&&r()};return document.addEventListener("mousedown",s),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",i)}},[e,n,r])}const We=({isPlaying:e,onToggle:n})=>t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":e?"Pause":"Play","aria-pressed":e,onClick:n,children:e?t.jsx(Ee,{}):t.jsx(Le,{})}),_e=({video:e})=>{const[n,r]=o.useState(0),[s,i]=o.useState(0),[u,d]=o.useState(0);o.useEffect(()=>{if(!e)return;const x=()=>r(e.currentTime),a=()=>i(Number.isFinite(e.duration)?e.duration:0),l=()=>{const f=e.buffered;if(!f||f.length===0){d(0);return}let g=f.end(f.length-1);for(let k=0;k<f.length;k++)if(f.start(k)<=e.currentTime&&e.currentTime<=f.end(k)){g=f.end(k);break}d(g)};return x(),a(),l(),e.addEventListener("timeupdate",x),e.addEventListener("durationchange",a),e.addEventListener("loadedmetadata",a),e.addEventListener("progress",l),e.addEventListener("timeupdate",l),()=>{e.removeEventListener("timeupdate",x),e.removeEventListener("durationchange",a),e.removeEventListener("loadedmetadata",a),e.removeEventListener("progress",l),e.removeEventListener("timeupdate",l)}},[e]);const c=s>0,m=c?n/s*100:0,h=c?u/s*100:0,b=x=>{if(!e||!c)return;const a=Number(x.target.value)/100*s;e.currentTime=a,r(a)};return t.jsxs("div",{className:"gvp-seek",children:[t.jsxs("div",{className:"gvp-seek-track",children:[t.jsx("div",{className:"gvp-seek-buffered",style:{width:`${h}%`}}),t.jsx("div",{className:"gvp-seek-progress",style:{width:`${m}%`}})]}),t.jsx("input",{type:"range",className:"gvp-seek-input",min:0,max:100,step:.1,value:m,onChange:b,disabled:!c,"aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(s),"aria-valuenow":Math.floor(n)})]})},Ue=({video:e})=>{const[n,r]=o.useState(0),[s,i]=o.useState(0);return o.useEffect(()=>{if(!e)return;const u=()=>r(e.currentTime),d=()=>i(Number.isFinite(e.duration)?e.duration:0);return u(),d(),e.addEventListener("timeupdate",u),e.addEventListener("durationchange",d),e.addEventListener("loadedmetadata",d),()=>{e.removeEventListener("timeupdate",u),e.removeEventListener("durationchange",d),e.removeEventListener("loadedmetadata",d)}},[e]),t.jsxs("span",{className:"gvp-time","aria-live":"off",children:[X(n)," / ",X(s)]})},qe=({video:e})=>{const[n,r]=o.useState(1),[s,i]=o.useState(!1);o.useEffect(()=>{if(!e)return;const h=()=>{r(e.volume),i(e.muted)};return h(),e.addEventListener("volumechange",h),()=>e.removeEventListener("volumechange",h)},[e]);const u=()=>{e&&(e.muted=!e.muted)},d=h=>{if(!e)return;const b=Number(h.target.value)/100;e.volume=b,b>0&&e.muted&&(e.muted=!1)};let c=ye;s||n===0?c=Se:n<.5&&(c=Ne);const m=s?0:Math.round(n*100);return t.jsxs("div",{className:N("gvp-volume",!G&&"is-expandable"),children:[t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":s?"Unmute":"Mute","aria-pressed":s,onClick:u,children:t.jsx(c,{})}),!G&&t.jsxs("div",{className:"gvp-volume-slider-wrap",children:[t.jsx("div",{className:"gvp-volume-track",children:t.jsx("div",{className:"gvp-volume-fill",style:{width:`${m}%`}})}),t.jsx("input",{type:"range",className:"gvp-volume-input",min:0,max:100,step:1,value:m,onChange:d,"aria-label":"Volume","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":m})]})]})},Oe=[.5,.75,1,1.25,1.5,2],Ze=({video:e})=>{const[n,r]=o.useState(1),[s,i]=o.useState(!1),u=o.useRef(null);o.useEffect(()=>{if(!e)return;const h=()=>r(e.playbackRate);return h(),e.addEventListener("ratechange",h),()=>e.removeEventListener("ratechange",h)},[e]);const d=o.useCallback(()=>i(!1),[]);z(s,u,d);const c=h=>{e&&(e.playbackRate=h),r(h),i(!1)},m=n===1?"1×":`${n}×`;return t.jsxs("div",{className:"gvp-speed",ref:u,children:[t.jsxs("button",{type:"button",className:"gvp-ctrl-btn gvp-speed-btn","aria-haspopup":"listbox","aria-expanded":s,"aria-label":`Playback speed: ${m}`,onClick:()=>i(h=>!h),children:[t.jsx(He,{}),t.jsx("span",{className:"gvp-speed-label",children:m})]}),s&&t.jsx("ul",{className:"gvp-speed-menu",role:"listbox","aria-label":"Playback speed",children:Oe.map(h=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":h===n,className:N("gvp-speed-menu-item",h===n&&"is-active"),onClick:()=>c(h),children:h===1?"Normal":`${h}×`})},h))})]})},Fe=({levels:e,currentLevel:n,selectedLevel:r,onSelect:s})=>{const[i,u]=o.useState(!1),d=o.useRef(null),c=o.useCallback(()=>u(!1),[]);if(z(i,d,c),e.length<2)return null;const m=a=>{s==null||s(a),u(!1)},h=[...e].sort((a,l)=>l.height-a.height),b=e.find(a=>a.index===n);let x;if(r<0)x=b?`Auto (${b.label})`:"Auto";else{const a=e.find(l=>l.index===r);x=(a==null?void 0:a.label)??"Auto"}return t.jsxs("div",{className:"gvp-quality",ref:d,children:[t.jsxs("button",{type:"button",className:"gvp-ctrl-btn gvp-quality-btn","aria-haspopup":"listbox","aria-expanded":i,"aria-label":`Quality: ${x}`,onClick:()=>u(a=>!a),children:[t.jsx(Ve,{}),t.jsx("span",{className:"gvp-quality-label",children:x})]}),i&&t.jsxs("ul",{className:"gvp-quality-menu",role:"listbox","aria-label":"Quality",children:[t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":r<0,className:N("gvp-quality-menu-item",r<0&&"is-active"),onClick:()=>m(Re.index),children:b?`Auto (${b.label})`:"Auto"})}),h.map(a=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":a.index===r,className:N("gvp-quality-menu-item",a.index===r&&"is-active"),onClick:()=>m(a.index),children:a.label})},a.index))]})]})},Ye=({video:e})=>{const[n,r]=o.useState([]),[s,i]=o.useState(-1),[u,d]=o.useState(!1),c=o.useRef(null),m=o.useCallback(a=>{const l=[];for(let g=0;g<a.length;g++){const k=a[g];(k.kind==="subtitles"||k.kind==="captions")&&l.push({index:g,label:k.label||k.language||`Track ${g+1}`,language:k.language})}r(l);let f=-1;for(let g=0;g<a.length;g++)if(a[g].mode==="showing"){f=g;break}i(f)},[]);o.useEffect(()=>{if(!e){r([]),i(-1);return}const a=e.textTracks;m(a);const l=()=>m(a);if(typeof a.addEventListener=="function")return a.addEventListener("addtrack",l),a.addEventListener("removetrack",l),a.addEventListener("change",l),()=>{a.removeEventListener("addtrack",l),a.removeEventListener("removetrack",l),a.removeEventListener("change",l)}},[e,m]);const h=o.useCallback(()=>d(!1),[]);z(u,c,h);const b=a=>{if(!e)return;const l=e.textTracks;for(let f=0;f<l.length;f++)l[f].mode=f===a?"showing":"hidden";i(a),d(!1)},x=()=>{if(!e)return;const a=e.textTracks;for(let l=0;l<a.length;l++)a[l].mode="hidden";i(-1),d(!1)};return n.length===0?null:t.jsxs("div",{className:"gvp-captions",ref:c,children:[t.jsx("button",{type:"button",className:N("gvp-ctrl-btn",s>=0&&"is-active"),"aria-haspopup":"listbox","aria-expanded":u,"aria-label":"Captions","aria-pressed":s>=0,onClick:()=>d(a=>!a),children:t.jsx(Ie,{})}),u&&t.jsxs("ul",{className:"gvp-captions-menu",role:"listbox","aria-label":"Captions",children:[t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":s===-1,className:N("gvp-captions-menu-item",s===-1&&"is-active"),onClick:x,children:"Off"})}),n.map(a=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":a.index===s,className:N("gvp-captions-menu-item",a.index===s&&"is-active"),onClick:()=>b(a.index),children:a.label})},a.index))]})]})},Qe=({video:e})=>{const[n,r]=o.useState(!1),[s,i]=o.useState(!1);if(o.useEffect(()=>{i(!0)},[]),o.useEffect(()=>{if(!e)return;const d=()=>r(!0),c=()=>r(!1);return e.addEventListener("enterpictureinpicture",d),e.addEventListener("leavepictureinpicture",c),()=>{e.removeEventListener("enterpictureinpicture",d),e.removeEventListener("leavepictureinpicture",c)}},[e]),!s||!document.pictureInPictureEnabled)return null;const u=()=>{document.pictureInPictureElement?document.exitPictureInPicture().catch(()=>{}):e==null||e.requestPictureInPicture().catch(()=>{})};return t.jsx("button",{type:"button",className:N("gvp-ctrl-btn",n&&"is-active"),"aria-label":n?"Exit picture-in-picture":"Picture-in-picture","aria-pressed":n,onClick:u,children:t.jsx(Pe,{})})},ze=({container:e,video:n})=>{const[r,s]=o.useState(!1);if(o.useEffect(()=>{if(Q)return;const m=()=>s(D.element()===e);return m(),D.onChange(m)},[e]),!(D.isSupported()||Q&&n!==null&&typeof n.webkitEnterFullscreen=="function"))return null;const u=()=>{var m;if(Q){(m=n==null?void 0:n.webkitEnterFullscreen)==null||m.call(n);return}r?D.exit().catch(()=>{}):e&&D.request(e).catch(()=>{})},d=r?Te:Me,c=r?"Exit fullscreen":"Enter fullscreen";return t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":c,"aria-pressed":r,onClick:u,children:t.jsx(d,{})})};function ee(e,n,r){const s=e==null?void 0:e.trim();if(s)return s;if(n){try{const u=new Intl.DisplayNames(void 0,{type:"language"}).of(n);if(u&&u!==n)return u}catch{}return n}return`Audio ${r+1}`}const ne=o.forwardRef(({src:e,hlsConfig:n,isHls:r,autoPlay:s,children:i,onAudioTracks:u,audioTrackIndex:d,onQualityLevels:c,onCurrentLevel:m,qualityLevelIndex:h,...b},x)=>{const a=o.useRef(null),l=o.useRef(null),f=o.useRef(u);f.current=u;const g=o.useRef(c);g.current=c;const k=o.useRef(m);k.current=m,o.useImperativeHandle(x,()=>a.current);const B=globalThis.window!==void 0&&H.isSupported(),M=!!r||B&&typeof e=="string"&&e.endsWith(".m3u8");return o.useEffect(()=>{var U,$,_;if(!e)return;const v=a.current;if(!v)return;const S=p=>{var C;(C=f.current)==null||C.call(f,p)},y=p=>{var C;(C=g.current)==null||C.call(g,p)},P=p=>{var C;(C=k.current)==null||C.call(k,p)},V=()=>{s&&v.play().catch(()=>{})};for(l.current&&(l.current.destroy(),l.current=null),v.pause(),v.removeAttribute("src");v.firstChild;)v.firstChild.remove();S([]),y([]),P(-1);let A;if(M){const p=new H(n);l.current=p;const C=()=>{const E=p.audioTracks.map((w,R)=>({index:R,label:ee(w.name,w.lang,R),lang:w.lang||void 0}));S(E)},I=()=>{const E=p.levels.map((w,R)=>({index:R,height:w.height||0,label:De(w.height||0,R)}));y(E)};p.on(H.Events.MANIFEST_PARSED,V),p.on(H.Events.MANIFEST_PARSED,I),p.on(H.Events.LEVELS_UPDATED,I),p.on(H.Events.LEVEL_SWITCHED,(E,w)=>{P(w.level)}),p.on(H.Events.AUDIO_TRACKS_UPDATED,C),p.on(H.Events.AUDIO_TRACK_SWITCHED,C),p.on(H.Events.ERROR,(E,w)=>{w.fatal&&(p.destroy(),l.current=null)}),p.attachMedia(v),p.loadSource(e)}else{v.src=e,v.load(),v.addEventListener("loadedmetadata",V,{once:!0});const p=v.audioTracks;if(p){const C=()=>{const I=[];for(let E=0;E<p.length;E++){const w=p[E];I.push({index:E,label:ee(w.label,w.language,E),lang:w.language||void 0})}S(I)};(U=p.addEventListener)==null||U.call(p,"addtrack",C),($=p.addEventListener)==null||$.call(p,"removetrack",C),(_=p.addEventListener)==null||_.call(p,"change",C),p.length>0&&C(),A=()=>{var I,E,w;(I=p.removeEventListener)==null||I.call(p,"addtrack",C),(E=p.removeEventListener)==null||E.call(p,"removetrack",C),(w=p.removeEventListener)==null||w.call(p,"change",C)}}}return()=>{for(v.removeEventListener("loadedmetadata",V),A==null||A(),l.current&&(l.current.destroy(),l.current=null),v.pause(),v.removeAttribute("src");v.firstChild;)v.firstChild.remove();v.load(),S([]),y([]),P(-1)}},[e,M,n,s]),o.useEffect(()=>{if(h==null)return;const v=l.current;v&&v.currentLevel!==h&&(v.currentLevel=h)},[h]),o.useEffect(()=>{var y;if(d==null||d<0)return;const v=l.current;if(v){v.audioTrack!==d&&(v.audioTrack=d);return}const S=(y=a.current)==null?void 0:y.audioTracks;if(S)for(let P=0;P<S.length;P++)S[P].enabled=P===d},[d]),t.jsx("video",{ref:a,...b,children:i})});ne.displayName="HLSPlayer";function se(e){if(!e)return null;if(/^[A-Za-z0-9_-]{11}$/.test(e))return e;let n;try{n=new URL(e)}catch{return null}const r=n.hostname.replace(/^www\./,"");if(r==="youtu.be"){const s=n.pathname.slice(1).split("/")[0];return/^[A-Za-z0-9_-]{11}$/.test(s)?s:null}if(r==="youtube.com"||r==="m.youtube.com"||r==="music.youtube.com"||r==="youtube-nocookie.com"){const s=n.searchParams.get("v");if(s&&/^[A-Za-z0-9_-]{11}$/.test(s))return s;const i=/^\/(?:embed|shorts|v|live)\/([A-Za-z0-9_-]{11})/.exec(n.pathname);if(i)return i[1]}return null}function re(e){try{const n=new URL(e),r=n.searchParams.get("t")??n.searchParams.get("start");if(!r)return null;if(/^\d+s?$/.test(r))return Number.parseInt(r,10);const s=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(r);if(s){const i=Number.parseInt(s[1]??"0",10),u=Number.parseInt(s[2]??"0",10),d=Number.parseInt(s[3]??"0",10),c=i*3600+u*60+d;return c>0?c:null}}catch{}return null}function oe(e,n={}){const{autoPlay:r=!1,muted:s=!0,loop:i=!1,controls:u=!0,startSeconds:d}=n,c=new URLSearchParams({rel:"0",modestbranding:"1",playsinline:"1",controls:u?"1":"0"});return r?(c.set("autoplay","1"),c.set("mute","1")):s&&c.set("mute","1"),i&&(c.set("loop","1"),c.set("playlist",e)),d&&d>0&&c.set("start",String(d)),`https://www.youtube-nocookie.com/embed/${e}?${c.toString()}`}const Ke=({tracks:e,activeIndex:n,onSelect:r})=>{const[s,i]=o.useState(!1),u=o.useRef(null);o.useEffect(()=>{if(!s)return;const c=h=>{u.current&&!u.current.contains(h.target)&&i(!1)},m=h=>{h.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",c),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",m)}},[s]);const d=e.find(c=>c.index===n)??e[0];return t.jsxs("div",{className:"gvp-audio",ref:u,children:[t.jsxs("button",{type:"button",className:"gvp-audio-btn","aria-haspopup":"listbox","aria-expanded":s,"aria-label":"Audio track",onClick:()=>i(c=>!c),children:[t.jsx(je,{}),t.jsx("span",{className:"gvp-audio-label",children:d==null?void 0:d.label}),t.jsx(Ae,{})]}),s&&t.jsx("ul",{className:"gvp-audio-menu",role:"listbox","aria-label":"Audio tracks",children:e.map(c=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":c.index===n,className:N("gvp-audio-menu-item",c.index===n&&"is-active"),onClick:()=>{r(c.index),i(!1)},children:c.label})},c.index))})]})},Je=({src:e,poster:n,showDeviceToggle:r=!0,defaultDevice:s="desktop",hoverPlay:i=!1,tooltipText:u,onClose:d,className:c="",muted:m=!0,loop:h=!1,controls:b=!0,autoPlay:x=!1,frameMaxWidth:a,aspectRatio:l,hlsConfig:f,children:g})=>{const k=o.useRef(null),B=o.useRef(null),[M,v]=o.useState(s),[S,y]=o.useState(!1),[P,V]=o.useState(!1),[A,U]=o.useState([]),[$,_]=o.useState(-1),[p,C]=o.useState([]),[I,E]=o.useState(-1),[w,R]=o.useState(-1),[ae,le]=o.useState(null),[ie,ce]=o.useState(null),ue=o.useCallback(j=>{k.current=j,ce(j)},[]),W=b===!0||b==="custom",F=b==="native",q=o.useMemo(()=>se(e),[e]),T=q!==null,de=o.useMemo(()=>M==="mobile"?(l==null?void 0:l.mobile)??"9/16":(l==null?void 0:l.desktop)??"16/9",[M,l]),he=o.useMemo(()=>M==="mobile"?(a==null?void 0:a.mobile)??"420px":(a==null?void 0:a.desktop)??"960px",[M,a]),pe=o.useMemo(()=>q?oe(q,{autoPlay:x,muted:m,loop:h,controls:W?!0:F,startSeconds:re(e)}):null,[q,e,x,m,h,W,F]),me=o.useCallback(j=>{U(j),_(-1)},[]),fe=o.useCallback(j=>{C(j),R(-1)},[]),O=o.useCallback(async()=>{const j=k.current;if(j){if(B.current)try{await B.current}catch{}j.pause()}},[]),Z=o.useCallback(async()=>{const j=k.current;if(j)try{j.readyState<2&&j.load();const K=j.play();B.current=K,await K,y(!0)}catch{y(!1)}finally{B.current=null}},[]),ge=o.useCallback(()=>{!i||T||Z()},[i,T,Z]),ve=o.useCallback(()=>{!i||T||O().then(()=>y(!1))},[i,T,O]),Y=o.useCallback(async()=>{const j=k.current;j&&(j.paused?await Z():(await O(),y(!1)))},[Z,O]),xe=!T&&A.length>1;return t.jsxs("div",{ref:le,className:N("gvp-root",c),style:{width:he,aspectRatio:de},onMouseEnter:()=>{V(!0),ge()},onMouseLeave:()=>{V(!1),ve()},children:[T?t.jsx("iframe",{className:"gvp-video gvp-youtube",src:pe??void 0,title:"YouTube video player",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,referrerPolicy:"strict-origin-when-cross-origin"}):t.jsx(ne,{ref:ue,src:e,poster:n,muted:m,loop:h,playsInline:!0,preload:"metadata",controls:F,autoPlay:x,hlsConfig:f,className:"gvp-video",onPlay:()=>y(!0),onPause:()=>y(!1),onAudioTracks:me,audioTrackIndex:$,onQualityLevels:fe,onCurrentLevel:E,qualityLevelIndex:w,children:g}),!T&&t.jsx("div",{className:"gvp-vignette"}),r&&t.jsx("div",{className:"gvp-toggle",children:t.jsxs("div",{className:"gvp-toggle-pill",children:[t.jsx("button",{type:"button",onClick:()=>v("desktop"),className:N("gvp-toggle-btn",M==="desktop"&&"is-active"),"aria-label":"Desktop view","aria-pressed":M==="desktop",children:t.jsx(be,{})}),t.jsx("div",{className:"gvp-toggle-divider"}),t.jsx("button",{type:"button",onClick:()=>v("mobile"),className:N("gvp-toggle-btn",M==="mobile"&&"is-active"),"aria-label":"Mobile view","aria-pressed":M==="mobile",children:t.jsx(ke,{})})]})}),d&&t.jsx("button",{type:"button",onClick:d,className:"gvp-close","aria-label":"Close",children:t.jsx(Ce,{})}),xe&&t.jsx(Ke,{tracks:A,activeIndex:$>=0?$:A[0].index,onSelect:_}),!T&&W&&t.jsx("button",{type:"button",className:"gvp-click-layer",onClick:()=>void Y(),"aria-label":S?"Pause":"Play"}),!T&&!W&&!S&&t.jsx("div",{className:"gvp-play-wrap",children:t.jsxs("button",{type:"button",onClick:()=>void Y(),onMouseEnter:()=>V(!0),onMouseLeave:()=>V(!1),className:"gvp-play","aria-label":"Play",children:[t.jsx(we,{}),u&&P&&t.jsx("span",{className:"gvp-tooltip",role:"tooltip",children:u})]})}),!T&&W&&t.jsx($e,{video:ie,isPlaying:S,container:ae,onTogglePlay:()=>void Y(),qualityLevels:p,currentLevel:I,selectedLevel:w,onSelectLevel:R}),!T&&!W&&t.jsx("div",{className:"gvp-bottom-fade"})]})};exports.ReactVideoPlayer=Je;exports.parseYouTubeId=se;exports.parseYouTubeStart=re;exports.youTubeEmbedUrl=oe;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),O=require("hls.js");function Pe(e){var s,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(s=0;s<o;s++)e[s]&&(n=Pe(e[s]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function V(){for(var e,s,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(s=Pe(e))&&(r&&(r+=" "),r+=s);return r}const Ne="gvp-icon",M=e=>e?`${Ne} ${e}`:Ne,it=({className:e})=>t.jsxs("svg",{className:M(e),width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),t.jsx("path",{d:"M11 15H13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),t.jsx("path",{d:"M7 22H17",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),lt=({className:e})=>t.jsxs("svg",{className:M(e),width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),t.jsx("path",{d:"M11 19H13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{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",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"})]}),ct=({className:e})=>t.jsx("svg",{className:M(e),width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{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",fill:"currentColor"})}),ut=({className:e})=>t.jsx("svg",{className:M(e),width:"22",height:"22",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{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",fill:"currentColor"})}),dt=({className:e})=>t.jsxs("svg",{className:M(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),ht=({className:e})=>t.jsx("svg",{className:M(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{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",fill:"currentColor"})}),ft=({className:e})=>t.jsxs("svg",{className:M(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1",fill:"currentColor"}),t.jsx("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1",fill:"currentColor"})]}),mt=({className:e})=>t.jsxs("svg",{className:M(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),pt=({className:e})=>t.jsxs("svg",{className:M(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),gt=({className:e})=>t.jsxs("svg",{className:M(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M16 9L22 15M22 9L16 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),vt=({className:e})=>t.jsx("svg",{className:M(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M4 9V4H9M15 4H20V9M20 15V20H15M9 20H4V15",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})}),xt=({className:e})=>t.jsx("svg",{className:M(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M9 4V9H4M15 9V4H20M15 20V15H20M9 15H4V20",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})}),bt=({className:e})=>t.jsxs("svg",{className:M(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("rect",{x:"12",y:"12",width:"8",height:"5",rx:"1",fill:"currentColor"})]}),kt=({className:e})=>t.jsxs("svg",{className:M(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"3",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M7 12H11M13 12H17M7 15H9M11 15H13M15 15H17",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Ct=({className:e})=>t.jsxs("svg",{className:M(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M12 8V12L14.5 14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),wt=({className:e})=>t.jsxs("svg",{className:M(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15Z",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M3 12C3 12.6 3.08 13.18 3.23 13.73L4.6 14.5C4.86 14.65 5.02 14.94 5 15.24C4.98 15.58 4.96 15.92 5.07 16.24C5.18 16.56 5.39 16.83 5.62 17.08C5.83 17.3 6.13 17.4 6.42 17.36L7.99 17.13C8.28 17.09 8.57 17.21 8.74 17.45C9.07 17.93 9.49 18.34 9.97 18.66C10.21 18.83 10.34 19.11 10.31 19.4L10.13 20.97C10.1 21.26 10.21 21.55 10.43 21.74C10.91 22.16 11.45 22 12 22C12.55 22 13.09 22.16 13.57 21.74C13.79 21.55 13.9 21.26 13.87 20.97L13.69 19.4C13.66 19.11 13.79 18.83 14.03 18.66",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),jt=({className:e})=>t.jsx("svg",{className:M(e),width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M6 9L12 15L18 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Lt=({className:e})=>t.jsxs("svg",{className:M(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M16.5 18.5V5.5C16.5 4.73408 15.6514 4.27388 15.0101 4.69288L6.91993 9.98432C6.33563 10.3653 6.33563 11.0347 6.91993 11.4157L15.0101 16.7071C15.6514 17.1261 16.5 16.6659 16.5 15.9V18.5Z",fill:"currentColor"}),t.jsx("path",{d:"M6 5V19",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Et=({className:e})=>t.jsxs("svg",{className:M(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M7.5 5.5V18.5C7.5 19.2659 8.34856 19.7261 8.98990 19.3071L17.0801 14.0157C17.6644 13.6347 17.6644 12.9653 17.0801 12.5843L8.98990 7.29288C8.34856 6.87388 7.5 7.33408 7.5 8.1V5.5Z",fill:"currentColor"}),t.jsx("path",{d:"M18 5V19",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});function me(e){if(!Number.isFinite(e)||e<0)return"--:--";const s=Math.floor(e),n=Math.floor(s/3600),r=Math.floor(s%3600/60),i=(s%60).toString().padStart(2,"0");if(n>0){const l=r.toString().padStart(2,"0");return`${n}:${l}:${i}`}return`${r}:${i}`}const Nt={index:-1};function yt(e,s){return e>0?`${e}p`:`Level ${s+1}`}function ye(e){const s=e.trim().split(":");if(s.length<2||s.length>3)return NaN;const n=s.map(Number);return n.some(r=>!Number.isFinite(r))?NaN:n.length===3?n[0]*3600+n[1]*60+n[2]:n[0]*60+n[1]}function St(e,s){try{return new URL(e,s).href}catch{return e}}function Mt(e,s){const n=[],r=e.replace(/\r/g,"").split(`
|
|
3
|
+
`);for(let o=0;o<r.length;o++){const i=r[o].indexOf("-->");if(i===-1)continue;const l=ye(r[o].slice(0,i)),u=ye(r[o].slice(i+3));if(!Number.isFinite(l)||!Number.isFinite(u))continue;const p=(r[o+1]??"").trim();if(!p)continue;const d=p.indexOf("#xywh=");let w=p,j=0,c=0,h=0,k=0;if(d!==-1){w=p.slice(0,d);const b=p.slice(d+6).split(",").map(Number);b.length===4&&b.every(Number.isFinite)&&([j,c,h,k]=b)}n.push({start:l,end:u,url:St(w,s),x:j,y:c,w:h,h:k})}return n.sort((o,i)=>o.start-i.start),n}function Tt(e){return{cues:e,cueAt(s){if(e.length===0)return null;let n=0,r=e.length-1,o=e[0];for(;n<=r;){const i=n+r>>1,l=e[i];if(s<l.start)r=i-1;else if(s>l.end)o=l,n=i+1;else return l}return o}}}function Se(e){const s=e.trim().split(":");if(s.length<2||s.length>3)return NaN;const n=s.map(Number);return n.some(r=>!Number.isFinite(r))?NaN:n.length===3?n[0]*3600+n[1]*60+n[2]:n[0]*60+n[1]}function Pt(e){const s=[],n=e.replace(/\r/g,"").split(`
|
|
4
|
+
`);for(let r=0;r<n.length;r++){const o=n[r].indexOf("-->");if(o===-1)continue;const i=Se(n[r].slice(0,o)),l=Se(n[r].slice(o+3));if(!Number.isFinite(i)||!Number.isFinite(l))continue;const u=(n[r+1]??"").trim();u&&s.push({start:i,end:l,title:u})}return s.sort((r,o)=>r.start-o.start),s}function It(e,s){const n=e.filter(r=>Number.isFinite(r.start)&&r.start>=0&&r.title).sort((r,o)=>r.start-o.start);return n.map((r,o)=>{var i;return{start:r.start,end:Number.isFinite(r.end)?r.end:((i=n[o+1])==null?void 0:i.start)??s,title:r.title}})}function Vt(e,s){for(const n of e)if(s>=n.start&&s<n.end)return n;return null}const Me=(()=>{if(typeof navigator>"u")return!1;const e=navigator.userAgent;return/iPad|iPhone|iPod/.test(e)||e.includes("Mac")&&navigator.maxTouchPoints>1})(),fe=typeof navigator>"u"?!1:/iPhone|iPod/.test(navigator.userAgent),Ht=3e3,q={isSupported(){return typeof document>"u"?!1:!!(document.fullscreenEnabled||document.webkitFullscreenEnabled)},element(){return typeof document>"u"?null:document.fullscreenElement??document.webkitFullscreenElement??null},request(e){const s=e.requestFullscreen??e.webkitRequestFullscreen;return s?s.call(e):Promise.reject(new Error("Fullscreen not supported"))},exit(){const e=document.exitFullscreen??document.webkitExitFullscreen;return e?e.call(document):Promise.reject(new Error("Fullscreen not supported"))},onChange(e){return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e)}}},At=({video:e,isPlaying:s,container:n,onTogglePlay:r,qualityLevels:o=[],currentLevel:i=-1,selectedLevel:l=-1,onSelectLevel:u,thumbnails:p,chapters:d,hasPrev:w=!1,hasNext:j=!1,onPrev:c,onNext:h})=>{const[k,b]=a.useState(!0),y=a.useRef(null),L=a.useCallback(()=>{y.current!==null&&(clearTimeout(y.current),y.current=null)},[]),A=a.useCallback(()=>{L(),s&&(y.current=setTimeout(()=>b(!1),Ht))},[L,s]),g=a.useCallback(()=>{b(!0),A()},[A]);return a.useEffect(()=>{if(!s){L(),b(!0);return}return A(),L},[s,A,L]),a.useEffect(()=>{if(!n)return;const v=()=>g();return n.addEventListener("mousemove",v),n.addEventListener("touchstart",v),n.addEventListener("focusin",v),()=>{n.removeEventListener("mousemove",v),n.removeEventListener("touchstart",v),n.removeEventListener("focusin",v)}},[n,g]),a.useEffect(()=>{if(!n||!e)return;const v=x=>{if(!(!n.contains(document.activeElement)||x.target.tagName==="INPUT"&&x.key!==" "))switch(x.key){case" ":case"k":x.preventDefault(),r(),g();break;case"ArrowLeft":x.preventDefault(),e.currentTime=Math.max(0,e.currentTime-5),g();break;case"ArrowRight":x.preventDefault(),e.currentTime=Math.min(e.duration||0,e.currentTime+5),g();break;case"ArrowUp":x.preventDefault(),e.volume=Math.min(1,e.volume+.1),e.muted&&(e.muted=!1),g();break;case"ArrowDown":x.preventDefault(),e.volume=Math.max(0,e.volume-.1),g();break;case"m":e.muted=!e.muted,g();break;case"f":q.element()===n?q.exit().catch(()=>{}):q.request(n).catch(()=>{}),g();break;case"p":document.pictureInPictureElement?document.exitPictureInPicture().catch(()=>{}):document.pictureInPictureEnabled&&e.requestPictureInPicture().catch(()=>{}),g();break}};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[n,e,r,g]),t.jsx("div",{role:"toolbar","aria-label":"Video controls",className:V("gvp-controls",!k&&"is-hidden"),onMouseEnter:L,onMouseLeave:A,children:t.jsxs("div",{className:"gvp-controls-row",children:[(w||j)&&t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":"Previous video",disabled:!w,onClick:c,children:t.jsx(Lt,{})}),t.jsx(Rt,{isPlaying:s,onToggle:r}),(w||j)&&t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":"Next video",disabled:!j,onClick:h,children:t.jsx(Et,{})}),t.jsx(Dt,{video:e,thumbnails:p,chapters:d}),t.jsx(Ft,{video:e}),t.jsx(_t,{video:e}),t.jsx(Zt,{levels:o,currentLevel:i,selectedLevel:l,onSelect:u}),t.jsx(qt,{video:e}),t.jsx(Ut,{video:e}),t.jsx(Yt,{video:e}),t.jsx(Qt,{container:n,video:e})]})})};function pe(e,s,n){a.useEffect(()=>{if(!e)return;const r=i=>{s.current&&!s.current.contains(i.target)&&n()},o=i=>{i.key==="Escape"&&n()};return document.addEventListener("mousedown",r),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",o)}},[e,s,n])}const Rt=({isPlaying:e,onToggle:s})=>t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":e?"Pause":"Play","aria-pressed":e,onClick:s,children:e?t.jsx(ft,{}):t.jsx(ht,{})});function $t(e){const[s,n]=a.useState(null);return a.useEffect(()=>{if(!e){n(null);return}let r=!1;return fetch(e).then(o=>o.ok?o.text():Promise.reject(new Error("fetch failed"))).then(o=>{if(r)return;const i=Mt(o,new URL(e,location.href).href);n(i.length>0?Tt(i):null)}).catch(()=>{r||n(null)}),()=>{r=!0}},[e]),s}function Bt(e,s){const[n,r]=a.useState([]),o=typeof e=="string";return a.useEffect(()=>{if(!o||!e){r([]);return}let i=!1;return fetch(e).then(l=>l.ok?l.text():Promise.reject(new Error("fetch failed"))).then(l=>{i||r(Pt(l))}).catch(()=>{i||r([])}),()=>{i=!0}},[o,e]),o?n:Array.isArray(e)?It(e,s):[]}const Dt=({video:e,thumbnails:s,chapters:n})=>{var g;const[r,o]=a.useState(0),[i,l]=a.useState(0),[u,p]=a.useState(0),[d,w]=a.useState(null),j=a.useRef(null),c=$t(s),h=Bt(n,i);a.useEffect(()=>{if(!e)return;const v=()=>o(e.currentTime),x=()=>l(Number.isFinite(e.duration)?e.duration:0),E=()=>{const T=e.buffered;if(!T||T.length===0){p(0);return}let D=T.end(T.length-1);for(let $=0;$<T.length;$++)if(T.start($)<=e.currentTime&&e.currentTime<=T.end($)){D=T.end($);break}p(D)};return v(),x(),E(),e.addEventListener("timeupdate",v),e.addEventListener("durationchange",x),e.addEventListener("loadedmetadata",x),e.addEventListener("progress",E),e.addEventListener("timeupdate",E),()=>{e.removeEventListener("timeupdate",v),e.removeEventListener("durationchange",x),e.removeEventListener("loadedmetadata",x),e.removeEventListener("progress",E),e.removeEventListener("timeupdate",E)}},[e]);const k=i>0,b=k?r/i*100:0,y=k?u/i*100:0,L=v=>{if(!e||!k)return;const x=Number(v.target.value)/100*i;e.currentTime=x,o(x)},A=v=>{const x=j.current;if(!x||!k)return;const E=x.getBoundingClientRect(),T=Math.min(Math.max(v-E.left,0),E.width);w({time:T/E.width*i,x:T})};return t.jsxs("div",{className:"gvp-seek",onPointerMove:v=>A(v.clientX),onPointerLeave:()=>w(null),children:[t.jsxs("div",{className:"gvp-seek-track",ref:j,children:[t.jsx("div",{className:"gvp-seek-buffered",style:{width:`${y}%`}}),t.jsx("div",{className:"gvp-seek-progress",style:{width:`${b}%`}}),k&&h.map(v=>v.start>0&&v.start<i&&t.jsx("div",{className:"gvp-seek-chapter-tick",style:{left:`${v.start/i*100}%`}},`${v.start}-${v.title}`))]}),d&&t.jsx(Wt,{hover:d,track:c,chapters:h,trackWidth:((g=j.current)==null?void 0:g.clientWidth)??0}),t.jsx("input",{type:"range",className:"gvp-seek-input",min:0,max:100,step:.1,value:b,onChange:L,disabled:!k,"aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(i),"aria-valuenow":Math.floor(r)})]})},Wt=({hover:e,track:s,chapters:n,trackWidth:r})=>{const o=(s==null?void 0:s.cueAt(e.time))??null,i=o!==null&&o.w>0&&o.h>0,l=Vt(n,e.time),p=(i?o.w:0)/2,d=r>0?Math.min(Math.max(e.x,p),r-p):e.x;return t.jsxs("div",{className:V("gvp-seek-preview",i&&"has-thumb"),style:{left:`${d}px`},children:[i&&t.jsx("div",{className:"gvp-seek-preview-thumb",style:{width:`${o.w}px`,height:`${o.h}px`,backgroundImage:`url(${JSON.stringify(o.url)})`,backgroundPosition:`-${o.x}px -${o.y}px`}}),l&&t.jsx("span",{className:"gvp-seek-preview-chapter",children:l.title}),t.jsx("span",{className:"gvp-seek-preview-time",children:me(e.time)})]})},Ft=({video:e})=>{const[s,n]=a.useState(0),[r,o]=a.useState(0);return a.useEffect(()=>{if(!e)return;const i=()=>n(e.currentTime),l=()=>o(Number.isFinite(e.duration)?e.duration:0);return i(),l(),e.addEventListener("timeupdate",i),e.addEventListener("durationchange",l),e.addEventListener("loadedmetadata",l),()=>{e.removeEventListener("timeupdate",i),e.removeEventListener("durationchange",l),e.removeEventListener("loadedmetadata",l)}},[e]),t.jsxs("span",{className:"gvp-time","aria-live":"off",children:[me(s)," / ",me(r)]})},Ut=({video:e})=>{const[s,n]=a.useState(1),[r,o]=a.useState(!1);a.useEffect(()=>{if(!e)return;const d=()=>{n(e.volume),o(e.muted)};return d(),e.addEventListener("volumechange",d),()=>e.removeEventListener("volumechange",d)},[e]);const i=()=>{e&&(e.muted=!e.muted)},l=d=>{if(!e)return;const w=Number(d.target.value)/100;e.volume=w,w>0&&e.muted&&(e.muted=!1)};let u=mt;r||s===0?u=gt:s<.5&&(u=pt);const p=r?0:Math.round(s*100);return t.jsxs("div",{className:V("gvp-volume",!Me&&"is-expandable"),children:[t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":r?"Unmute":"Mute","aria-pressed":r,onClick:i,children:t.jsx(u,{})}),!Me&&t.jsxs("div",{className:"gvp-volume-slider-wrap",children:[t.jsx("div",{className:"gvp-volume-track",children:t.jsx("div",{className:"gvp-volume-fill",style:{width:`${p}%`}})}),t.jsx("input",{type:"range",className:"gvp-volume-input",min:0,max:100,step:1,value:p,onChange:l,"aria-label":"Volume","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":p})]})]})},Ot=[.5,.75,1,1.25,1.5,2],_t=({video:e})=>{const[s,n]=a.useState(1),[r,o]=a.useState(!1),i=a.useRef(null);a.useEffect(()=>{if(!e)return;const d=()=>n(e.playbackRate);return d(),e.addEventListener("ratechange",d),()=>e.removeEventListener("ratechange",d)},[e]);const l=a.useCallback(()=>o(!1),[]);pe(r,i,l);const u=d=>{e&&(e.playbackRate=d),n(d),o(!1)},p=s===1?"1×":`${s}×`;return t.jsxs("div",{className:"gvp-speed",ref:i,children:[t.jsxs("button",{type:"button",className:"gvp-ctrl-btn gvp-speed-btn","aria-haspopup":"listbox","aria-expanded":r,"aria-label":`Playback speed: ${p}`,onClick:()=>o(d=>!d),children:[t.jsx(Ct,{}),t.jsx("span",{className:"gvp-speed-label",children:p})]}),r&&t.jsx("ul",{className:"gvp-speed-menu",role:"listbox","aria-label":"Playback speed",children:Ot.map(d=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":d===s,className:V("gvp-speed-menu-item",d===s&&"is-active"),onClick:()=>u(d),children:d===1?"Normal":`${d}×`})},d))})]})},Zt=({levels:e,currentLevel:s,selectedLevel:n,onSelect:r})=>{const[o,i]=a.useState(!1),l=a.useRef(null),u=a.useCallback(()=>i(!1),[]);if(pe(o,l,u),e.length<2)return null;const p=c=>{r==null||r(c),i(!1)},d=[...e].sort((c,h)=>h.height-c.height),w=e.find(c=>c.index===s);let j;if(n<0)j=w?`Auto (${w.label})`:"Auto";else{const c=e.find(h=>h.index===n);j=(c==null?void 0:c.label)??"Auto"}return t.jsxs("div",{className:"gvp-quality",ref:l,children:[t.jsxs("button",{type:"button",className:"gvp-ctrl-btn gvp-quality-btn","aria-haspopup":"listbox","aria-expanded":o,"aria-label":`Quality: ${j}`,onClick:()=>i(c=>!c),children:[t.jsx(wt,{}),t.jsx("span",{className:"gvp-quality-label",children:j})]}),o&&t.jsxs("ul",{className:"gvp-quality-menu",role:"listbox","aria-label":"Quality",children:[t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":n<0,className:V("gvp-quality-menu-item",n<0&&"is-active"),onClick:()=>p(Nt.index),children:w?`Auto (${w.label})`:"Auto"})}),d.map(c=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":c.index===n,className:V("gvp-quality-menu-item",c.index===n&&"is-active"),onClick:()=>p(c.index),children:c.label})},c.index))]})]})},qt=({video:e})=>{const[s,n]=a.useState([]),[r,o]=a.useState(-1),[i,l]=a.useState(!1),u=a.useRef(null),p=a.useCallback(c=>{const h=[];for(let b=0;b<c.length;b++){const y=c[b];(y.kind==="subtitles"||y.kind==="captions")&&h.push({index:b,label:y.label||y.language||`Track ${b+1}`,language:y.language})}n(h);let k=-1;for(let b=0;b<c.length;b++)if(c[b].mode==="showing"){k=b;break}o(k)},[]);a.useEffect(()=>{if(!e){n([]),o(-1);return}const c=e.textTracks;p(c);const h=()=>p(c);if(typeof c.addEventListener=="function")return c.addEventListener("addtrack",h),c.addEventListener("removetrack",h),c.addEventListener("change",h),()=>{c.removeEventListener("addtrack",h),c.removeEventListener("removetrack",h),c.removeEventListener("change",h)}},[e,p]);const d=a.useCallback(()=>l(!1),[]);pe(i,u,d);const w=c=>{if(!e)return;const h=e.textTracks;for(let k=0;k<h.length;k++)h[k].mode=k===c?"showing":"hidden";o(c),l(!1)},j=()=>{if(!e)return;const c=e.textTracks;for(let h=0;h<c.length;h++)c[h].mode="hidden";o(-1),l(!1)};return s.length===0?null:t.jsxs("div",{className:"gvp-captions",ref:u,children:[t.jsx("button",{type:"button",className:V("gvp-ctrl-btn",r>=0&&"is-active"),"aria-haspopup":"listbox","aria-expanded":i,"aria-label":"Captions","aria-pressed":r>=0,onClick:()=>l(c=>!c),children:t.jsx(kt,{})}),i&&t.jsxs("ul",{className:"gvp-captions-menu",role:"listbox","aria-label":"Captions",children:[t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":r===-1,className:V("gvp-captions-menu-item",r===-1&&"is-active"),onClick:j,children:"Off"})}),s.map(c=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":c.index===r,className:V("gvp-captions-menu-item",c.index===r&&"is-active"),onClick:()=>w(c.index),children:c.label})},c.index))]})]})},Yt=({video:e})=>{const[s,n]=a.useState(!1),[r,o]=a.useState(!1);if(a.useEffect(()=>{o(!0)},[]),a.useEffect(()=>{if(!e)return;const l=()=>n(!0),u=()=>n(!1);return e.addEventListener("enterpictureinpicture",l),e.addEventListener("leavepictureinpicture",u),()=>{e.removeEventListener("enterpictureinpicture",l),e.removeEventListener("leavepictureinpicture",u)}},[e]),!r||!document.pictureInPictureEnabled)return null;const i=()=>{document.pictureInPictureElement?document.exitPictureInPicture().catch(()=>{}):e==null||e.requestPictureInPicture().catch(()=>{})};return t.jsx("button",{type:"button",className:V("gvp-ctrl-btn",s&&"is-active"),"aria-label":s?"Exit picture-in-picture":"Picture-in-picture","aria-pressed":s,onClick:i,children:t.jsx(bt,{})})},Qt=({container:e,video:s})=>{const[n,r]=a.useState(!1);if(a.useEffect(()=>{if(fe)return;const p=()=>r(q.element()===e);return p(),q.onChange(p)},[e]),!(q.isSupported()||fe&&s!==null&&typeof s.webkitEnterFullscreen=="function"))return null;const i=()=>{var p;if(fe){(p=s==null?void 0:s.webkitEnterFullscreen)==null||p.call(s);return}n?q.exit().catch(()=>{}):e&&q.request(e).catch(()=>{})},l=n?xt:vt,u=n?"Exit fullscreen":"Enter fullscreen";return t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":u,"aria-pressed":n,onClick:i,children:t.jsx(l,{})})};function Te(e,s,n){const r=e==null?void 0:e.trim();if(r)return r;if(s){try{const i=new Intl.DisplayNames(void 0,{type:"language"}).of(s);if(i&&i!==s)return i}catch{}return s}return`Audio ${n+1}`}const Ie=a.forwardRef(({src:e,hlsConfig:s,isHls:n,autoPlay:r,children:o,onAudioTracks:i,audioTrackIndex:l,onQualityLevels:u,onCurrentLevel:p,qualityLevelIndex:d,...w},j)=>{const c=a.useRef(null),h=a.useRef(null),k=a.useRef(i);k.current=i;const b=a.useRef(u);b.current=u;const y=a.useRef(p);y.current=p,a.useImperativeHandle(j,()=>c.current);const L=globalThis.window!==void 0&&O.isSupported(),A=!!n||L&&typeof e=="string"&&e.endsWith(".m3u8");return a.useEffect(()=>{var $,X,G;if(!e)return;const g=c.current;if(!g)return;const v=f=>{var N;(N=k.current)==null||N.call(k,f)},x=f=>{var N;(N=b.current)==null||N.call(b,f)},E=f=>{var N;(N=y.current)==null||N.call(y,f)},T=()=>{r&&g.play().catch(()=>{})};for(h.current&&(h.current.destroy(),h.current=null),g.pause(),g.removeAttribute("src");g.firstChild;)g.firstChild.remove();v([]),x([]),E(-1);let D;if(A){const f=new O(s);h.current=f;const N=()=>{const S=f.audioTracks.map((C,_)=>({index:_,label:Te(C.name,C.lang,_),lang:C.lang||void 0}));v(S)},H=()=>{const S=f.levels.map((C,_)=>({index:_,height:C.height||0,label:yt(C.height||0,_)}));x(S)};f.on(O.Events.MANIFEST_PARSED,T),f.on(O.Events.MANIFEST_PARSED,H),f.on(O.Events.LEVELS_UPDATED,H),f.on(O.Events.LEVEL_SWITCHED,(S,C)=>{E(C.level)}),f.on(O.Events.AUDIO_TRACKS_UPDATED,N),f.on(O.Events.AUDIO_TRACK_SWITCHED,N),f.on(O.Events.ERROR,(S,C)=>{C.fatal&&(f.destroy(),h.current=null)}),f.attachMedia(g),f.loadSource(e)}else{g.src=e,g.load(),g.addEventListener("loadedmetadata",T,{once:!0});const f=g.audioTracks;if(f){const N=()=>{const H=[];for(let S=0;S<f.length;S++){const C=f[S];H.push({index:S,label:Te(C.label,C.language,S),lang:C.language||void 0})}v(H)};($=f.addEventListener)==null||$.call(f,"addtrack",N),(X=f.addEventListener)==null||X.call(f,"removetrack",N),(G=f.addEventListener)==null||G.call(f,"change",N),f.length>0&&N(),D=()=>{var H,S,C;(H=f.removeEventListener)==null||H.call(f,"addtrack",N),(S=f.removeEventListener)==null||S.call(f,"removetrack",N),(C=f.removeEventListener)==null||C.call(f,"change",N)}}}return()=>{for(g.removeEventListener("loadedmetadata",T),D==null||D(),h.current&&(h.current.destroy(),h.current=null),g.pause(),g.removeAttribute("src");g.firstChild;)g.firstChild.remove();g.load(),v([]),x([]),E(-1)}},[e,A,s,r]),a.useEffect(()=>{if(d==null)return;const g=h.current;g&&g.currentLevel!==d&&(g.currentLevel=d)},[d]),a.useEffect(()=>{var x;if(l==null||l<0)return;const g=h.current;if(g){g.audioTrack!==l&&(g.audioTrack=l);return}const v=(x=c.current)==null?void 0:x.audioTracks;if(v)for(let E=0;E<v.length;E++)v[E].enabled=E===l},[l]),t.jsx("video",{ref:c,...w,children:o})});Ie.displayName="HLSPlayer";function Ve(e){if(!e)return null;if(/^[A-Za-z0-9_-]{11}$/.test(e))return e;let s;try{s=new URL(e)}catch{return null}const n=s.hostname.replace(/^www\./,"");if(n==="youtu.be"){const r=s.pathname.slice(1).split("/")[0];return/^[A-Za-z0-9_-]{11}$/.test(r)?r:null}if(n==="youtube.com"||n==="m.youtube.com"||n==="music.youtube.com"||n==="youtube-nocookie.com"){const r=s.searchParams.get("v");if(r&&/^[A-Za-z0-9_-]{11}$/.test(r))return r;const o=/^\/(?:embed|shorts|v|live)\/([A-Za-z0-9_-]{11})/.exec(s.pathname);if(o)return o[1]}return null}function He(e){try{const s=new URL(e),n=s.searchParams.get("t")??s.searchParams.get("start");if(!n)return null;if(/^\d+s?$/.test(n))return Number.parseInt(n,10);const r=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(n);if(r){const o=Number.parseInt(r[1]??"0",10),i=Number.parseInt(r[2]??"0",10),l=Number.parseInt(r[3]??"0",10),u=o*3600+i*60+l;return u>0?u:null}}catch{}return null}function Ae(e,s={}){const{autoPlay:n=!1,muted:r=!0,loop:o=!1,controls:i=!0,startSeconds:l}=s,u=new URLSearchParams({rel:"0",modestbranding:"1",playsinline:"1",controls:i?"1":"0"});return n?(u.set("autoplay","1"),u.set("mute","1")):r&&u.set("mute","1"),o&&(u.set("loop","1"),u.set("playlist",e)),l&&l>0&&u.set("start",String(l)),`https://www.youtube-nocookie.com/embed/${e}?${u.toString()}`}const zt=({tracks:e,activeIndex:s,onSelect:n})=>{const[r,o]=a.useState(!1),i=a.useRef(null);a.useEffect(()=>{if(!r)return;const u=d=>{i.current&&!i.current.contains(d.target)&&o(!1)},p=d=>{d.key==="Escape"&&o(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",p)}},[r]);const l=e.find(u=>u.index===s)??e[0];return t.jsxs("div",{className:"gvp-audio",ref:i,children:[t.jsxs("button",{type:"button",className:"gvp-audio-btn","aria-haspopup":"listbox","aria-expanded":r,"aria-label":"Audio track",onClick:()=>o(u=>!u),children:[t.jsx(dt,{}),t.jsx("span",{className:"gvp-audio-label",children:l==null?void 0:l.label}),t.jsx(jt,{})]}),r&&t.jsx("ul",{className:"gvp-audio-menu",role:"listbox","aria-label":"Audio tracks",children:e.map(u=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":u.index===s,className:V("gvp-audio-menu-item",u.index===s&&"is-active"),onClick:()=>{n(u.index),o(!1)},children:u.label})},u.index))})]})},Kt=({src:e,poster:s,showDeviceToggle:n=!0,defaultDevice:r="desktop",hoverPlay:o=!1,tooltipText:i,onClose:l,className:u="",muted:p=!0,loop:d=!1,controls:w=!0,autoPlay:j=!1,frameMaxWidth:c,aspectRatio:h,hlsConfig:k,thumbnails:b,chapters:y,playlist:L,defaultIndex:A=0,autoAdvance:g=!0,onPlaylistChange:v,onPlay:x,onPause:E,onEnded:T,onTimeUpdate:D,onSeeked:$,onVolumeChange:X,onMilestone:G,onError:f,children:N})=>{const H=a.useRef(null),S=a.useRef(null),[C,_]=a.useState(r),[oe,Y]=a.useState(!1),[Re,ee]=a.useState(!1),[ae,$e]=a.useState([]),[ie,ge]=a.useState(-1),[Be,De]=a.useState([]),[We,Fe]=a.useState(-1),[ve,xe]=a.useState(-1),[Ue,Oe]=a.useState(null),[le,_e]=a.useState(null),Ze=a.useCallback(m=>{H.current=m,_e(m)},[]),F=a.useRef({onPlay:x,onPause:E,onEnded:T,onTimeUpdate:D,onSeeked:$,onVolumeChange:X,onMilestone:G,onError:f});F.current={onPlay:x,onPause:E,onEnded:T,onTimeUpdate:D,onSeeked:$,onVolumeChange:X,onMilestone:G,onError:f};const K=w===!0||w==="custom",ce=w==="native",Z=Array.isArray(L)&&L.length>0,qe=Z?Math.min(Math.max(A,0),L.length-1):0,[U,Ye]=a.useState(qe),R=Z?L[Math.min(U,L.length-1)]:null,Q=(R==null?void 0:R.src)??e??"",Qe=(R==null?void 0:R.poster)??s,ze=(R==null?void 0:R.thumbnails)??b,Ke=(R==null?void 0:R.chapters)??y,ue=a.useRef(!1),te=a.useCallback((m,P=!1)=>{if(!Z)return;const z=Math.min(Math.max(m,0),L.length-1);z!==U&&(ue.current=P,Ye(z),v==null||v(z,L[z]))},[Z,L,U,v]),Je=Z&&U>0,de=Z&&U<((L==null?void 0:L.length)??0)-1,ne=a.useMemo(()=>Ve(Q),[Q]),B=ne!==null,Xe=a.useMemo(()=>C==="mobile"?(h==null?void 0:h.mobile)??"9/16":(h==null?void 0:h.desktop)??"16/9",[C,h]),Ge=a.useMemo(()=>C==="mobile"?(c==null?void 0:c.mobile)??"420px":(c==null?void 0:c.desktop)??"960px",[C,c]),et=a.useMemo(()=>ne?Ae(ne,{autoPlay:j,muted:p,loop:d,controls:K?!0:ce,startSeconds:He(Q)}):null,[ne,Q,j,p,d,K,ce]),tt=a.useCallback(m=>{$e(m),ge(-1)},[]),nt=a.useCallback(m=>{De(m),xe(-1)},[]),re=a.useCallback(async()=>{const m=H.current;if(m){if(S.current)try{await S.current}catch{}m.pause()}},[]),J=a.useCallback(async()=>{const m=H.current;if(m)try{m.readyState<2&&m.load();const P=m.play();S.current=P,await P,Y(!0)}catch{Y(!1)}finally{S.current=null}},[]),rt=a.useCallback(()=>{!o||B||J()},[o,B,J]),st=a.useCallback(()=>{!o||B||re().then(()=>Y(!1))},[o,B,re]),he=a.useCallback(async()=>{const m=H.current;m&&(m.paused?await J():(await re(),Y(!1)))},[J,re]),ot=a.useCallback(()=>{var m,P;Y(!1),(P=(m=F.current).onEnded)==null||P.call(m),Z&&g&&de&&te(U+1,!0)},[Z,g,de,te,U]);a.useEffect(()=>{const m=le;if(!m)return;const P=new Set,z=()=>{var we,je,Le,Ee;const I=m.duration;if((je=(we=F.current).onTimeUpdate)==null||je.call(we,m.currentTime,Number.isFinite(I)?I:0),!Number.isFinite(I)||I<=0)return;const W=m.currentTime/I*100;for(const se of[25,50,75,100])W>=se&&!P.has(se)&&(P.add(se),(Ee=(Le=F.current).onMilestone)==null||Ee.call(Le,se))},be=()=>{var I,W;return(W=(I=F.current).onSeeked)==null?void 0:W.call(I,m.currentTime)},ke=()=>{var I,W;return(W=(I=F.current).onVolumeChange)==null?void 0:W.call(I,m.volume,m.muted)},Ce=()=>{var I,W;return(W=(I=F.current).onError)==null?void 0:W.call(I)};return m.addEventListener("timeupdate",z),m.addEventListener("seeked",be),m.addEventListener("volumechange",ke),m.addEventListener("error",Ce),()=>{m.removeEventListener("timeupdate",z),m.removeEventListener("seeked",be),m.removeEventListener("volumechange",ke),m.removeEventListener("error",Ce)}},[le]),a.useEffect(()=>{ue.current&&(ue.current=!1,J())},[Q,J]);const at=!B&&ae.length>1;return t.jsxs("div",{ref:Oe,className:V("gvp-root",u),style:{width:Ge,aspectRatio:Xe},onMouseEnter:()=>{ee(!0),rt()},onMouseLeave:()=>{ee(!1),st()},children:[B?t.jsx("iframe",{className:"gvp-video gvp-youtube",src:et??void 0,title:"YouTube video player",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,referrerPolicy:"strict-origin-when-cross-origin"}):t.jsx(Ie,{ref:Ze,src:Q,poster:Qe,muted:p,loop:d,playsInline:!0,preload:"metadata",controls:ce,autoPlay:j,hlsConfig:k,className:"gvp-video",onPlay:()=>{var m,P;Y(!0),(P=(m=F.current).onPlay)==null||P.call(m)},onPause:()=>{var m,P;Y(!1),(P=(m=F.current).onPause)==null||P.call(m)},onEnded:ot,onAudioTracks:tt,audioTrackIndex:ie,onQualityLevels:nt,onCurrentLevel:Fe,qualityLevelIndex:ve,children:N},Q),!B&&t.jsx("div",{className:"gvp-vignette"}),n&&t.jsx("div",{className:"gvp-toggle",children:t.jsxs("div",{className:"gvp-toggle-pill",children:[t.jsx("button",{type:"button",onClick:()=>_("desktop"),className:V("gvp-toggle-btn",C==="desktop"&&"is-active"),"aria-label":"Desktop view","aria-pressed":C==="desktop",children:t.jsx(it,{})}),t.jsx("div",{className:"gvp-toggle-divider"}),t.jsx("button",{type:"button",onClick:()=>_("mobile"),className:V("gvp-toggle-btn",C==="mobile"&&"is-active"),"aria-label":"Mobile view","aria-pressed":C==="mobile",children:t.jsx(lt,{})})]})}),l&&t.jsx("button",{type:"button",onClick:l,className:"gvp-close","aria-label":"Close",children:t.jsx(ct,{})}),at&&t.jsx(zt,{tracks:ae,activeIndex:ie>=0?ie:ae[0].index,onSelect:ge}),!B&&K&&t.jsx("button",{type:"button",className:"gvp-click-layer",onClick:()=>void he(),"aria-label":oe?"Pause":"Play"}),!B&&!K&&!oe&&t.jsx("div",{className:"gvp-play-wrap",children:t.jsxs("button",{type:"button",onClick:()=>void he(),onMouseEnter:()=>ee(!0),onMouseLeave:()=>ee(!1),className:"gvp-play","aria-label":"Play",children:[t.jsx(ut,{}),i&&Re&&t.jsx("span",{className:"gvp-tooltip",role:"tooltip",children:i})]})}),!B&&K&&t.jsx(At,{video:le,isPlaying:oe,container:Ue,onTogglePlay:()=>void he(),qualityLevels:Be,currentLevel:We,selectedLevel:ve,onSelectLevel:xe,thumbnails:ze,chapters:Ke,hasPrev:Je,hasNext:de,onPrev:()=>te(U-1,!0),onNext:()=>te(U+1,!0)}),!B&&!K&&t.jsx("div",{className:"gvp-bottom-fade"})]})};exports.ReactVideoPlayer=Kt;exports.parseYouTubeId=Ve;exports.parseYouTubeStart=He;exports.youTubeEmbedUrl=Ae;
|
|
3
5
|
//# sourceMappingURL=index.cjs.map
|