@livo-tv/blocks 1.5.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import * as React7 from 'react';
2
+ import * as React8 from 'react';
3
3
  import { createContext, useContext, useState, useRef, useId, useEffect, useCallback, useLayoutEffect } from 'react';
4
4
  import { Loader2, AlertTriangle, Inbox, Bell, Monitor, Sun, Moon, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Settings, Cast, PictureInPicture2, Minimize, Maximize, XIcon } from 'lucide-react';
5
5
  import { clsx } from 'clsx';
@@ -1310,7 +1310,7 @@ function Slider({
1310
1310
  max = 100,
1311
1311
  ...props
1312
1312
  }) {
1313
- const _values = React7.useMemo(
1313
+ const _values = React8.useMemo(
1314
1314
  () => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
1315
1315
  [value, defaultValue, min, max]
1316
1316
  );
@@ -2378,8 +2378,8 @@ function probeVideoAudio(el) {
2378
2378
  return "unknown";
2379
2379
  }
2380
2380
  function usePrefersReducedMotion() {
2381
- const [reduced, setReduced] = React7.useState(false);
2382
- React7.useEffect(() => {
2381
+ const [reduced, setReduced] = React8.useState(false);
2382
+ React8.useEffect(() => {
2383
2383
  const media = window.matchMedia("(prefers-reduced-motion: reduce)");
2384
2384
  const sync = () => setReduced(media.matches);
2385
2385
  sync();
@@ -2396,11 +2396,11 @@ function CurtainVideo({
2396
2396
  allowSound,
2397
2397
  labels
2398
2398
  }) {
2399
- const videoRef = React7.useRef(null);
2400
- const [playback, setPlayback] = React7.useState("pending");
2401
- const [muted, setMuted] = React7.useState(true);
2402
- const [audio, setAudio] = React7.useState("unknown");
2403
- React7.useEffect(() => {
2399
+ const videoRef = React8.useRef(null);
2400
+ const [playback, setPlayback] = React8.useState("pending");
2401
+ const [muted, setMuted] = React8.useState(true);
2402
+ const [audio, setAudio] = React8.useState("unknown");
2403
+ React8.useEffect(() => {
2404
2404
  const el = videoRef.current;
2405
2405
  if (!el) return;
2406
2406
  el.setAttribute("webkit-playsinline", "");
@@ -2441,7 +2441,7 @@ function CurtainVideo({
2441
2441
  el.removeEventListener("loadedmetadata", applyAudio);
2442
2442
  };
2443
2443
  }, [url, freeze]);
2444
- const startPlayback = React7.useCallback(() => {
2444
+ const startPlayback = React8.useCallback(() => {
2445
2445
  const el = videoRef.current;
2446
2446
  if (!el) return;
2447
2447
  el.muted = true;
@@ -2457,7 +2457,7 @@ function CurtainVideo({
2457
2457
  }
2458
2458
  );
2459
2459
  }, []);
2460
- const setVideoMuted = React7.useCallback((next) => {
2460
+ const setVideoMuted = React8.useCallback((next) => {
2461
2461
  const el = videoRef.current;
2462
2462
  if (el) el.muted = next;
2463
2463
  setMuted(next);
@@ -2564,9 +2564,9 @@ function isVideoKind(kind) {
2564
2564
  return kind === "video";
2565
2565
  }
2566
2566
  function useElementInView(enabled) {
2567
- const [node, setNode] = React7.useState(null);
2568
- const [inView, setInView] = React7.useState(false);
2569
- React7.useEffect(() => {
2567
+ const [node, setNode] = React8.useState(null);
2568
+ const [inView, setInView] = React8.useState(false);
2569
+ React8.useEffect(() => {
2570
2570
  if (!enabled || !node || typeof IntersectionObserver === "undefined") {
2571
2571
  setInView(false);
2572
2572
  return;
@@ -2738,7 +2738,7 @@ function CurtainPicker({
2738
2738
  actionsPending = false
2739
2739
  }) {
2740
2740
  const copy = { ...DEFAULT_CURTAIN_PICKER_LABELS, ...labels };
2741
- const groupName = React7.useId();
2741
+ const groupName = React8.useId();
2742
2742
  const selectable = typeof onChange === "function";
2743
2743
  const compact = variant === "compact";
2744
2744
  const selectedId = value === "" ? null : value ?? null;
@@ -2754,7 +2754,7 @@ function CurtainPicker({
2754
2754
  canMakeDefault,
2755
2755
  canDelete
2756
2756
  ) : {};
2757
- const grouped = React7.useMemo(() => {
2757
+ const grouped = React8.useMemo(() => {
2758
2758
  if (!groupByOwner) {
2759
2759
  return [{ group: null, items: ready }];
2760
2760
  }
@@ -3079,8 +3079,8 @@ function WaitingRoom({
3079
3079
  labels,
3080
3080
  className
3081
3081
  }) {
3082
- const [now, setNow] = React7.useState(nowMs ?? Date.now());
3083
- React7.useEffect(() => {
3082
+ const [now, setNow] = React8.useState(nowMs ?? Date.now());
3083
+ React8.useEffect(() => {
3084
3084
  if (nowMs != null) {
3085
3085
  setNow(nowMs);
3086
3086
  return;
@@ -3175,6 +3175,187 @@ async function castHlsUrl(hlsUrl) {
3175
3175
  await session.loadMedia(request);
3176
3176
  }
3177
3177
 
3178
+ // src/components/video/seekPreview.ts
3179
+ var XYWH_RE = /#xywh=(\d+),(\d+),(\d+),(\d+)\s*$/;
3180
+ function thumbnailsVttUrlFromPlayback(src) {
3181
+ const trimmed = src.trim();
3182
+ if (!trimmed) return null;
3183
+ const replaced = trimmed.replace(
3184
+ /index\.m3u8(?:\?.*)?$/i,
3185
+ "thumbs/preview.vtt"
3186
+ );
3187
+ if (replaced === trimmed) return null;
3188
+ return replaced;
3189
+ }
3190
+ function parseVttTimestamp(value) {
3191
+ const parts = value.trim().split(":");
3192
+ if (parts.length === 3) {
3193
+ const hours = Number(parts[0]);
3194
+ const minutes = Number(parts[1]);
3195
+ const seconds2 = Number(parts[2]);
3196
+ if ([hours, minutes, seconds2].some((n) => Number.isNaN(n))) return 0;
3197
+ return hours * 3600 + minutes * 60 + seconds2;
3198
+ }
3199
+ if (parts.length === 2) {
3200
+ const minutes = Number(parts[0]);
3201
+ const seconds2 = Number(parts[1]);
3202
+ if ([minutes, seconds2].some((n) => Number.isNaN(n))) return 0;
3203
+ return minutes * 60 + seconds2;
3204
+ }
3205
+ const seconds = Number(value);
3206
+ return Number.isFinite(seconds) ? seconds : 0;
3207
+ }
3208
+ function parseThumbnailsVtt(text, vttUrl) {
3209
+ const cues = [];
3210
+ const blocks = text.replace(/^\uFEFF?WEBVTT[^\n]*\n/i, "").split(/\n\s*\n/);
3211
+ for (const block of blocks) {
3212
+ const lines = block.split("\n").map((line) => line.trim()).filter(Boolean);
3213
+ const timing = lines.find((line) => line.includes("-->"));
3214
+ const payload = lines.find((line) => XYWH_RE.test(line));
3215
+ if (!timing || !payload) continue;
3216
+ const [startRaw, endRaw] = timing.split("-->").map((part) => part.trim());
3217
+ const match = payload.match(XYWH_RE);
3218
+ if (!startRaw || !endRaw || !match) continue;
3219
+ const spriteName = payload.slice(0, match.index);
3220
+ cues.push({
3221
+ start: parseVttTimestamp(startRaw),
3222
+ end: parseVttTimestamp(endRaw),
3223
+ spriteUrl: new URL(spriteName, vttUrl).toString(),
3224
+ x: Number(match[1]),
3225
+ y: Number(match[2]),
3226
+ width: Number(match[3]),
3227
+ height: Number(match[4])
3228
+ });
3229
+ }
3230
+ return cues;
3231
+ }
3232
+ function cueAtTime(cues, time) {
3233
+ if (cues.length === 0) return null;
3234
+ const hit = cues.find((cue) => time >= cue.start && time < cue.end);
3235
+ if (hit) return hit;
3236
+ const last = cues[cues.length - 1];
3237
+ if (last && time >= last.start) return last;
3238
+ return cues[0] ?? null;
3239
+ }
3240
+ function hoverTimeFromClientX(clientX, rect, duration) {
3241
+ if (rect.width <= 0 || duration <= 0) return 0;
3242
+ const ratio = Math.min(1, Math.max(0, (clientX - rect.left) / rect.width));
3243
+ return ratio * duration;
3244
+ }
3245
+ async function loadThumbnailsVtt(src) {
3246
+ const vttUrl = thumbnailsVttUrlFromPlayback(src);
3247
+ if (!vttUrl) return [];
3248
+ try {
3249
+ const response = await fetch(vttUrl);
3250
+ if (!response.ok) return [];
3251
+ const text = await response.text();
3252
+ return parseThumbnailsVtt(text, vttUrl);
3253
+ } catch {
3254
+ return [];
3255
+ }
3256
+ }
3257
+ function SeekBar({
3258
+ src,
3259
+ duration,
3260
+ currentTime,
3261
+ buffered,
3262
+ onSeek,
3263
+ formatTime: formatTime2
3264
+ }) {
3265
+ const trackRef = React8.useRef(null);
3266
+ const [hoverTime, setHoverTime] = React8.useState(null);
3267
+ const [cues, setCues] = React8.useState(null);
3268
+ const loadedSrc = React8.useRef(null);
3269
+ React8.useEffect(() => {
3270
+ setCues(null);
3271
+ loadedSrc.current = null;
3272
+ }, [src]);
3273
+ const ensureCues = React8.useCallback(() => {
3274
+ if (loadedSrc.current === src) return;
3275
+ loadedSrc.current = src;
3276
+ void loadThumbnailsVtt(src).then((next) => {
3277
+ setCues(next);
3278
+ });
3279
+ }, [src]);
3280
+ const updateHover = React8.useCallback(
3281
+ (clientX) => {
3282
+ const rect = trackRef.current?.getBoundingClientRect();
3283
+ if (!rect) return;
3284
+ setHoverTime(hoverTimeFromClientX(clientX, rect, duration));
3285
+ },
3286
+ [duration]
3287
+ );
3288
+ const cue = hoverTime !== null && cues && cues.length > 0 ? cueAtTime(cues, hoverTime) : null;
3289
+ const hoverPercent = hoverTime !== null && duration > 0 ? Math.min(100, Math.max(0, hoverTime / duration * 100)) : 0;
3290
+ return /* @__PURE__ */ jsxs(
3291
+ "div",
3292
+ {
3293
+ ref: trackRef,
3294
+ className: "relative w-full",
3295
+ onPointerEnter: ensureCues,
3296
+ onPointerDown: (event) => {
3297
+ ensureCues();
3298
+ updateHover(event.clientX);
3299
+ },
3300
+ onPointerMove: (event) => {
3301
+ ensureCues();
3302
+ updateHover(event.clientX);
3303
+ },
3304
+ onPointerLeave: () => setHoverTime(null),
3305
+ onPointerUp: () => setHoverTime(null),
3306
+ children: [
3307
+ hoverTime !== null ? /* @__PURE__ */ jsxs(
3308
+ "div",
3309
+ {
3310
+ className: "pointer-events-none absolute bottom-full mb-2 flex flex-col items-center gap-1",
3311
+ style: { left: `${hoverPercent}%`, transform: "translateX(-50%)" },
3312
+ "data-slot": "seek-preview",
3313
+ children: [
3314
+ cue ? /* @__PURE__ */ jsx(
3315
+ "div",
3316
+ {
3317
+ "aria-hidden": "true",
3318
+ className: "overflow-hidden rounded border border-white/20 bg-black shadow-md",
3319
+ style: {
3320
+ width: cue.width,
3321
+ height: cue.height,
3322
+ backgroundImage: `url(${cue.spriteUrl})`,
3323
+ backgroundPosition: `-${cue.x}px -${cue.y}px`,
3324
+ backgroundRepeat: "no-repeat"
3325
+ }
3326
+ }
3327
+ ) : null,
3328
+ /* @__PURE__ */ jsx("span", { className: "rounded-full bg-black/80 px-1.5 py-0.5 text-[10px] tabular-nums text-white", children: formatTime2(hoverTime) })
3329
+ ]
3330
+ }
3331
+ ) : null,
3332
+ /* @__PURE__ */ jsx(
3333
+ Slider,
3334
+ {
3335
+ "aria-label": "Seek",
3336
+ min: 0,
3337
+ max: duration || 0,
3338
+ step: 0.1,
3339
+ value: [Math.min(currentTime, duration || 0)],
3340
+ onValueChange: (value) => onSeek(value[0] ?? 0),
3341
+ className: "w-full"
3342
+ }
3343
+ ),
3344
+ duration > 0 && buffered > currentTime ? /* @__PURE__ */ jsx(
3345
+ "span",
3346
+ {
3347
+ "aria-hidden": "true",
3348
+ className: "pointer-events-none absolute top-1/2 left-0 h-1.5 -translate-y-1/2 rounded-full bg-white/25",
3349
+ style: {
3350
+ width: `${Math.min(buffered / duration * 100, 100)}%`
3351
+ }
3352
+ }
3353
+ ) : null
3354
+ ]
3355
+ }
3356
+ );
3357
+ }
3358
+
3178
3359
  // src/components/video/hls-config.ts
3179
3360
  function shouldRetryLiveEdge404(retryConfig, retryCount, _isTimeout, loaderResponse, defaultRetry) {
3180
3361
  if (loaderResponse?.code === 404) {
@@ -3353,27 +3534,27 @@ function useHlsPlayback({
3353
3534
  onError,
3354
3535
  onPlayingChange
3355
3536
  }) {
3356
- const videoRef = React7.useRef(null);
3357
- const hlsRef = React7.useRef(null);
3358
- const [state, setState] = React7.useState("idle");
3359
- const [qualities, setQualities] = React7.useState([]);
3360
- const [activeLevel, setActiveLevel] = React7.useState(-1);
3361
- const [autoplayState, setAutoplayState] = React7.useState("none");
3362
- const [error, setError] = React7.useState(null);
3363
- const [reloadKey, setReloadKey] = React7.useState(0);
3364
- const onErrorRef = React7.useRef(onError);
3365
- const onPlayingChangeRef = React7.useRef(onPlayingChange);
3366
- React7.useEffect(() => {
3537
+ const videoRef = React8.useRef(null);
3538
+ const hlsRef = React8.useRef(null);
3539
+ const [state, setState] = React8.useState("idle");
3540
+ const [qualities, setQualities] = React8.useState([]);
3541
+ const [activeLevel, setActiveLevel] = React8.useState(-1);
3542
+ const [autoplayState, setAutoplayState] = React8.useState("none");
3543
+ const [error, setError] = React8.useState(null);
3544
+ const [reloadKey, setReloadKey] = React8.useState(0);
3545
+ const onErrorRef = React8.useRef(onError);
3546
+ const onPlayingChangeRef = React8.useRef(onPlayingChange);
3547
+ React8.useEffect(() => {
3367
3548
  onErrorRef.current = onError;
3368
3549
  onPlayingChangeRef.current = onPlayingChange;
3369
3550
  }, [onError, onPlayingChange]);
3370
- const retry = React7.useCallback(() => {
3551
+ const retry = React8.useCallback(() => {
3371
3552
  setError(null);
3372
3553
  setState("loading");
3373
3554
  setAutoplayState("none");
3374
3555
  setReloadKey((k) => k + 1);
3375
3556
  }, []);
3376
- React7.useEffect(() => {
3557
+ React8.useEffect(() => {
3377
3558
  const media = videoRef.current;
3378
3559
  if (!media || !src || !active) {
3379
3560
  setState("idle");
@@ -3643,7 +3824,7 @@ function useHlsPlayback({
3643
3824
  destroyHls();
3644
3825
  };
3645
3826
  }, [src, mode, active, autoPlay, muted, reloadKey]);
3646
- const setLevel = React7.useCallback((index) => {
3827
+ const setLevel = React8.useCallback((index) => {
3647
3828
  const hls = hlsRef.current;
3648
3829
  if (!hls) return;
3649
3830
  hls.nextLevel = index;
@@ -3729,12 +3910,12 @@ function VideoPlayer({
3729
3910
  className
3730
3911
  }) {
3731
3912
  const t = { ...DEFAULT_LABELS3, ...labels };
3732
- const containerRef = React7.useRef(null);
3733
- const firstPlayFiredRef = React7.useRef(false);
3734
- const [userStarted, setUserStarted] = React7.useState(false);
3913
+ const containerRef = React8.useRef(null);
3914
+ const firstPlayFiredRef = React8.useRef(false);
3915
+ const [userStarted, setUserStarted] = React8.useState(false);
3735
3916
  const active = autoPlay || !poster || userStarted;
3736
3917
  const autoplayActive = autoPlay || userStarted;
3737
- const handlePlayingChange = React7.useCallback(
3918
+ const handlePlayingChange = React8.useCallback(
3738
3919
  (playing) => {
3739
3920
  setIsPlaying(playing);
3740
3921
  if (playing && !firstPlayFiredRef.current) {
@@ -3763,25 +3944,25 @@ function VideoPlayer({
3763
3944
  onError,
3764
3945
  onPlayingChange: handlePlayingChange
3765
3946
  });
3766
- const [isPlaying, setIsPlaying] = React7.useState(false);
3767
- const [isMuted, setIsMuted] = React7.useState(muted);
3768
- const [volume, setVolume] = React7.useState(1);
3769
- const [currentTime, setCurrentTime] = React7.useState(0);
3770
- const [duration, setDuration] = React7.useState(0);
3771
- const [buffered, setBuffered] = React7.useState(0);
3772
- const [isFullscreen, setIsFullscreen] = React7.useState(false);
3773
- const [pipActive, setPipActive] = React7.useState(false);
3774
- const [controlsVisible, setControlsVisible] = React7.useState(true);
3775
- const [playbackRate, setPlaybackRate] = React7.useState(1);
3776
- const [openMenu, setOpenMenu] = React7.useState(
3947
+ const [isPlaying, setIsPlaying] = React8.useState(false);
3948
+ const [isMuted, setIsMuted] = React8.useState(muted);
3949
+ const [volume, setVolume] = React8.useState(1);
3950
+ const [currentTime, setCurrentTime] = React8.useState(0);
3951
+ const [duration, setDuration] = React8.useState(0);
3952
+ const [buffered, setBuffered] = React8.useState(0);
3953
+ const [isFullscreen, setIsFullscreen] = React8.useState(false);
3954
+ const [pipActive, setPipActive] = React8.useState(false);
3955
+ const [controlsVisible, setControlsVisible] = React8.useState(true);
3956
+ const [playbackRate, setPlaybackRate] = React8.useState(1);
3957
+ const [openMenu, setOpenMenu] = React8.useState(
3777
3958
  null
3778
3959
  );
3779
- const [behindLive, setBehindLive] = React7.useState(false);
3780
- const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React7.useState(false);
3781
- const hideTimerRef = React7.useRef(null);
3960
+ const [behindLive, setBehindLive] = React8.useState(false);
3961
+ const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React8.useState(false);
3962
+ const hideTimerRef = React8.useRef(null);
3782
3963
  const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
3783
3964
  const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported;
3784
- React7.useEffect(() => {
3965
+ React8.useEffect(() => {
3785
3966
  const video = videoRef.current;
3786
3967
  if (!video || !active) return;
3787
3968
  const onTimeUpdate = () => {
@@ -3814,21 +3995,21 @@ function VideoPlayer({
3814
3995
  video.removeEventListener("ratechange", onRate);
3815
3996
  };
3816
3997
  }, [videoRef, active, mode]);
3817
- React7.useEffect(() => {
3998
+ React8.useEffect(() => {
3818
3999
  const video = videoRef.current;
3819
4000
  if (!paused || !video || !isPlaying) return;
3820
4001
  video.pause();
3821
4002
  }, [paused, videoRef, isPlaying]);
3822
- React7.useEffect(() => {
4003
+ React8.useEffect(() => {
3823
4004
  setWebkitFullscreenSupported(hasWebkitVideoFullscreen(videoRef.current));
3824
4005
  videoRef.current?.setAttribute("x-webkit-airplay", "allow");
3825
4006
  }, [videoRef, active]);
3826
- React7.useEffect(() => {
4007
+ React8.useEffect(() => {
3827
4008
  const onFsChange = () => setIsFullscreen(document.fullscreenElement === containerRef.current);
3828
4009
  document.addEventListener("fullscreenchange", onFsChange);
3829
4010
  return () => document.removeEventListener("fullscreenchange", onFsChange);
3830
4011
  }, []);
3831
- React7.useEffect(() => {
4012
+ React8.useEffect(() => {
3832
4013
  const video = asWebkitVideo(videoRef.current);
3833
4014
  if (!video) return;
3834
4015
  const onBegin = () => setIsFullscreen(true);
@@ -3840,7 +4021,7 @@ function VideoPlayer({
3840
4021
  video.removeEventListener("webkitendfullscreen", onEnd);
3841
4022
  };
3842
4023
  }, [videoRef, active]);
3843
- React7.useEffect(() => {
4024
+ React8.useEffect(() => {
3844
4025
  const video = videoRef.current;
3845
4026
  if (!video) return;
3846
4027
  const onEnter = () => setPipActive(true);
@@ -3852,18 +4033,18 @@ function VideoPlayer({
3852
4033
  video.removeEventListener("leavepictureinpicture", onLeave);
3853
4034
  };
3854
4035
  }, [videoRef]);
3855
- const scheduleHide = React7.useCallback(() => {
4036
+ const scheduleHide = React8.useCallback(() => {
3856
4037
  if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
3857
4038
  hideTimerRef.current = setTimeout(() => {
3858
4039
  setControlsVisible(false);
3859
4040
  setOpenMenu(null);
3860
4041
  }, CONTROLS_HIDE_MS);
3861
4042
  }, []);
3862
- const revealControls = React7.useCallback(() => {
4043
+ const revealControls = React8.useCallback(() => {
3863
4044
  setControlsVisible(true);
3864
4045
  scheduleHide();
3865
4046
  }, [scheduleHide]);
3866
- React7.useEffect(() => {
4047
+ React8.useEffect(() => {
3867
4048
  return () => {
3868
4049
  if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
3869
4050
  };
@@ -4105,30 +4286,17 @@ function VideoPlayer({
4105
4286
  ),
4106
4287
  "data-slot": "video-controls",
4107
4288
  children: [
4108
- mode === "vod" && /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
4109
- /* @__PURE__ */ jsx(
4110
- Slider,
4111
- {
4112
- "aria-label": "Seek",
4113
- min: 0,
4114
- max: duration || 0,
4115
- step: 0.1,
4116
- value: [Math.min(currentTime, duration || 0)],
4117
- onValueChange: (v) => seekTo(v[0] ?? 0),
4118
- className: "w-full"
4119
- }
4120
- ),
4121
- duration > 0 && buffered > currentTime && /* @__PURE__ */ jsx(
4122
- "span",
4123
- {
4124
- "aria-hidden": "true",
4125
- className: "pointer-events-none absolute top-1/2 left-0 h-1.5 -translate-y-1/2 rounded-full bg-white/25",
4126
- style: {
4127
- width: `${Math.min(buffered / duration * 100, 100)}%`
4128
- }
4129
- }
4130
- )
4131
- ] }),
4289
+ mode === "vod" && /* @__PURE__ */ jsx(
4290
+ SeekBar,
4291
+ {
4292
+ src,
4293
+ duration,
4294
+ currentTime,
4295
+ buffered,
4296
+ onSeek: seekTo,
4297
+ formatTime
4298
+ }
4299
+ ),
4132
4300
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
4133
4301
  /* @__PURE__ */ jsx(
4134
4302
  ControlButton,
@@ -4366,16 +4534,16 @@ function videoInPictureInPicture(container) {
4366
4534
  return container.contains(pip);
4367
4535
  }
4368
4536
  function useFeedExclusivePlayback(playbackId) {
4369
- const containerRef = React7.useRef(null);
4370
- const [forcePaused, setForcePaused] = React7.useState(false);
4371
- const requestPause = React7.useCallback(() => {
4537
+ const containerRef = React8.useRef(null);
4538
+ const [forcePaused, setForcePaused] = React8.useState(false);
4539
+ const requestPause = React8.useCallback(() => {
4372
4540
  if (videoInPictureInPicture(containerRef.current)) return;
4373
4541
  setForcePaused(true);
4374
4542
  }, []);
4375
- React7.useEffect(() => {
4543
+ React8.useEffect(() => {
4376
4544
  return registerFeedPlayer(playbackId, requestPause);
4377
4545
  }, [playbackId, requestPause]);
4378
- React7.useEffect(() => {
4546
+ React8.useEffect(() => {
4379
4547
  const node = containerRef.current;
4380
4548
  if (!node || typeof IntersectionObserver === "undefined") return;
4381
4549
  const observer = new IntersectionObserver(
@@ -4391,14 +4559,14 @@ function useFeedExclusivePlayback(playbackId) {
4391
4559
  observer.observe(node);
4392
4560
  return () => observer.disconnect();
4393
4561
  }, [requestPause]);
4394
- React7.useEffect(() => {
4562
+ React8.useEffect(() => {
4395
4563
  const onVisibility = () => {
4396
4564
  if (document.hidden) requestPause();
4397
4565
  };
4398
4566
  document.addEventListener("visibilitychange", onVisibility);
4399
4567
  return () => document.removeEventListener("visibilitychange", onVisibility);
4400
4568
  }, [requestPause]);
4401
- const onPlayingChange = React7.useCallback(
4569
+ const onPlayingChange = React8.useCallback(
4402
4570
  (playing) => {
4403
4571
  if (!playing) return;
4404
4572
  setForcePaused(false);
@@ -4425,7 +4593,7 @@ function FeedVideoPlayer({
4425
4593
  paused: exclusivePaused,
4426
4594
  onPlayingChange: onExclusivePlayingChange
4427
4595
  } = useFeedExclusivePlayback(playbackId);
4428
- const handlePlayingChange = React7.useCallback(
4596
+ const handlePlayingChange = React8.useCallback(
4429
4597
  (playing) => {
4430
4598
  onExclusivePlayingChange(playing);
4431
4599
  onPlayingChange?.(playing);
@@ -4452,8 +4620,8 @@ function FeedVideoPlayer({
4452
4620
  );
4453
4621
  }
4454
4622
  function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {}) {
4455
- const [stats, setStats] = React7.useState({});
4456
- React7.useEffect(() => {
4623
+ const [stats, setStats] = React8.useState({});
4624
+ React8.useEffect(() => {
4457
4625
  if (!statsUrl || !enabled) return;
4458
4626
  let cancelled = false;
4459
4627
  const controller = new AbortController();
@@ -4589,79 +4757,85 @@ function FileDropzone({
4589
4757
  inputRef.current?.click();
4590
4758
  }
4591
4759
  }
4592
- return /* @__PURE__ */ jsxs("div", { className: cn("grid gap-2", className), children: [
4593
- /* @__PURE__ */ jsxs(
4594
- "div",
4595
- {
4596
- role: "button",
4597
- tabIndex: disabled ? -1 : 0,
4598
- "aria-disabled": disabled,
4599
- "aria-describedby": message ? `${inputId}-message` : `${inputId}-hint`,
4600
- "aria-controls": inputId,
4601
- "data-dragging": dragging || void 0,
4602
- className: cn(
4603
- "border-input bg-background focus-visible:border-ring focus-visible:ring-ring/50 rounded-lg border border-dashed px-4 py-8 text-center outline-none focus-visible:ring-[3px]",
4604
- dragging && "border-primary bg-primary/5",
4605
- disabled && "pointer-events-none opacity-50"
4606
- ),
4607
- onClick: () => {
4608
- if (!disabled) inputRef.current?.click();
4609
- },
4610
- onKeyDown,
4611
- onDragEnter: (event) => {
4612
- event.preventDefault();
4613
- if (!disabled) setDragging(true);
4614
- },
4615
- onDragOver: (event) => {
4616
- event.preventDefault();
4617
- },
4618
- onDragLeave: (event) => {
4619
- if (event.currentTarget.contains(event.relatedTarget)) {
4620
- return;
4760
+ return /* @__PURE__ */ jsxs(
4761
+ "div",
4762
+ {
4763
+ className: cn("relative flex w-full min-w-0 flex-col gap-2", className),
4764
+ children: [
4765
+ /* @__PURE__ */ jsxs(
4766
+ "div",
4767
+ {
4768
+ role: "button",
4769
+ tabIndex: disabled ? -1 : 0,
4770
+ "aria-disabled": disabled,
4771
+ "aria-describedby": message ? `${inputId}-message` : `${inputId}-hint`,
4772
+ "aria-controls": inputId,
4773
+ "data-dragging": dragging || void 0,
4774
+ className: cn(
4775
+ "border-input bg-background focus-visible:border-ring focus-visible:ring-ring/50 w-full min-w-0 rounded-lg border border-dashed px-4 py-8 text-center outline-none focus-visible:ring-[3px]",
4776
+ dragging && "border-primary bg-primary/5",
4777
+ disabled && "pointer-events-none opacity-50"
4778
+ ),
4779
+ onClick: () => {
4780
+ if (!disabled) inputRef.current?.click();
4781
+ },
4782
+ onKeyDown,
4783
+ onDragEnter: (event) => {
4784
+ event.preventDefault();
4785
+ if (!disabled) setDragging(true);
4786
+ },
4787
+ onDragOver: (event) => {
4788
+ event.preventDefault();
4789
+ },
4790
+ onDragLeave: (event) => {
4791
+ if (event.currentTarget.contains(event.relatedTarget)) {
4792
+ return;
4793
+ }
4794
+ setDragging(false);
4795
+ },
4796
+ onDrop,
4797
+ children: [
4798
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: labels.idle }),
4799
+ /* @__PURE__ */ jsx(
4800
+ "p",
4801
+ {
4802
+ id: `${inputId}-hint`,
4803
+ className: "text-muted-foreground mt-1 text-xs",
4804
+ children: labels.hint
4805
+ }
4806
+ ),
4807
+ /* @__PURE__ */ jsx("span", { className: "text-primary mt-3 inline-flex text-sm font-medium underline-offset-4", children: labels.browse })
4808
+ ]
4621
4809
  }
4622
- setDragging(false);
4623
- },
4624
- onDrop,
4625
- children: [
4626
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: labels.idle }),
4627
- /* @__PURE__ */ jsx(
4628
- "p",
4629
- {
4630
- id: `${inputId}-hint`,
4631
- className: "text-muted-foreground mt-1 text-xs",
4632
- children: labels.hint
4810
+ ),
4811
+ /* @__PURE__ */ jsx(
4812
+ "input",
4813
+ {
4814
+ id: inputId,
4815
+ ref: inputRef,
4816
+ type: "file",
4817
+ accept,
4818
+ disabled,
4819
+ "aria-label": labels.browse,
4820
+ className: "sr-only",
4821
+ onChange: (event) => {
4822
+ takeFile(event.target.files?.[0]);
4823
+ event.target.value = "";
4633
4824
  }
4634
- ),
4635
- /* @__PURE__ */ jsx("span", { className: "text-primary mt-3 inline-flex text-sm font-medium underline-offset-4", children: labels.browse })
4636
- ]
4637
- }
4638
- ),
4639
- /* @__PURE__ */ jsx(
4640
- "input",
4641
- {
4642
- id: inputId,
4643
- ref: inputRef,
4644
- type: "file",
4645
- accept,
4646
- disabled,
4647
- "aria-label": labels.browse,
4648
- className: "sr-only",
4649
- onChange: (event) => {
4650
- takeFile(event.target.files?.[0]);
4651
- event.target.value = "";
4652
- }
4653
- }
4654
- ),
4655
- message ? /* @__PURE__ */ jsx(
4656
- "p",
4657
- {
4658
- id: `${inputId}-message`,
4659
- role: "alert",
4660
- className: "text-destructive text-sm",
4661
- children: message
4662
- }
4663
- ) : null
4664
- ] });
4825
+ }
4826
+ ),
4827
+ message ? /* @__PURE__ */ jsx(
4828
+ "p",
4829
+ {
4830
+ id: `${inputId}-message`,
4831
+ role: "alert",
4832
+ className: "text-destructive text-sm",
4833
+ children: message
4834
+ }
4835
+ ) : null
4836
+ ]
4837
+ }
4838
+ );
4665
4839
  }
4666
4840
  function statusLabel(status, labels) {
4667
4841
  switch (status) {
@@ -4694,73 +4868,90 @@ function FileUploadTray({
4694
4868
  const labels = { ...DEFAULT_FILE_UPLOAD_TRAY_LABELS, ...labelOverrides };
4695
4869
  const visible = jobs.filter((job) => job.status !== "cancelled");
4696
4870
  if (visible.length === 0) return null;
4697
- return /* @__PURE__ */ jsx("section", { "aria-label": labels.title, className: cn("grid gap-3", className), children: /* @__PURE__ */ jsx("ul", { className: "grid gap-3", children: visible.map((job) => {
4698
- const active = job.status === "uploading" || job.status === "completing";
4699
- const canPause = job.status === "uploading";
4700
- const canResume = job.status === "paused";
4701
- const canCancel = job.status === "uploading" || job.status === "paused" || job.status === "error";
4702
- return /* @__PURE__ */ jsxs("li", { className: "grid gap-1.5", children: [
4703
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
4704
- /* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-sm font-medium", children: job.name }),
4705
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: statusLabel(job.status, labels) }),
4706
- canPause ? /* @__PURE__ */ jsx(
4707
- Button,
4708
- {
4709
- type: "button",
4710
- variant: "ghost",
4711
- size: "icon-sm",
4712
- "aria-label": `${labels.pause} ${job.name}`,
4713
- onClick: () => onPause(job.id),
4714
- children: /* @__PURE__ */ jsx(Pause, {})
4715
- }
4716
- ) : null,
4717
- canResume ? /* @__PURE__ */ jsx(
4718
- Button,
4719
- {
4720
- type: "button",
4721
- variant: "ghost",
4722
- size: "icon-sm",
4723
- "aria-label": `${labels.resume} ${job.name}`,
4724
- onClick: () => onResume(job.id),
4725
- children: /* @__PURE__ */ jsx(Play, {})
4726
- }
4727
- ) : null,
4728
- canCancel ? /* @__PURE__ */ jsx(
4729
- Button,
4730
- {
4731
- type: "button",
4732
- variant: "ghost",
4733
- size: "icon-sm",
4734
- "aria-label": `${labels.cancel} ${job.name}`,
4735
- onClick: () => onCancel(job.id),
4736
- children: /* @__PURE__ */ jsx(X, {})
4737
- }
4738
- ) : null
4739
- ] }),
4740
- /* @__PURE__ */ jsx(
4741
- "div",
4742
- {
4743
- role: "progressbar",
4744
- "aria-valuemin": 0,
4745
- "aria-valuemax": 100,
4746
- "aria-valuenow": job.percent,
4747
- "aria-label": job.name,
4748
- className: "bg-muted h-2 overflow-hidden rounded-full",
4749
- children: /* @__PURE__ */ jsx(
4871
+ return /* @__PURE__ */ jsx(
4872
+ "section",
4873
+ {
4874
+ "aria-label": labels.title,
4875
+ className: cn("grid min-w-0 gap-3", className),
4876
+ children: /* @__PURE__ */ jsx("ul", { className: "grid min-w-0 gap-3", children: visible.map((job) => {
4877
+ const active = job.status === "uploading" || job.status === "completing";
4878
+ const canPause = job.status === "uploading";
4879
+ const canResume = job.status === "paused";
4880
+ const canCancel = job.status === "uploading" || job.status === "paused" || job.status === "error";
4881
+ return /* @__PURE__ */ jsxs("li", { className: "grid min-w-0 gap-1.5", children: [
4882
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
4883
+ /* @__PURE__ */ jsx(
4884
+ "p",
4885
+ {
4886
+ className: "min-w-0 flex-1 truncate text-sm font-medium",
4887
+ title: job.name,
4888
+ children: job.name
4889
+ }
4890
+ ),
4891
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground shrink-0 text-xs", children: statusLabel(job.status, labels) }),
4892
+ canPause ? /* @__PURE__ */ jsx(
4893
+ Button,
4894
+ {
4895
+ type: "button",
4896
+ variant: "ghost",
4897
+ size: "icon-sm",
4898
+ className: "shrink-0",
4899
+ "aria-label": `${labels.pause} ${job.name}`,
4900
+ onClick: () => onPause(job.id),
4901
+ children: /* @__PURE__ */ jsx(Pause, {})
4902
+ }
4903
+ ) : null,
4904
+ canResume ? /* @__PURE__ */ jsx(
4905
+ Button,
4906
+ {
4907
+ type: "button",
4908
+ variant: "ghost",
4909
+ size: "icon-sm",
4910
+ className: "shrink-0",
4911
+ "aria-label": `${labels.resume} ${job.name}`,
4912
+ onClick: () => onResume(job.id),
4913
+ children: /* @__PURE__ */ jsx(Play, {})
4914
+ }
4915
+ ) : null,
4916
+ canCancel ? /* @__PURE__ */ jsx(
4917
+ Button,
4918
+ {
4919
+ type: "button",
4920
+ variant: "ghost",
4921
+ size: "icon-sm",
4922
+ className: "shrink-0",
4923
+ "aria-label": `${labels.cancel} ${job.name}`,
4924
+ onClick: () => onCancel(job.id),
4925
+ children: /* @__PURE__ */ jsx(X, {})
4926
+ }
4927
+ ) : null
4928
+ ] }),
4929
+ /* @__PURE__ */ jsx(
4750
4930
  "div",
4751
4931
  {
4752
- className: cn(
4753
- "bg-primary h-full",
4754
- active && "motion-safe:transition-[width]"
4755
- ),
4756
- style: { width: `${job.percent}%` }
4932
+ role: "progressbar",
4933
+ "aria-valuemin": 0,
4934
+ "aria-valuemax": 100,
4935
+ "aria-valuenow": job.percent,
4936
+ "aria-label": job.name,
4937
+ className: "bg-muted h-2 overflow-hidden rounded-full",
4938
+ children: /* @__PURE__ */ jsx(
4939
+ "div",
4940
+ {
4941
+ className: cn(
4942
+ "bg-primary h-full",
4943
+ active && "motion-safe:transition-[width]"
4944
+ ),
4945
+ style: { width: `${job.percent}%` }
4946
+ }
4947
+ )
4757
4948
  }
4758
- )
4759
- }
4760
- ),
4761
- job.error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-destructive text-xs", children: job.error }) : null
4762
- ] }, job.id);
4763
- }) }) });
4949
+ ),
4950
+ job.error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-destructive text-xs", children: job.error }) : null
4951
+ ] }, job.id);
4952
+ }) })
4953
+ }
4954
+ );
4764
4955
  }
4765
4956
  function formatActiveBadge(count) {
4766
4957
  return count > 9 ? "9+" : String(count);
@@ -4813,19 +5004,26 @@ function FileUploadMenu({
4813
5004
  ]
4814
5005
  }
4815
5006
  ) }),
4816
- /* @__PURE__ */ jsxs(DropdownMenuContent, { align, className: "w-80 p-0", children: [
4817
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between border-b px-4 py-3", children: /* @__PURE__ */ jsx("h4", { className: "font-semibold", children: labels.title }) }),
4818
- /* @__PURE__ */ jsx("div", { className: "max-h-80 overflow-y-auto p-3", children: /* @__PURE__ */ jsx(
4819
- FileUploadTray,
4820
- {
4821
- jobs: visible,
4822
- labels,
4823
- onPause,
4824
- onResume,
4825
- onCancel
4826
- }
4827
- ) })
4828
- ] })
5007
+ /* @__PURE__ */ jsxs(
5008
+ DropdownMenuContent,
5009
+ {
5010
+ align,
5011
+ className: "w-80 min-w-0 max-w-[calc(100vw-2rem)] overflow-x-hidden p-0",
5012
+ children: [
5013
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between border-b px-4 py-3", children: /* @__PURE__ */ jsx("h4", { className: "font-semibold", children: labels.title }) }),
5014
+ /* @__PURE__ */ jsx("div", { className: "max-h-80 min-w-0 overflow-x-hidden overflow-y-auto p-3", children: /* @__PURE__ */ jsx(
5015
+ FileUploadTray,
5016
+ {
5017
+ jobs: visible,
5018
+ labels,
5019
+ onPause,
5020
+ onResume,
5021
+ onCancel
5022
+ }
5023
+ ) })
5024
+ ]
5025
+ }
5026
+ )
4829
5027
  ]
4830
5028
  }
4831
5029
  );