@livo-tv/blocks 1.32.1 → 1.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use client";
2
- import * as React11 from 'react';
2
+ import * as React from 'react';
3
3
  import { createContext, useContext, useState, useRef, useId, useEffect, useCallback, useLayoutEffect } from 'react';
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, Captions, Settings, Cast, PictureInPicture2, Gauge, EllipsisVertical, Minimize, Maximize, ChevronRight, ChevronLeft, BarChart3, XIcon } from 'lucide-react';
4
+ import { Loader2, AlertTriangle, Inbox, Bell, Monitor, Sun, Moon, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Pause, Play, BarChart3, XIcon } from 'lucide-react';
5
5
  import { clsx } from 'clsx';
6
6
  import { twMerge } from 'tailwind-merge';
7
7
  import { cva } from 'class-variance-authority';
8
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
8
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
9
  import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
10
10
  import { Slot } from '@radix-ui/react-slot';
11
11
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
@@ -526,7 +526,7 @@ function NotificationBell({
526
526
  isLoading = false,
527
527
  labels: labelOverrides,
528
528
  viewAllHref,
529
- formatTime: formatTime2 = defaultFormatTime,
529
+ formatTime = defaultFormatTime,
530
530
  onOpenChange,
531
531
  align = "end",
532
532
  className
@@ -553,7 +553,7 @@ function NotificationBell({
553
553
  const body = /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-1", children: [
554
554
  /* @__PURE__ */ jsx("p", { className: "text-sm leading-none font-medium", children: item.title }),
555
555
  /* @__PURE__ */ jsx("p", { className: "text-muted-foreground line-clamp-2 text-xs", children: item.message }),
556
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground/70 text-xs", children: formatTime2(item.createdAt) })
556
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground/70 text-xs", children: formatTime(item.createdAt) })
557
557
  ] });
558
558
  return /* @__PURE__ */ jsxs("div", { children: [
559
559
  item.href ? /* @__PURE__ */ jsx(
@@ -1311,7 +1311,7 @@ function Slider({
1311
1311
  max = 100,
1312
1312
  ...props
1313
1313
  }) {
1314
- const _values = React11.useMemo(
1314
+ const _values = React.useMemo(
1315
1315
  () => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
1316
1316
  [value, defaultValue, min, max]
1317
1317
  );
@@ -2348,4726 +2348,6 @@ function AvatarEditorDialog({
2348
2348
  ] });
2349
2349
  }
2350
2350
 
2351
- // src/components/video/shader-config.ts
2352
- var SHADER_CURTAIN_TYPES = ["plane", "sphere", "waterPlane"];
2353
- var SHADER_VARIANTS = [
2354
- "defaults",
2355
- "cosmic",
2356
- "glass",
2357
- "positionMix"
2358
- ];
2359
- var SHADER_LIGHT_TYPES = ["3d", "env"];
2360
- var SHADER_ENV_PRESETS = ["city", "dawn", "lobby"];
2361
- var SHADER_ON_OFF = ["on", "off"];
2362
- var SHADER_RANGE = ["enabled", "disabled"];
2363
- var PRESET_BASE = {
2364
- shader: "defaults",
2365
- animate: "on",
2366
- wireframe: false,
2367
- loop: "on",
2368
- loopDuration: 10,
2369
- range: "disabled",
2370
- rangeStart: 0,
2371
- rangeEnd: 40,
2372
- fov: 45,
2373
- zoomOut: false,
2374
- grainBlending: 0.3,
2375
- pixelDensity: 1
2376
- };
2377
- var DEFAULT_SHADER_CURTAIN_CONFIG = {
2378
- ...PRESET_BASE,
2379
- type: "plane",
2380
- uTime: 0,
2381
- uSpeed: 0.4,
2382
- uStrength: 4,
2383
- uDensity: 1.3,
2384
- uFrequency: 5.5,
2385
- uAmplitude: 1,
2386
- positionX: -1.4,
2387
- positionY: 0,
2388
- positionZ: 0,
2389
- rotationX: 0,
2390
- rotationY: 10,
2391
- rotationZ: 50,
2392
- color1: "#ff5005",
2393
- color2: "#dbba95",
2394
- color3: "#d0bce1",
2395
- reflection: 0.1,
2396
- brightness: 1.2,
2397
- cAzimuthAngle: 180,
2398
- cPolarAngle: 90,
2399
- cDistance: 3.6,
2400
- cameraZoom: 1,
2401
- lightType: "3d",
2402
- envPreset: "city",
2403
- grain: "on"
2404
- };
2405
- var SHADER_CURTAIN_PRESETS = [
2406
- { id: "halo", title: "Halo", config: { ...DEFAULT_SHADER_CURTAIN_CONFIG } },
2407
- {
2408
- id: "pensive",
2409
- title: "Pensive",
2410
- config: {
2411
- ...PRESET_BASE,
2412
- type: "sphere",
2413
- uTime: 0,
2414
- uSpeed: 0.3,
2415
- uStrength: 0.4,
2416
- uDensity: 0.8,
2417
- uFrequency: 5.5,
2418
- uAmplitude: 7,
2419
- positionX: 0,
2420
- positionY: 0,
2421
- positionZ: 0,
2422
- rotationX: 0,
2423
- rotationY: 0,
2424
- rotationZ: 140,
2425
- color1: "#809bd6",
2426
- color2: "#910aff",
2427
- color3: "#af38ff",
2428
- reflection: 0.5,
2429
- brightness: 1.5,
2430
- cAzimuthAngle: 250,
2431
- cPolarAngle: 140,
2432
- cDistance: 1.5,
2433
- cameraZoom: 12.5,
2434
- lightType: "3d",
2435
- envPreset: "city",
2436
- grain: "on"
2437
- }
2438
- },
2439
- {
2440
- id: "mint",
2441
- title: "Mint",
2442
- config: {
2443
- ...PRESET_BASE,
2444
- type: "waterPlane",
2445
- uTime: 0,
2446
- uSpeed: 0.2,
2447
- uStrength: 3.4,
2448
- uDensity: 1.2,
2449
- uFrequency: 0,
2450
- uAmplitude: 0,
2451
- positionX: 0,
2452
- positionY: 0.9,
2453
- positionZ: -0.3,
2454
- rotationX: 45,
2455
- rotationY: 0,
2456
- rotationZ: 0,
2457
- color1: "#94ffd1",
2458
- color2: "#6bf5ff",
2459
- color3: "#ffffff",
2460
- reflection: 0.1,
2461
- brightness: 1.2,
2462
- cAzimuthAngle: 170,
2463
- cPolarAngle: 70,
2464
- cDistance: 4.4,
2465
- cameraZoom: 1,
2466
- lightType: "3d",
2467
- envPreset: "city",
2468
- grain: "off"
2469
- }
2470
- },
2471
- {
2472
- id: "interstella",
2473
- title: "Interstella",
2474
- config: {
2475
- ...PRESET_BASE,
2476
- type: "sphere",
2477
- uTime: 0,
2478
- uSpeed: 0.3,
2479
- uStrength: 0.3,
2480
- uDensity: 0.8,
2481
- uFrequency: 5.5,
2482
- uAmplitude: 3.2,
2483
- positionX: -0.1,
2484
- positionY: 0,
2485
- positionZ: 0,
2486
- rotationX: 0,
2487
- rotationY: 130,
2488
- rotationZ: 70,
2489
- color1: "#73bfc4",
2490
- color2: "#ff810a",
2491
- color3: "#8da0ce",
2492
- reflection: 0.4,
2493
- brightness: 0.8,
2494
- cAzimuthAngle: 270,
2495
- cPolarAngle: 180,
2496
- cDistance: 0.5,
2497
- cameraZoom: 15.1,
2498
- lightType: "env",
2499
- envPreset: "city",
2500
- grain: "on"
2501
- }
2502
- },
2503
- {
2504
- id: "nightyNight",
2505
- title: "Nighty night",
2506
- config: {
2507
- ...PRESET_BASE,
2508
- type: "waterPlane",
2509
- uTime: 8,
2510
- uSpeed: 0.3,
2511
- uStrength: 1.5,
2512
- uDensity: 1.5,
2513
- uFrequency: 0,
2514
- uAmplitude: 0,
2515
- positionX: 0,
2516
- positionY: 0,
2517
- positionZ: 0,
2518
- rotationX: 50,
2519
- rotationY: 0,
2520
- rotationZ: -60,
2521
- color1: "#606080",
2522
- color2: "#8d7dca",
2523
- color3: "#212121",
2524
- reflection: 0.1,
2525
- brightness: 1,
2526
- cAzimuthAngle: 180,
2527
- cPolarAngle: 80,
2528
- cDistance: 2.8,
2529
- cameraZoom: 9.1,
2530
- lightType: "3d",
2531
- envPreset: "city",
2532
- grain: "on"
2533
- }
2534
- },
2535
- {
2536
- id: "violaOrientalis",
2537
- title: "Viola orientalis",
2538
- config: {
2539
- ...PRESET_BASE,
2540
- type: "sphere",
2541
- uTime: 0,
2542
- uSpeed: 0.1,
2543
- uStrength: 1,
2544
- uDensity: 1.1,
2545
- uFrequency: 5.5,
2546
- uAmplitude: 1.4,
2547
- positionX: 0,
2548
- positionY: 0,
2549
- positionZ: 0,
2550
- rotationX: 0,
2551
- rotationY: 0,
2552
- rotationZ: 0,
2553
- color1: "#ffffff",
2554
- color2: "#ffbb00",
2555
- color3: "#0700ff",
2556
- reflection: 0.1,
2557
- brightness: 1.1,
2558
- cAzimuthAngle: 0,
2559
- cPolarAngle: 140,
2560
- cDistance: 7.1,
2561
- cameraZoom: 17.3,
2562
- lightType: "3d",
2563
- envPreset: "city",
2564
- grain: "off"
2565
- }
2566
- },
2567
- {
2568
- id: "universe",
2569
- title: "Universe",
2570
- config: {
2571
- ...PRESET_BASE,
2572
- type: "waterPlane",
2573
- uTime: 0.2,
2574
- uSpeed: 0.1,
2575
- uStrength: 2.4,
2576
- uDensity: 1.1,
2577
- uFrequency: 5.5,
2578
- uAmplitude: 0,
2579
- positionX: -0.5,
2580
- positionY: 0.1,
2581
- positionZ: 0,
2582
- rotationX: 0,
2583
- rotationY: 0,
2584
- rotationZ: 235,
2585
- color1: "#5606ff",
2586
- color2: "#fe8989",
2587
- color3: "#000000",
2588
- reflection: 0.1,
2589
- brightness: 1.1,
2590
- cAzimuthAngle: 180,
2591
- cPolarAngle: 115,
2592
- cDistance: 3.9,
2593
- cameraZoom: 1,
2594
- lightType: "3d",
2595
- envPreset: "city",
2596
- grain: "off"
2597
- }
2598
- },
2599
- {
2600
- id: "sunset",
2601
- title: "Sunset",
2602
- config: {
2603
- ...PRESET_BASE,
2604
- type: "sphere",
2605
- uTime: 0,
2606
- uSpeed: 0.1,
2607
- uStrength: 0.4,
2608
- uDensity: 1.1,
2609
- uFrequency: 5.5,
2610
- uAmplitude: 1.4,
2611
- positionX: 0,
2612
- positionY: -0.15,
2613
- positionZ: 0,
2614
- rotationX: 0,
2615
- rotationY: 0,
2616
- rotationZ: 0,
2617
- color1: "#ff7a33",
2618
- color2: "#33a0ff",
2619
- color3: "#ffc53d",
2620
- reflection: 0.1,
2621
- brightness: 1.5,
2622
- cAzimuthAngle: 60,
2623
- cPolarAngle: 90,
2624
- cDistance: 7.1,
2625
- cameraZoom: 15.3,
2626
- lightType: "3d",
2627
- envPreset: "dawn",
2628
- grain: "off"
2629
- }
2630
- },
2631
- {
2632
- id: "mandarin",
2633
- title: "Mandarin",
2634
- config: {
2635
- ...PRESET_BASE,
2636
- type: "waterPlane",
2637
- uTime: 0.2,
2638
- uSpeed: 0.2,
2639
- uStrength: 3,
2640
- uDensity: 1.8,
2641
- uFrequency: 5.5,
2642
- uAmplitude: 0,
2643
- positionX: 0,
2644
- positionY: -2.1,
2645
- positionZ: 0,
2646
- rotationX: 0,
2647
- rotationY: 0,
2648
- rotationZ: 225,
2649
- color1: "#ff6a1a",
2650
- color2: "#c73c00",
2651
- color3: "#fd4912",
2652
- reflection: 0.1,
2653
- brightness: 1.2,
2654
- cAzimuthAngle: 180,
2655
- cPolarAngle: 95,
2656
- cDistance: 2.4,
2657
- cameraZoom: 1,
2658
- lightType: "3d",
2659
- envPreset: "city",
2660
- grain: "off"
2661
- }
2662
- },
2663
- {
2664
- id: "cottonCandy",
2665
- title: "Cotton candy",
2666
- config: {
2667
- ...PRESET_BASE,
2668
- type: "waterPlane",
2669
- uTime: 0.2,
2670
- uSpeed: 0.3,
2671
- uStrength: 3,
2672
- uDensity: 1,
2673
- uFrequency: 5.5,
2674
- uAmplitude: 0,
2675
- positionX: 0,
2676
- positionY: 1.8,
2677
- positionZ: 0,
2678
- rotationX: 0,
2679
- rotationY: 0,
2680
- rotationZ: -90,
2681
- color1: "#ebedff",
2682
- color2: "#f3f2f8",
2683
- color3: "#dbf8ff",
2684
- reflection: 0.1,
2685
- brightness: 1.2,
2686
- cAzimuthAngle: 180,
2687
- cPolarAngle: 120,
2688
- cDistance: 2.9,
2689
- cameraZoom: 1,
2690
- lightType: "3d",
2691
- envPreset: "city",
2692
- grain: "off"
2693
- }
2694
- }
2695
- ];
2696
- var HEX = /^#([0-9a-fA-F]{6})$/;
2697
- var ON_OFF = new Set(SHADER_ON_OFF);
2698
- var TYPES = new Set(SHADER_CURTAIN_TYPES);
2699
- var VARIANTS = new Set(SHADER_VARIANTS);
2700
- var LIGHTS = new Set(SHADER_LIGHT_TYPES);
2701
- var ENVS = new Set(SHADER_ENV_PRESETS);
2702
- var RANGES = new Set(SHADER_RANGE);
2703
- function clamp(value, min, max) {
2704
- return Math.min(max, Math.max(min, value));
2705
- }
2706
- function numberParam(raw, fallback, min, max) {
2707
- if (raw == null || raw === "") return fallback;
2708
- const parsed = Number(raw);
2709
- if (!Number.isFinite(parsed)) return fallback;
2710
- return clamp(parsed, min, max);
2711
- }
2712
- function hexParam(raw, fallback) {
2713
- if (!raw) return fallback;
2714
- const value = raw.startsWith("#") ? raw : `#${raw}`;
2715
- return HEX.test(value) ? value : fallback;
2716
- }
2717
- function enumParam(raw, allowed, fallback) {
2718
- if (!raw) return fallback;
2719
- return allowed.has(raw) ? raw : fallback;
2720
- }
2721
- function boolParam(raw, fallback) {
2722
- if (raw == null) return fallback;
2723
- if (raw === "true" || raw === "1" || raw === "on") return true;
2724
- if (raw === "false" || raw === "0" || raw === "off") return false;
2725
- return fallback;
2726
- }
2727
- function mergeShaderCurtainConfig(partial) {
2728
- return { ...DEFAULT_SHADER_CURTAIN_CONFIG, ...partial };
2729
- }
2730
- function parseShaderGradientUrl(input) {
2731
- const trimmed = input.trim();
2732
- if (!trimmed) return null;
2733
- let url;
2734
- try {
2735
- url = new URL(trimmed);
2736
- } catch {
2737
- try {
2738
- url = new URL(`https://www.shadergradient.co/customize?${trimmed}`);
2739
- } catch {
2740
- return null;
2741
- }
2742
- }
2743
- const q = url.searchParams;
2744
- const known = [
2745
- "type",
2746
- "shader",
2747
- "animate",
2748
- "color1",
2749
- "uSpeed",
2750
- "uStrength",
2751
- "cDistance",
2752
- "lightType"
2753
- ];
2754
- if (!known.some((key) => q.has(key))) return null;
2755
- const base = DEFAULT_SHADER_CURTAIN_CONFIG;
2756
- return {
2757
- type: enumParam(q.get("type"), TYPES, base.type),
2758
- shader: enumParam(q.get("shader"), VARIANTS, base.shader),
2759
- animate: enumParam(q.get("animate"), ON_OFF, base.animate),
2760
- uTime: numberParam(q.get("uTime"), base.uTime, 0, 40),
2761
- uSpeed: numberParam(q.get("uSpeed"), base.uSpeed, 0, 4),
2762
- uStrength: numberParam(q.get("uStrength"), base.uStrength, 0, 10),
2763
- uDensity: numberParam(q.get("uDensity"), base.uDensity, 0, 8),
2764
- uFrequency: numberParam(q.get("uFrequency"), base.uFrequency, 0, 12),
2765
- uAmplitude: numberParam(q.get("uAmplitude"), base.uAmplitude, 0, 8),
2766
- wireframe: boolParam(q.get("wireframe"), base.wireframe),
2767
- loop: enumParam(q.get("loop"), ON_OFF, base.loop),
2768
- loopDuration: numberParam(q.get("loopDuration"), base.loopDuration, 1, 60),
2769
- range: enumParam(q.get("range"), RANGES, base.range),
2770
- rangeStart: numberParam(q.get("rangeStart"), base.rangeStart, 0, 40),
2771
- rangeEnd: numberParam(q.get("rangeEnd"), base.rangeEnd, 0, 40),
2772
- positionX: numberParam(q.get("positionX"), base.positionX, -20, 20),
2773
- positionY: numberParam(q.get("positionY"), base.positionY, -20, 20),
2774
- positionZ: numberParam(q.get("positionZ"), base.positionZ, -20, 20),
2775
- rotationX: numberParam(q.get("rotationX"), base.rotationX, -360, 360),
2776
- rotationY: numberParam(q.get("rotationY"), base.rotationY, -360, 360),
2777
- rotationZ: numberParam(q.get("rotationZ"), base.rotationZ, -360, 360),
2778
- color1: hexParam(q.get("color1"), base.color1),
2779
- color2: hexParam(q.get("color2"), base.color2),
2780
- color3: hexParam(q.get("color3"), base.color3),
2781
- reflection: numberParam(q.get("reflection"), base.reflection, 0, 1),
2782
- brightness: numberParam(q.get("brightness"), base.brightness, 0, 4),
2783
- cAzimuthAngle: numberParam(
2784
- q.get("cAzimuthAngle"),
2785
- base.cAzimuthAngle,
2786
- 0,
2787
- 360
2788
- ),
2789
- cPolarAngle: numberParam(q.get("cPolarAngle"), base.cPolarAngle, 0, 180),
2790
- cDistance: numberParam(q.get("cDistance"), base.cDistance, 0.1, 40),
2791
- cameraZoom: numberParam(q.get("cameraZoom"), base.cameraZoom, 0.1, 50),
2792
- fov: numberParam(q.get("fov"), base.fov, 10, 120),
2793
- zoomOut: boolParam(q.get("zoomOut"), base.zoomOut),
2794
- lightType: enumParam(q.get("lightType"), LIGHTS, base.lightType),
2795
- envPreset: enumParam(q.get("envPreset"), ENVS, base.envPreset),
2796
- grain: enumParam(q.get("grain"), ON_OFF, base.grain),
2797
- grainBlending: numberParam(
2798
- q.get("grainBlending"),
2799
- base.grainBlending,
2800
- 0,
2801
- 1
2802
- ),
2803
- pixelDensity: numberParam(q.get("pixelDensity"), base.pixelDensity, 0.5, 2)
2804
- };
2805
- }
2806
- function toShaderGradientUrl(config) {
2807
- const params = new URLSearchParams();
2808
- Object.keys(DEFAULT_SHADER_CURTAIN_CONFIG).forEach((key) => {
2809
- params.set(key, String(config[key]));
2810
- });
2811
- return `https://www.shadergradient.co/customize?${params.toString()}`;
2812
- }
2813
- function isShaderCurtainKind(kind) {
2814
- return kind === "shader";
2815
- }
2816
- function webglAvailable() {
2817
- if (typeof document === "undefined") return false;
2818
- try {
2819
- const canvas = document.createElement("canvas");
2820
- return Boolean(
2821
- canvas.getContext("webgl") || canvas.getContext("experimental-webgl")
2822
- );
2823
- } catch {
2824
- return false;
2825
- }
2826
- }
2827
- function Poster({
2828
- url,
2829
- alt,
2830
- className
2831
- }) {
2832
- if (!url) {
2833
- return /* @__PURE__ */ jsx(
2834
- "div",
2835
- {
2836
- className: cn("h-full w-full bg-zinc-950", className),
2837
- "aria-hidden": alt ? void 0 : true
2838
- }
2839
- );
2840
- }
2841
- return /* @__PURE__ */ jsx(
2842
- "img",
2843
- {
2844
- src: url,
2845
- alt,
2846
- className: cn("h-full w-full object-cover", className)
2847
- }
2848
- );
2849
- }
2850
- function ShaderCurtain({
2851
- config,
2852
- posterUrl,
2853
- envBasePath,
2854
- className,
2855
- preserveDrawingBuffer = false,
2856
- reducedMotion = false,
2857
- alt = ""
2858
- }) {
2859
- const [module, setModule] = React11.useState(null);
2860
- const [failed, setFailed] = React11.useState(false);
2861
- const resolved = mergeShaderCurtainConfig(config);
2862
- React11.useEffect(() => {
2863
- if (reducedMotion || !webglAvailable()) {
2864
- setFailed(true);
2865
- return;
2866
- }
2867
- let cancelled = false;
2868
- void import(
2869
- /* turbopackOptional: true */
2870
- '@shadergradient/react'
2871
- ).then((loaded) => {
2872
- if (cancelled) return;
2873
- if (!loaded.ShaderGradientCanvas || !loaded.ShaderGradient) {
2874
- setFailed(true);
2875
- return;
2876
- }
2877
- setModule(loaded);
2878
- }).catch(() => {
2879
- if (!cancelled) setFailed(true);
2880
- });
2881
- return () => {
2882
- cancelled = true;
2883
- };
2884
- }, [reducedMotion]);
2885
- if (failed || reducedMotion || !module) {
2886
- return /* @__PURE__ */ jsx(Poster, { url: posterUrl, alt, className });
2887
- }
2888
- const { ShaderGradientCanvas, ShaderGradient } = module;
2889
- const animate = resolved.animate === "off" || reducedMotion ? "off" : "on";
2890
- return /* @__PURE__ */ jsx(
2891
- "div",
2892
- {
2893
- className: cn(
2894
- "relative h-full w-full overflow-hidden [container-type:size]",
2895
- className
2896
- ),
2897
- children: /* @__PURE__ */ jsx("div", { className: "absolute top-1/2 left-1/2 h-[max(100cqh,56.25cqw)] w-[max(100cqw,177.778cqh)] -translate-x-1/2 -translate-y-1/2", children: /* @__PURE__ */ jsx(
2898
- ShaderGradientCanvas,
2899
- {
2900
- style: { position: "absolute", inset: 0 },
2901
- pixelDensity: resolved.pixelDensity,
2902
- fov: resolved.fov,
2903
- envBasePath,
2904
- preserveDrawingBuffer,
2905
- children: /* @__PURE__ */ jsx(
2906
- ShaderGradient,
2907
- {
2908
- control: "props",
2909
- type: resolved.type,
2910
- shader: resolved.shader,
2911
- animate,
2912
- uTime: resolved.uTime,
2913
- uSpeed: resolved.uSpeed,
2914
- uStrength: resolved.uStrength,
2915
- uDensity: resolved.uDensity,
2916
- uFrequency: resolved.uFrequency,
2917
- uAmplitude: resolved.uAmplitude,
2918
- wireframe: resolved.wireframe,
2919
- loop: resolved.loop,
2920
- loopDuration: resolved.loopDuration,
2921
- range: resolved.range,
2922
- rangeStart: resolved.rangeStart,
2923
- rangeEnd: resolved.rangeEnd,
2924
- positionX: resolved.positionX,
2925
- positionY: resolved.positionY,
2926
- positionZ: resolved.positionZ,
2927
- rotationX: resolved.rotationX,
2928
- rotationY: resolved.rotationY,
2929
- rotationZ: resolved.rotationZ,
2930
- color1: resolved.color1,
2931
- color2: resolved.color2,
2932
- color3: resolved.color3,
2933
- reflection: resolved.reflection,
2934
- brightness: resolved.brightness,
2935
- cAzimuthAngle: resolved.cAzimuthAngle,
2936
- cPolarAngle: resolved.cPolarAngle,
2937
- cDistance: resolved.cDistance,
2938
- cameraZoom: resolved.cameraZoom,
2939
- zoomOut: resolved.zoomOut,
2940
- lightType: resolved.lightType,
2941
- envPreset: resolved.envPreset,
2942
- grain: resolved.grain,
2943
- grainBlending: resolved.grainBlending
2944
- }
2945
- )
2946
- }
2947
- ) })
2948
- }
2949
- );
2950
- }
2951
- var DEFAULT_LABELS2 = {
2952
- play: "Play",
2953
- tapToUnmute: "Tap to unmute",
2954
- mute: "Mute",
2955
- unmute: "Unmute"
2956
- };
2957
- var CURTAIN_VIDEO_STYLE = `
2958
- .livo-curtain-video::-webkit-media-controls-start-playback-button {
2959
- display: none !important;
2960
- -webkit-appearance: none;
2961
- }
2962
- .livo-curtain-video::-webkit-media-controls {
2963
- display: none !important;
2964
- }
2965
- `;
2966
- function isAudioTrackList(value) {
2967
- return typeof value === "object" && value !== null && typeof value.getTrackById === "function";
2968
- }
2969
- function probeVideoAudio(el) {
2970
- const video = el;
2971
- if (typeof video.mozHasAudio === "boolean") {
2972
- return video.mozHasAudio ? "yes" : "no";
2973
- }
2974
- if (typeof video.webkitAudioDecodedByteCount === "number" && video.webkitAudioDecodedByteCount > 0) {
2975
- return "yes";
2976
- }
2977
- if (isAudioTrackList(video.audioTracks)) {
2978
- return video.audioTracks.length > 0 ? "yes" : "no";
2979
- }
2980
- return "unknown";
2981
- }
2982
- function usePrefersReducedMotion() {
2983
- const [reduced, setReduced] = React11.useState(false);
2984
- React11.useEffect(() => {
2985
- const media = window.matchMedia("(prefers-reduced-motion: reduce)");
2986
- const sync = () => setReduced(media.matches);
2987
- sync();
2988
- media.addEventListener("change", sync);
2989
- return () => media.removeEventListener("change", sync);
2990
- }, []);
2991
- return reduced;
2992
- }
2993
- function CurtainVideo({
2994
- url,
2995
- alt,
2996
- className,
2997
- freeze,
2998
- allowSound,
2999
- labels
3000
- }) {
3001
- const videoRef = React11.useRef(null);
3002
- const [playback, setPlayback] = React11.useState("pending");
3003
- const [muted, setMuted] = React11.useState(true);
3004
- const [audio, setAudio] = React11.useState("unknown");
3005
- React11.useEffect(() => {
3006
- const el = videoRef.current;
3007
- if (!el) return;
3008
- el.setAttribute("webkit-playsinline", "");
3009
- el.muted = true;
3010
- setMuted(true);
3011
- setAudio("unknown");
3012
- setPlayback("pending");
3013
- if (freeze) {
3014
- el.pause();
3015
- return;
3016
- }
3017
- let cancelled = false;
3018
- const applyAudio = () => {
3019
- const next = probeVideoAudio(el);
3020
- if (next !== "unknown") setAudio(next);
3021
- };
3022
- const tryPlay = () => {
3023
- if (cancelled) return;
3024
- void el.play().then(
3025
- () => {
3026
- if (cancelled) return;
3027
- setPlayback("playing");
3028
- applyAudio();
3029
- },
3030
- () => {
3031
- if (!cancelled && el.paused) setPlayback("blocked");
3032
- }
3033
- );
3034
- };
3035
- tryPlay();
3036
- el.addEventListener("canplay", tryPlay);
3037
- el.addEventListener("timeupdate", applyAudio);
3038
- el.addEventListener("loadedmetadata", applyAudio);
3039
- return () => {
3040
- cancelled = true;
3041
- el.removeEventListener("canplay", tryPlay);
3042
- el.removeEventListener("timeupdate", applyAudio);
3043
- el.removeEventListener("loadedmetadata", applyAudio);
3044
- };
3045
- }, [url, freeze]);
3046
- const startPlayback = React11.useCallback(() => {
3047
- const el = videoRef.current;
3048
- if (!el) return;
3049
- el.muted = true;
3050
- setMuted(true);
3051
- void el.play().then(
3052
- () => {
3053
- setPlayback("playing");
3054
- const next = probeVideoAudio(el);
3055
- if (next !== "unknown") setAudio(next);
3056
- },
3057
- () => {
3058
- if (el.paused) setPlayback("blocked");
3059
- }
3060
- );
3061
- }, []);
3062
- const setVideoMuted = React11.useCallback((next) => {
3063
- const el = videoRef.current;
3064
- if (el) el.muted = next;
3065
- setMuted(next);
3066
- }, []);
3067
- const showUnmute = allowSound && !freeze && playback === "playing" && muted && audio !== "no";
3068
- const showMute = allowSound && !freeze && playback === "playing" && !muted;
3069
- return /* @__PURE__ */ jsxs("div", { className: cn("relative h-full w-full", className), children: [
3070
- /* @__PURE__ */ jsx("style", { children: CURTAIN_VIDEO_STYLE }),
3071
- /* @__PURE__ */ jsx(
3072
- "video",
3073
- {
3074
- ref: videoRef,
3075
- src: url,
3076
- className: "livo-curtain-video h-full w-full object-cover",
3077
- autoPlay: !freeze,
3078
- muted,
3079
- loop: !freeze,
3080
- playsInline: true,
3081
- preload: freeze ? "metadata" : void 0,
3082
- "aria-hidden": alt ? void 0 : true
3083
- }
3084
- ),
3085
- playback === "blocked" && !freeze ? /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/40", children: /* @__PURE__ */ jsx(
3086
- "button",
3087
- {
3088
- type: "button",
3089
- "aria-label": labels.play,
3090
- onClick: startPlayback,
3091
- className: "flex size-16 items-center justify-center rounded-full bg-white/20 backdrop-blur-sm transition hover:bg-white/30",
3092
- children: /* @__PURE__ */ jsx(Play, { className: "size-8 translate-x-0.5", fill: "currentColor" })
3093
- }
3094
- ) }) : null,
3095
- showUnmute ? /* @__PURE__ */ jsxs(
3096
- "button",
3097
- {
3098
- type: "button",
3099
- onClick: () => setVideoMuted(false),
3100
- className: "absolute top-3 right-3 z-20 flex items-center gap-1.5 rounded-full bg-black/70 px-3 py-1.5 text-xs text-white backdrop-blur-sm transition hover:bg-black/90",
3101
- children: [
3102
- /* @__PURE__ */ jsx(VolumeX, { className: "size-4" }),
3103
- labels.tapToUnmute
3104
- ]
3105
- }
3106
- ) : null,
3107
- showMute ? /* @__PURE__ */ jsx(
3108
- "button",
3109
- {
3110
- type: "button",
3111
- "aria-label": labels.mute,
3112
- onClick: () => setVideoMuted(true),
3113
- className: "absolute top-3 right-3 z-20 flex items-center gap-1.5 rounded-full bg-black/70 px-3 py-1.5 text-xs text-white backdrop-blur-sm transition hover:bg-black/90",
3114
- children: /* @__PURE__ */ jsx(Volume2, { className: "size-4" })
3115
- }
3116
- ) : null
3117
- ] });
3118
- }
3119
- function CurtainStage({
3120
- kind,
3121
- url,
3122
- alt = "",
3123
- className,
3124
- config,
3125
- envBasePath,
3126
- reducedMotion,
3127
- allowSound = false,
3128
- labels
3129
- }) {
3130
- const prefersReduced = usePrefersReducedMotion();
3131
- const freeze = reducedMotion ?? prefersReduced;
3132
- const copy = { ...DEFAULT_LABELS2, ...labels };
3133
- switch (kind) {
3134
- case "video":
3135
- return /* @__PURE__ */ jsx(
3136
- CurtainVideo,
3137
- {
3138
- url,
3139
- alt,
3140
- className,
3141
- freeze,
3142
- allowSound,
3143
- labels: copy
3144
- }
3145
- );
3146
- case "shader":
3147
- return /* @__PURE__ */ jsx(
3148
- ShaderCurtain,
3149
- {
3150
- config: mergeShaderCurtainConfig(config),
3151
- posterUrl: url,
3152
- envBasePath,
3153
- reducedMotion: freeze,
3154
- alt,
3155
- className
3156
- }
3157
- );
3158
- case "image":
3159
- return /* @__PURE__ */ jsx(
3160
- "img",
3161
- {
3162
- src: url,
3163
- alt,
3164
- className: cn("h-full w-full object-cover", className)
3165
- }
3166
- );
3167
- default: {
3168
- const _exhaustive = kind;
3169
- return _exhaustive;
3170
- }
3171
- }
3172
- }
3173
- function useMediaQuery2(query) {
3174
- const [matches, setMatches] = useState(false);
3175
- useEffect(() => {
3176
- if (typeof window === "undefined" || !window.matchMedia) return;
3177
- const mql = window.matchMedia(query);
3178
- const onChange = () => setMatches(mql.matches);
3179
- onChange();
3180
- mql.addEventListener("change", onChange);
3181
- return () => mql.removeEventListener("change", onChange);
3182
- }, [query]);
3183
- return matches;
3184
- }
3185
- function isVideoKind(kind) {
3186
- return kind === "video";
3187
- }
3188
- function useElementInView(enabled) {
3189
- const [node, setNode] = React11.useState(null);
3190
- const [inView, setInView] = React11.useState(false);
3191
- React11.useEffect(() => {
3192
- if (!enabled || !node || typeof IntersectionObserver === "undefined") {
3193
- setInView(false);
3194
- return;
3195
- }
3196
- const observer = new IntersectionObserver(
3197
- (entries) => {
3198
- const entry = entries[0];
3199
- setInView(Boolean(entry?.isIntersecting));
3200
- },
3201
- { threshold: 0.35, rootMargin: "32px" }
3202
- );
3203
- observer.observe(node);
3204
- return () => observer.disconnect();
3205
- }, [enabled, node]);
3206
- return [setNode, inView];
3207
- }
3208
- function CurtainPreview({
3209
- kind,
3210
- url,
3211
- alt = "",
3212
- className,
3213
- playWhenVisible = true,
3214
- frozen = false
3215
- }) {
3216
- const prefersReduced = useMediaQuery2("(prefers-reduced-motion: reduce)");
3217
- const video = isVideoKind(kind);
3218
- const observe = !frozen && playWhenVisible && video && !prefersReduced;
3219
- const [setNode, inView] = useElementInView(observe);
3220
- const shouldPlay = !frozen && video && !prefersReduced && (!playWhenVisible || inView);
3221
- if (!url) {
3222
- return /* @__PURE__ */ jsx(
3223
- "div",
3224
- {
3225
- ref: setNode,
3226
- className: cn("aspect-video rounded-md bg-skeleton", className),
3227
- "aria-hidden": "true"
3228
- }
3229
- );
3230
- }
3231
- const stageKind = video ? "video" : "image";
3232
- return /* @__PURE__ */ jsx(
3233
- "div",
3234
- {
3235
- ref: setNode,
3236
- className: cn(
3237
- "aspect-video overflow-hidden rounded-md bg-black",
3238
- className
3239
- ),
3240
- children: /* @__PURE__ */ jsx(
3241
- CurtainStage,
3242
- {
3243
- kind: stageKind,
3244
- url,
3245
- alt,
3246
- reducedMotion: !shouldPlay,
3247
- className: "h-full w-full"
3248
- }
3249
- )
3250
- }
3251
- );
3252
- }
3253
- var DEFAULT_CURTAIN_PICKER_LABELS = {
3254
- select: "Curtain",
3255
- none: "None",
3256
- noneDescription: "Use the default curtain",
3257
- defaultBadge: "Default",
3258
- makeDefault: "Set as default",
3259
- edit: "Edit",
3260
- delete: "Delete",
3261
- image: "Image",
3262
- video: "Video",
3263
- shader: "Shader",
3264
- organization: "Organization",
3265
- platform: "Catalog",
3266
- groupOrganization: "Your curtains",
3267
- groupPlatform: "Catalog",
3268
- groupOther: "Other",
3269
- emptyTitle: "No curtains yet",
3270
- emptyDescription: "Upload an image or a short looping video."
3271
- };
3272
- var OWNER_GROUPS = [
3273
- "organization",
3274
- "platform",
3275
- "other"
3276
- ];
3277
- function ownerGroup(ownerType) {
3278
- switch (ownerType) {
3279
- case "organization":
3280
- return "organization";
3281
- case "platform":
3282
- return "platform";
3283
- default:
3284
- return "other";
3285
- }
3286
- }
3287
- function kindLabel(kind, copy) {
3288
- if (kind === "video") return copy.video;
3289
- if (kind === "shader") return copy.shader;
3290
- return copy.image;
3291
- }
3292
- function ownerLabel(ownerType, copy) {
3293
- if (ownerType === "organization") return copy.organization;
3294
- if (ownerType === "platform") return copy.platform;
3295
- return null;
3296
- }
3297
- function groupHeading(group, copy) {
3298
- const headings = {
3299
- organization: copy.groupOrganization,
3300
- platform: copy.groupPlatform,
3301
- other: copy.groupOther
3302
- };
3303
- return headings[group];
3304
- }
3305
- function gridClass(variant) {
3306
- return variant === "compact" ? "grid grid-cols-3 gap-2 sm:grid-cols-4 lg:grid-cols-6" : "grid gap-4 sm:grid-cols-2 lg:grid-cols-3";
3307
- }
3308
- function selectionRing(selectable) {
3309
- return selectable && "has-[:checked]:ring-ring has-[:checked]:ring-2 has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-2";
3310
- }
3311
- function resolvePreviewItem(selectedId, ready, allowNone) {
3312
- if (selectedId) {
3313
- return ready.find((curtain) => curtain.id === selectedId) ?? ready[0] ?? null;
3314
- }
3315
- if (allowNone) return null;
3316
- return ready[0] ?? null;
3317
- }
3318
- function itemActions(item, onMakeDefault, onEdit, onDelete, canMakeDefault, canDelete) {
3319
- if (!item) return {};
3320
- return {
3321
- onMakeDefault: onMakeDefault && (canMakeDefault ? canMakeDefault(item) : !item.isDefault) ? () => onMakeDefault(item) : void 0,
3322
- onEdit: onEdit ? () => onEdit(item) : void 0,
3323
- onDelete: onDelete && (canDelete ? canDelete(item) : true) ? () => onDelete(item) : void 0
3324
- };
3325
- }
3326
- function CurtainPickerSkeleton({
3327
- count = 6,
3328
- variant = "default",
3329
- className
3330
- }) {
3331
- if (variant === "compact") {
3332
- return /* @__PURE__ */ jsxs("div", { className: cn("space-y-4", className), "aria-hidden": "true", children: [
3333
- /* @__PURE__ */ jsxs("div", { className: "max-w-sm space-y-3", children: [
3334
- /* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
3335
- /* @__PURE__ */ jsx("div", { className: "h-4 w-2/3 rounded bg-skeleton" }),
3336
- /* @__PURE__ */ jsx("div", { className: "h-3 w-1/2 rounded bg-skeleton" })
3337
- ] }),
3338
- /* @__PURE__ */ jsx("ul", { className: gridClass("compact"), children: Array.from({ length: count }, (_, index) => /* @__PURE__ */ jsxs("li", { className: "space-y-1.5 rounded-lg border p-1.5", children: [
3339
- /* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
3340
- /* @__PURE__ */ jsx("div", { className: "h-3 w-3/4 rounded bg-skeleton" })
3341
- ] }, index)) })
3342
- ] });
3343
- }
3344
- return /* @__PURE__ */ jsx("ul", { className: cn(gridClass(variant), className), "aria-hidden": "true", children: Array.from({ length: count }, (_, index) => /* @__PURE__ */ jsxs("li", { className: "space-y-3 rounded-xl border p-4", children: [
3345
- /* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
3346
- /* @__PURE__ */ jsx("div", { className: "h-4 w-2/3 rounded bg-skeleton" }),
3347
- /* @__PURE__ */ jsx("div", { className: "h-3 w-1/3 rounded bg-skeleton" })
3348
- ] }, index)) });
3349
- }
3350
- function CurtainPicker({
3351
- curtains,
3352
- value = null,
3353
- onChange,
3354
- allowNone = false,
3355
- disabled = false,
3356
- variant = "default",
3357
- groupByOwner = false,
3358
- onMakeDefault,
3359
- onEdit,
3360
- onDelete,
3361
- canMakeDefault,
3362
- canDelete,
3363
- labels,
3364
- emptyAction,
3365
- className,
3366
- actionsPending = false
3367
- }) {
3368
- const copy = { ...DEFAULT_CURTAIN_PICKER_LABELS, ...labels };
3369
- const groupName = React11.useId();
3370
- const selectable = typeof onChange === "function";
3371
- const compact = variant === "compact";
3372
- const selectedId = value === "" ? null : value ?? null;
3373
- const ready = curtains.filter((curtain) => curtain.publicUrl);
3374
- const showEmpty = ready.length === 0 && !allowNone;
3375
- const previewItem = resolvePreviewItem(selectedId, ready, allowNone);
3376
- const selectedItem = selectedId ? ready.find((curtain) => curtain.id === selectedId) ?? null : null;
3377
- const actionTarget = selectedItem ?? (!selectable ? previewItem : null);
3378
- const compactActions = compact ? itemActions(
3379
- actionTarget,
3380
- onMakeDefault,
3381
- onEdit,
3382
- onDelete,
3383
- canMakeDefault,
3384
- canDelete
3385
- ) : {};
3386
- const grouped = React11.useMemo(() => {
3387
- if (!groupByOwner) {
3388
- return [{ group: null, items: ready }];
3389
- }
3390
- return OWNER_GROUPS.map((group) => ({
3391
- group,
3392
- items: ready.filter((curtain) => ownerGroup(curtain.ownerType) === group)
3393
- })).filter((section) => section.items.length > 0);
3394
- }, [groupByOwner, ready]);
3395
- if (showEmpty) {
3396
- return /* @__PURE__ */ jsx(
3397
- EmptyState,
3398
- {
3399
- title: copy.emptyTitle,
3400
- description: copy.emptyDescription,
3401
- action: emptyAction,
3402
- className
3403
- }
3404
- );
3405
- }
3406
- const noneTile = allowNone && selectable ? /* @__PURE__ */ jsx(
3407
- NoneTile,
3408
- {
3409
- name: groupName,
3410
- checked: selectedId === null,
3411
- disabled,
3412
- copy,
3413
- compact,
3414
- onSelect: () => onChange(null)
3415
- }
3416
- ) : null;
3417
- const sections = grouped.length === 0 && noneTile ? [{ group: null, items: [] }] : grouped;
3418
- return /* @__PURE__ */ jsxs("div", { className: cn(compact ? "space-y-4" : "space-y-6", className), children: [
3419
- compact ? /* @__PURE__ */ jsx(
3420
- SelectedPreview,
3421
- {
3422
- item: previewItem,
3423
- copy,
3424
- disabled,
3425
- actionsPending,
3426
- onMakeDefault: compactActions.onMakeDefault,
3427
- onEdit: compactActions.onEdit,
3428
- onDelete: compactActions.onDelete
3429
- }
3430
- ) : null,
3431
- sections.map((section, index) => /* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
3432
- section.group ? /* @__PURE__ */ jsx("h3", { className: "text-muted-foreground text-sm font-medium", children: groupHeading(section.group, copy) }) : null,
3433
- /* @__PURE__ */ jsxs("ul", { className: gridClass(variant), children: [
3434
- index === 0 && noneTile ? /* @__PURE__ */ jsx("li", { children: noneTile }) : null,
3435
- section.items.map((item) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
3436
- CurtainPickerCard,
3437
- {
3438
- item,
3439
- name: groupName,
3440
- selectable,
3441
- checked: selectedId === item.id,
3442
- disabled,
3443
- actionsPending,
3444
- copy,
3445
- compact,
3446
- onSelect: onChange ? () => onChange(item.id) : void 0,
3447
- onMakeDefault: compact ? void 0 : itemActions(
3448
- item,
3449
- onMakeDefault,
3450
- onEdit,
3451
- onDelete,
3452
- canMakeDefault,
3453
- canDelete
3454
- ).onMakeDefault,
3455
- onEdit: compact ? void 0 : itemActions(
3456
- item,
3457
- onMakeDefault,
3458
- onEdit,
3459
- onDelete,
3460
- canMakeDefault,
3461
- canDelete
3462
- ).onEdit,
3463
- onDelete: compact ? void 0 : itemActions(
3464
- item,
3465
- onMakeDefault,
3466
- onEdit,
3467
- onDelete,
3468
- canMakeDefault,
3469
- canDelete
3470
- ).onDelete
3471
- }
3472
- ) }, item.id))
3473
- ] })
3474
- ] }, section.group ?? "all"))
3475
- ] });
3476
- }
3477
- function SelectedPreview({
3478
- item,
3479
- copy,
3480
- disabled,
3481
- actionsPending,
3482
- onMakeDefault,
3483
- onEdit,
3484
- onDelete
3485
- }) {
3486
- const owner = item ? ownerLabel(item.ownerType, copy) : null;
3487
- return /* @__PURE__ */ jsxs("div", { className: "max-w-sm space-y-3", children: [
3488
- item ? /* @__PURE__ */ jsxs(Fragment, { children: [
3489
- /* @__PURE__ */ jsx(
3490
- CurtainPreview,
3491
- {
3492
- kind: item.kind,
3493
- url: item.publicUrl,
3494
- alt: "",
3495
- className: "pointer-events-none"
3496
- }
3497
- ),
3498
- /* @__PURE__ */ jsx(
3499
- ItemMeta,
3500
- {
3501
- title: item.title,
3502
- detail: [kindLabel(item.kind, copy), owner].filter(Boolean).join(" \xB7 "),
3503
- isDefault: item.isDefault,
3504
- defaultBadge: copy.defaultBadge
3505
- }
3506
- )
3507
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
3508
- /* @__PURE__ */ jsx(
3509
- "div",
3510
- {
3511
- className: "aspect-video rounded-md bg-gradient-to-br from-zinc-900 to-zinc-950",
3512
- "aria-hidden": "true"
3513
- }
3514
- ),
3515
- /* @__PURE__ */ jsxs("div", { children: [
3516
- /* @__PURE__ */ jsx("p", { className: "font-medium", children: copy.none }),
3517
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: copy.noneDescription })
3518
- ] })
3519
- ] }),
3520
- /* @__PURE__ */ jsx(
3521
- ManageActions,
3522
- {
3523
- disabled,
3524
- actionsPending,
3525
- copy,
3526
- onMakeDefault,
3527
- onEdit,
3528
- onDelete
3529
- }
3530
- )
3531
- ] });
3532
- }
3533
- function ItemMeta({
3534
- title,
3535
- detail,
3536
- isDefault,
3537
- defaultBadge
3538
- }) {
3539
- return /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
3540
- /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
3541
- /* @__PURE__ */ jsx("p", { className: "truncate font-medium", children: title }),
3542
- detail ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: detail }) : null
3543
- ] }),
3544
- isDefault ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground shrink-0 text-xs", children: defaultBadge }) : null
3545
- ] });
3546
- }
3547
- function ManageActions({
3548
- disabled,
3549
- actionsPending,
3550
- copy,
3551
- onMakeDefault,
3552
- onEdit,
3553
- onDelete
3554
- }) {
3555
- if (!onMakeDefault && !onEdit && !onDelete) return null;
3556
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
3557
- onMakeDefault ? /* @__PURE__ */ jsx(
3558
- Button,
3559
- {
3560
- type: "button",
3561
- size: "sm",
3562
- variant: "secondary",
3563
- disabled: disabled || actionsPending,
3564
- onClick: onMakeDefault,
3565
- children: copy.makeDefault
3566
- }
3567
- ) : null,
3568
- onEdit ? /* @__PURE__ */ jsx(
3569
- Button,
3570
- {
3571
- type: "button",
3572
- size: "sm",
3573
- variant: "secondary",
3574
- disabled: disabled || actionsPending,
3575
- onClick: onEdit,
3576
- children: copy.edit
3577
- }
3578
- ) : null,
3579
- onDelete ? /* @__PURE__ */ jsx(
3580
- Button,
3581
- {
3582
- type: "button",
3583
- size: "sm",
3584
- variant: "destructive",
3585
- disabled: disabled || actionsPending,
3586
- onClick: onDelete,
3587
- children: copy.delete
3588
- }
3589
- ) : null
3590
- ] });
3591
- }
3592
- function NoneTile({
3593
- name,
3594
- checked,
3595
- disabled,
3596
- copy,
3597
- compact,
3598
- onSelect
3599
- }) {
3600
- return /* @__PURE__ */ jsxs(
3601
- "label",
3602
- {
3603
- className: cn(
3604
- "block cursor-pointer transition-shadow",
3605
- compact ? "flex min-h-11 flex-col gap-1.5 rounded-lg border p-1.5" : "space-y-3 rounded-xl border p-4",
3606
- "has-[:checked]:ring-ring has-[:checked]:ring-2",
3607
- "has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-2",
3608
- disabled && "pointer-events-none opacity-50"
3609
- ),
3610
- children: [
3611
- /* @__PURE__ */ jsx(
3612
- "input",
3613
- {
3614
- type: "radio",
3615
- name,
3616
- value: "",
3617
- checked,
3618
- disabled,
3619
- onChange: onSelect,
3620
- className: "sr-only"
3621
- }
3622
- ),
3623
- /* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-gradient-to-br from-zinc-900 to-zinc-950" }),
3624
- compact ? /* @__PURE__ */ jsx("p", { className: "truncate text-xs font-medium", children: copy.none }) : /* @__PURE__ */ jsxs("div", { children: [
3625
- /* @__PURE__ */ jsx("p", { className: "font-medium", children: copy.none }),
3626
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: copy.noneDescription })
3627
- ] })
3628
- ]
3629
- }
3630
- );
3631
- }
3632
- function CurtainPickerCard({
3633
- item,
3634
- name,
3635
- selectable,
3636
- checked,
3637
- disabled,
3638
- actionsPending,
3639
- copy,
3640
- compact,
3641
- onSelect,
3642
- onMakeDefault,
3643
- onEdit,
3644
- onDelete
3645
- }) {
3646
- const owner = ownerLabel(item.ownerType, copy);
3647
- const media = /* @__PURE__ */ jsx(
3648
- CurtainPreview,
3649
- {
3650
- kind: item.kind,
3651
- url: item.publicUrl,
3652
- alt: item.title,
3653
- frozen: compact
3654
- }
3655
- );
3656
- const meta = compact ? /* @__PURE__ */ jsx("p", { className: "truncate text-xs font-medium", children: item.title }) : /* @__PURE__ */ jsx(
3657
- ItemMeta,
3658
- {
3659
- title: item.title,
3660
- detail: [kindLabel(item.kind, copy), owner].filter(Boolean).join(" \xB7 "),
3661
- isDefault: item.isDefault,
3662
- defaultBadge: copy.defaultBadge
3663
- }
3664
- );
3665
- return /* @__PURE__ */ jsxs(
3666
- "div",
3667
- {
3668
- className: cn(
3669
- compact ? "rounded-lg border p-1.5" : "space-y-3 rounded-xl border p-4",
3670
- selectionRing(selectable),
3671
- disabled && "opacity-50"
3672
- ),
3673
- children: [
3674
- selectable && onSelect ? /* @__PURE__ */ jsxs(
3675
- "label",
3676
- {
3677
- className: cn(
3678
- compact ? "flex min-h-11 flex-col gap-1.5" : "block space-y-3",
3679
- disabled ? "pointer-events-none" : "cursor-pointer"
3680
- ),
3681
- children: [
3682
- /* @__PURE__ */ jsx(
3683
- "input",
3684
- {
3685
- type: "radio",
3686
- name,
3687
- value: item.id,
3688
- checked,
3689
- disabled,
3690
- onChange: onSelect,
3691
- className: "sr-only"
3692
- }
3693
- ),
3694
- media,
3695
- meta
3696
- ]
3697
- }
3698
- ) : /* @__PURE__ */ jsxs("div", { className: compact ? "space-y-1.5" : "space-y-3", children: [
3699
- media,
3700
- meta
3701
- ] }),
3702
- compact ? null : /* @__PURE__ */ jsx(
3703
- ManageActions,
3704
- {
3705
- disabled,
3706
- actionsPending,
3707
- copy,
3708
- onMakeDefault,
3709
- onEdit,
3710
- onDelete
3711
- }
3712
- )
3713
- ]
3714
- }
3715
- );
3716
- }
3717
- function formatCountdown(ms) {
3718
- if (ms <= 0) return "0:00";
3719
- const total = Math.floor(ms / 1e3);
3720
- const h = Math.floor(total / 3600);
3721
- const m = Math.floor(total % 3600 / 60);
3722
- const s = total % 60;
3723
- const mm = String(m).padStart(2, "0");
3724
- const ss = String(s).padStart(2, "0");
3725
- return h > 0 ? `${h}:${mm}:${ss}` : `${m}:${ss}`;
3726
- }
3727
- function WaitingRoom({
3728
- title,
3729
- organizationName,
3730
- organizationImage,
3731
- startsAt,
3732
- durationSeconds,
3733
- curtain,
3734
- hideBranding = false,
3735
- hideStatus = false,
3736
- nowMs,
3737
- labels,
3738
- className
3739
- }) {
3740
- const [now, setNow] = React11.useState(nowMs ?? Date.now());
3741
- React11.useEffect(() => {
3742
- if (nowMs != null) {
3743
- setNow(nowMs);
3744
- return;
3745
- }
3746
- const timer = window.setInterval(() => setNow(Date.now()), 1e3);
3747
- return () => window.clearInterval(timer);
3748
- }, [nowMs]);
3749
- const remaining = startsAt != null ? startsAt - now : null;
3750
- const durationMinutes = durationSeconds != null ? Math.max(1, Math.round(durationSeconds / 60)) : null;
3751
- return /* @__PURE__ */ jsxs(
3752
- "div",
3753
- {
3754
- className: cn(
3755
- "relative flex min-h-[16rem] w-full overflow-hidden rounded-lg bg-zinc-950 text-white",
3756
- className
3757
- ),
3758
- children: [
3759
- curtain ? /* @__PURE__ */ jsx(
3760
- CurtainStage,
3761
- {
3762
- kind: curtain.kind,
3763
- url: curtain.url,
3764
- config: curtain.config,
3765
- envBasePath: curtain.envBasePath,
3766
- allowSound: true,
3767
- className: "absolute inset-0"
3768
- }
3769
- ) : /* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-gradient-to-br from-zinc-900 to-zinc-950" }),
3770
- /* @__PURE__ */ jsxs("p", { className: "sr-only", role: "status", children: [
3771
- title,
3772
- remaining != null ? remaining > 0 ? ` ${labels?.startsIn ?? "Starts in"} ${formatCountdown(remaining)}` : ` ${labels?.started ?? "Starting soon"}` : ""
3773
- ] }),
3774
- hideBranding && hideStatus ? null : /* @__PURE__ */ jsxs("div", { className: "relative z-10 flex w-full flex-col justify-end gap-3 bg-gradient-to-t from-black/70 via-black/30 to-transparent p-6", children: [
3775
- hideBranding ? null : /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
3776
- organizationImage ? /* @__PURE__ */ jsx(
3777
- "img",
3778
- {
3779
- src: organizationImage,
3780
- alt: "",
3781
- className: "size-10 rounded-lg object-cover"
3782
- }
3783
- ) : /* @__PURE__ */ jsx("div", { className: "flex size-10 items-center justify-center rounded-lg bg-primary/15 text-sm font-semibold", children: (organizationName ?? title).slice(0, 1).toUpperCase() }),
3784
- /* @__PURE__ */ jsxs("div", { children: [
3785
- /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold tracking-tight", children: title }),
3786
- organizationName ? /* @__PURE__ */ jsx("p", { className: "text-sm text-white/80", children: organizationName }) : null
3787
- ] })
3788
- ] }),
3789
- hideStatus ? null : remaining != null ? /* @__PURE__ */ jsx("p", { className: "text-sm tabular-nums", children: remaining > 0 ? `${labels?.startsIn ?? "Starts in"} ${formatCountdown(remaining)}` : labels?.started ?? "Starting soon" }) : null,
3790
- hideStatus ? null : durationMinutes != null ? /* @__PURE__ */ jsx("p", { className: "text-xs text-white/70", children: labels?.duration ? labels.duration(durationMinutes) : `${durationMinutes} min` }) : null
3791
- ] })
3792
- ]
3793
- }
3794
- );
3795
- }
3796
-
3797
- // src/components/video/captureShaderPoster.ts
3798
- function canvasFromRoot(root) {
3799
- return root.querySelector("canvas");
3800
- }
3801
- function captureShaderPoster(root, options = {}) {
3802
- const canvas = canvasFromRoot(root);
3803
- if (!canvas) return Promise.resolve(null);
3804
- const type = options.type ?? "image/jpeg";
3805
- const quality = options.quality ?? 0.92;
3806
- return new Promise((resolve) => {
3807
- canvas.toBlob(
3808
- (blob) => resolve(blob),
3809
- type,
3810
- type === "image/jpeg" ? quality : void 0
3811
- );
3812
- });
3813
- }
3814
- var DEFAULT_SHADER_CURTAIN_EDITOR_LABELS = {
3815
- shape: "Shape",
3816
- colors: "Colors",
3817
- light: "Light & effects",
3818
- camera: "Camera",
3819
- presets: "Presets",
3820
- importUrl: "Paste a shadergradient.co URL",
3821
- importApply: "Apply URL",
3822
- importError: "Could not read that URL"
3823
- };
3824
- function NumberField({
3825
- label,
3826
- value,
3827
- min,
3828
- max,
3829
- step,
3830
- onChange
3831
- }) {
3832
- const rangeId = React11.useId();
3833
- return /* @__PURE__ */ jsxs("div", { className: "grid min-w-0 gap-1 text-xs", children: [
3834
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
3835
- /* @__PURE__ */ jsx(
3836
- "label",
3837
- {
3838
- htmlFor: rangeId,
3839
- className: "text-muted-foreground min-w-0 truncate",
3840
- children: label
3841
- }
3842
- ),
3843
- /* @__PURE__ */ jsx(
3844
- "input",
3845
- {
3846
- type: "number",
3847
- min,
3848
- max,
3849
- step,
3850
- value,
3851
- "aria-label": label,
3852
- onChange: (event) => onChange(Number(event.target.value)),
3853
- className: "border-input bg-background w-14 shrink-0 rounded-md border px-1.5 py-0.5 text-right tabular-nums"
3854
- }
3855
- )
3856
- ] }),
3857
- /* @__PURE__ */ jsx(
3858
- "input",
3859
- {
3860
- id: rangeId,
3861
- type: "range",
3862
- min,
3863
- max,
3864
- step,
3865
- value,
3866
- onChange: (event) => onChange(Number(event.target.value)),
3867
- className: "w-full min-w-0"
3868
- }
3869
- )
3870
- ] });
3871
- }
3872
- function SelectField({
3873
- label,
3874
- value,
3875
- options,
3876
- onChange
3877
- }) {
3878
- return /* @__PURE__ */ jsxs("label", { className: "grid min-w-0 gap-1 text-xs", children: [
3879
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground truncate", children: label }),
3880
- /* @__PURE__ */ jsx(
3881
- "select",
3882
- {
3883
- value,
3884
- onChange: (event) => onChange(event.target.value),
3885
- className: "border-input bg-background min-w-0 w-full rounded-md border px-2 py-1",
3886
- children: options.map((option) => /* @__PURE__ */ jsx("option", { value: option, children: option }, option))
3887
- }
3888
- )
3889
- ] });
3890
- }
3891
- function ColorField({
3892
- label,
3893
- value,
3894
- onChange
3895
- }) {
3896
- return /* @__PURE__ */ jsxs("label", { className: "grid gap-1 text-xs", children: [
3897
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: label }),
3898
- /* @__PURE__ */ jsx(
3899
- "input",
3900
- {
3901
- type: "color",
3902
- value,
3903
- onChange: (event) => onChange(event.target.value),
3904
- className: "h-9 w-full cursor-pointer rounded-md border"
3905
- }
3906
- )
3907
- ] });
3908
- }
3909
- var ShaderCurtainEditor = React11.forwardRef(function ShaderCurtainEditor2({ value, onChange, envBasePath, className, labels }, ref) {
3910
- const copy = { ...DEFAULT_SHADER_CURTAIN_EDITOR_LABELS, ...labels };
3911
- const [config, setConfig] = React11.useState(
3912
- () => mergeShaderCurtainConfig(value)
3913
- );
3914
- const [tab, setTab] = React11.useState("shape");
3915
- const [url, setUrl] = React11.useState("");
3916
- const [urlError, setUrlError] = React11.useState(null);
3917
- const previewRef = React11.useRef(null);
3918
- const update = React11.useCallback(
3919
- (patch) => {
3920
- setConfig((current) => {
3921
- const next = { ...current, ...patch };
3922
- onChange?.(next);
3923
- return next;
3924
- });
3925
- },
3926
- [onChange]
3927
- );
3928
- const replace = React11.useCallback(
3929
- (next) => {
3930
- setConfig(next);
3931
- onChange?.(next);
3932
- },
3933
- [onChange]
3934
- );
3935
- React11.useImperativeHandle(ref, () => ({
3936
- getConfig: () => config,
3937
- capturePoster: async () => {
3938
- if (!previewRef.current) return null;
3939
- return captureShaderPoster(previewRef.current);
3940
- }
3941
- }));
3942
- const applyUrl = () => {
3943
- const parsed = parseShaderGradientUrl(url);
3944
- if (!parsed) {
3945
- setUrlError(copy.importError);
3946
- return;
3947
- }
3948
- setUrlError(null);
3949
- replace(parsed);
3950
- };
3951
- return /* @__PURE__ */ jsxs(
3952
- "div",
3953
- {
3954
- className: cn(
3955
- "grid min-h-0 gap-4 md:grid-cols-2 md:items-start",
3956
- className
3957
- ),
3958
- children: [
3959
- /* @__PURE__ */ jsx(
3960
- "div",
3961
- {
3962
- ref: previewRef,
3963
- className: "relative aspect-video overflow-hidden rounded-lg bg-zinc-950 md:sticky md:top-0",
3964
- children: /* @__PURE__ */ jsx(
3965
- ShaderCurtain,
3966
- {
3967
- config,
3968
- envBasePath,
3969
- preserveDrawingBuffer: true,
3970
- className: "absolute inset-0"
3971
- }
3972
- )
3973
- }
3974
- ),
3975
- /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-col gap-3", children: [
3976
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: [
3977
- ["shape", copy.shape],
3978
- ["colors", copy.colors],
3979
- ["light", copy.light],
3980
- ["camera", copy.camera]
3981
- ].map(([id, label]) => /* @__PURE__ */ jsx(
3982
- Button,
3983
- {
3984
- type: "button",
3985
- size: "sm",
3986
- variant: tab === id ? "default" : "secondary",
3987
- onClick: () => setTab(id),
3988
- children: label
3989
- },
3990
- id
3991
- )) }),
3992
- /* @__PURE__ */ jsxs("div", { className: "min-h-0 max-h-[min(22rem,40dvh)] overflow-x-hidden overflow-y-auto pr-1", children: [
3993
- tab === "shape" ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
3994
- /* @__PURE__ */ jsx(
3995
- SelectField,
3996
- {
3997
- label: "Type",
3998
- value: config.type,
3999
- options: SHADER_CURTAIN_TYPES,
4000
- onChange: (type) => update({ type })
4001
- }
4002
- ),
4003
- /* @__PURE__ */ jsx(
4004
- SelectField,
4005
- {
4006
- label: "Shader",
4007
- value: config.shader,
4008
- options: SHADER_VARIANTS,
4009
- onChange: (shader) => update({ shader })
4010
- }
4011
- ),
4012
- /* @__PURE__ */ jsx(
4013
- SelectField,
4014
- {
4015
- label: "Animate",
4016
- value: config.animate,
4017
- options: ["on", "off"],
4018
- onChange: (animate) => update({ animate })
4019
- }
4020
- ),
4021
- /* @__PURE__ */ jsx(
4022
- SelectField,
4023
- {
4024
- label: "Loop",
4025
- value: config.loop,
4026
- options: ["on", "off"],
4027
- onChange: (loop) => update({ loop })
4028
- }
4029
- ),
4030
- /* @__PURE__ */ jsx(
4031
- NumberField,
4032
- {
4033
- label: "Speed",
4034
- value: config.uSpeed,
4035
- min: 0,
4036
- max: 4,
4037
- step: 0.05,
4038
- onChange: (uSpeed) => update({ uSpeed })
4039
- }
4040
- ),
4041
- /* @__PURE__ */ jsx(
4042
- NumberField,
4043
- {
4044
- label: "Strength",
4045
- value: config.uStrength,
4046
- min: 0,
4047
- max: 10,
4048
- step: 0.1,
4049
- onChange: (uStrength) => update({ uStrength })
4050
- }
4051
- ),
4052
- /* @__PURE__ */ jsx(
4053
- NumberField,
4054
- {
4055
- label: "Density",
4056
- value: config.uDensity,
4057
- min: 0,
4058
- max: 8,
4059
- step: 0.1,
4060
- onChange: (uDensity) => update({ uDensity })
4061
- }
4062
- ),
4063
- /* @__PURE__ */ jsx(
4064
- NumberField,
4065
- {
4066
- label: "Frequency",
4067
- value: config.uFrequency,
4068
- min: 0,
4069
- max: 12,
4070
- step: 0.1,
4071
- onChange: (uFrequency) => update({ uFrequency })
4072
- }
4073
- ),
4074
- /* @__PURE__ */ jsx(
4075
- NumberField,
4076
- {
4077
- label: "Amplitude",
4078
- value: config.uAmplitude,
4079
- min: 0,
4080
- max: 8,
4081
- step: 0.1,
4082
- onChange: (uAmplitude) => update({ uAmplitude })
4083
- }
4084
- ),
4085
- /* @__PURE__ */ jsx(
4086
- NumberField,
4087
- {
4088
- label: "Time",
4089
- value: config.uTime,
4090
- min: 0,
4091
- max: 40,
4092
- step: 0.1,
4093
- onChange: (uTime) => update({ uTime })
4094
- }
4095
- ),
4096
- /* @__PURE__ */ jsx(
4097
- NumberField,
4098
- {
4099
- label: "Loop duration",
4100
- value: config.loopDuration,
4101
- min: 1,
4102
- max: 60,
4103
- step: 1,
4104
- onChange: (loopDuration) => update({ loopDuration })
4105
- }
4106
- ),
4107
- /* @__PURE__ */ jsx(
4108
- SelectField,
4109
- {
4110
- label: "Range",
4111
- value: config.range,
4112
- options: ["enabled", "disabled"],
4113
- onChange: (range) => update({ range })
4114
- }
4115
- ),
4116
- /* @__PURE__ */ jsx(
4117
- NumberField,
4118
- {
4119
- label: "Range start",
4120
- value: config.rangeStart,
4121
- min: 0,
4122
- max: 40,
4123
- step: 0.1,
4124
- onChange: (rangeStart) => update({ rangeStart })
4125
- }
4126
- ),
4127
- /* @__PURE__ */ jsx(
4128
- NumberField,
4129
- {
4130
- label: "Range end",
4131
- value: config.rangeEnd,
4132
- min: 0,
4133
- max: 40,
4134
- step: 0.1,
4135
- onChange: (rangeEnd) => update({ rangeEnd })
4136
- }
4137
- ),
4138
- /* @__PURE__ */ jsxs("label", { className: "col-span-2 flex items-center gap-2 text-xs", children: [
4139
- /* @__PURE__ */ jsx(
4140
- "input",
4141
- {
4142
- type: "checkbox",
4143
- checked: config.wireframe,
4144
- onChange: (event) => update({ wireframe: event.target.checked })
4145
- }
4146
- ),
4147
- "Wireframe"
4148
- ] })
4149
- ] }) : null,
4150
- tab === "colors" ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
4151
- /* @__PURE__ */ jsx(
4152
- ColorField,
4153
- {
4154
- label: "Color 1",
4155
- value: config.color1,
4156
- onChange: (color1) => update({ color1 })
4157
- }
4158
- ),
4159
- /* @__PURE__ */ jsx(
4160
- ColorField,
4161
- {
4162
- label: "Color 2",
4163
- value: config.color2,
4164
- onChange: (color2) => update({ color2 })
4165
- }
4166
- ),
4167
- /* @__PURE__ */ jsx(
4168
- ColorField,
4169
- {
4170
- label: "Color 3",
4171
- value: config.color3,
4172
- onChange: (color3) => update({ color3 })
4173
- }
4174
- ),
4175
- /* @__PURE__ */ jsx(
4176
- NumberField,
4177
- {
4178
- label: "Reflection",
4179
- value: config.reflection,
4180
- min: 0,
4181
- max: 1,
4182
- step: 0.05,
4183
- onChange: (reflection) => update({ reflection })
4184
- }
4185
- ),
4186
- /* @__PURE__ */ jsx(
4187
- NumberField,
4188
- {
4189
- label: "Brightness",
4190
- value: config.brightness,
4191
- min: 0,
4192
- max: 4,
4193
- step: 0.05,
4194
- onChange: (brightness) => update({ brightness })
4195
- }
4196
- )
4197
- ] }) : null,
4198
- tab === "light" ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
4199
- /* @__PURE__ */ jsx(
4200
- SelectField,
4201
- {
4202
- label: "Light",
4203
- value: config.lightType,
4204
- options: SHADER_LIGHT_TYPES,
4205
- onChange: (lightType) => update({ lightType })
4206
- }
4207
- ),
4208
- /* @__PURE__ */ jsx(
4209
- SelectField,
4210
- {
4211
- label: "Environment",
4212
- value: config.envPreset,
4213
- options: SHADER_ENV_PRESETS,
4214
- onChange: (envPreset) => update({ envPreset })
4215
- }
4216
- ),
4217
- /* @__PURE__ */ jsx(
4218
- SelectField,
4219
- {
4220
- label: "Grain",
4221
- value: config.grain,
4222
- options: ["on", "off"],
4223
- onChange: (grain) => update({ grain })
4224
- }
4225
- ),
4226
- /* @__PURE__ */ jsx(
4227
- NumberField,
4228
- {
4229
- label: "Grain blending",
4230
- value: config.grainBlending,
4231
- min: 0,
4232
- max: 1,
4233
- step: 0.05,
4234
- onChange: (grainBlending) => update({ grainBlending })
4235
- }
4236
- )
4237
- ] }) : null,
4238
- tab === "camera" ? /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
4239
- /* @__PURE__ */ jsx(
4240
- NumberField,
4241
- {
4242
- label: "Azimuth",
4243
- value: config.cAzimuthAngle,
4244
- min: 0,
4245
- max: 360,
4246
- step: 1,
4247
- onChange: (cAzimuthAngle) => update({ cAzimuthAngle })
4248
- }
4249
- ),
4250
- /* @__PURE__ */ jsx(
4251
- NumberField,
4252
- {
4253
- label: "Polar",
4254
- value: config.cPolarAngle,
4255
- min: 0,
4256
- max: 180,
4257
- step: 1,
4258
- onChange: (cPolarAngle) => update({ cPolarAngle })
4259
- }
4260
- ),
4261
- /* @__PURE__ */ jsx(
4262
- NumberField,
4263
- {
4264
- label: "Distance",
4265
- value: config.cDistance,
4266
- min: 0.1,
4267
- max: 40,
4268
- step: 0.1,
4269
- onChange: (cDistance) => update({ cDistance })
4270
- }
4271
- ),
4272
- /* @__PURE__ */ jsx(
4273
- NumberField,
4274
- {
4275
- label: "Zoom",
4276
- value: config.cameraZoom,
4277
- min: 0.1,
4278
- max: 50,
4279
- step: 0.1,
4280
- onChange: (cameraZoom) => update({ cameraZoom })
4281
- }
4282
- ),
4283
- /* @__PURE__ */ jsx(
4284
- NumberField,
4285
- {
4286
- label: "FOV",
4287
- value: config.fov,
4288
- min: 10,
4289
- max: 120,
4290
- step: 1,
4291
- onChange: (fov) => update({ fov })
4292
- }
4293
- ),
4294
- /* @__PURE__ */ jsx(
4295
- NumberField,
4296
- {
4297
- label: "Pixel density",
4298
- value: config.pixelDensity,
4299
- min: 0.5,
4300
- max: 2,
4301
- step: 0.1,
4302
- onChange: (pixelDensity) => update({ pixelDensity })
4303
- }
4304
- ),
4305
- /* @__PURE__ */ jsx(
4306
- NumberField,
4307
- {
4308
- label: "Position X",
4309
- value: config.positionX,
4310
- min: -20,
4311
- max: 20,
4312
- step: 0.1,
4313
- onChange: (positionX) => update({ positionX })
4314
- }
4315
- ),
4316
- /* @__PURE__ */ jsx(
4317
- NumberField,
4318
- {
4319
- label: "Position Y",
4320
- value: config.positionY,
4321
- min: -20,
4322
- max: 20,
4323
- step: 0.1,
4324
- onChange: (positionY) => update({ positionY })
4325
- }
4326
- ),
4327
- /* @__PURE__ */ jsx(
4328
- NumberField,
4329
- {
4330
- label: "Position Z",
4331
- value: config.positionZ,
4332
- min: -20,
4333
- max: 20,
4334
- step: 0.1,
4335
- onChange: (positionZ) => update({ positionZ })
4336
- }
4337
- ),
4338
- /* @__PURE__ */ jsx(
4339
- NumberField,
4340
- {
4341
- label: "Rotation X",
4342
- value: config.rotationX,
4343
- min: -360,
4344
- max: 360,
4345
- step: 1,
4346
- onChange: (rotationX) => update({ rotationX })
4347
- }
4348
- ),
4349
- /* @__PURE__ */ jsx(
4350
- NumberField,
4351
- {
4352
- label: "Rotation Y",
4353
- value: config.rotationY,
4354
- min: -360,
4355
- max: 360,
4356
- step: 1,
4357
- onChange: (rotationY) => update({ rotationY })
4358
- }
4359
- ),
4360
- /* @__PURE__ */ jsx(
4361
- NumberField,
4362
- {
4363
- label: "Rotation Z",
4364
- value: config.rotationZ,
4365
- min: -360,
4366
- max: 360,
4367
- step: 1,
4368
- onChange: (rotationZ) => update({ rotationZ })
4369
- }
4370
- ),
4371
- /* @__PURE__ */ jsxs("label", { className: "col-span-2 flex items-center gap-2 text-xs", children: [
4372
- /* @__PURE__ */ jsx(
4373
- "input",
4374
- {
4375
- type: "checkbox",
4376
- checked: config.zoomOut,
4377
- onChange: (event) => update({ zoomOut: event.target.checked })
4378
- }
4379
- ),
4380
- "Zoom out"
4381
- ] })
4382
- ] }) : null
4383
- ] }),
4384
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
4385
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: copy.presets }),
4386
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: SHADER_CURTAIN_PRESETS.map((preset) => /* @__PURE__ */ jsx(
4387
- Button,
4388
- {
4389
- type: "button",
4390
- size: "sm",
4391
- variant: "secondary",
4392
- onClick: () => replace(preset.config),
4393
- children: preset.title
4394
- },
4395
- preset.id
4396
- )) })
4397
- ] }),
4398
- /* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
4399
- /* @__PURE__ */ jsxs("label", { className: "grid gap-1 text-xs", children: [
4400
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: copy.importUrl }),
4401
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
4402
- /* @__PURE__ */ jsx(
4403
- "input",
4404
- {
4405
- value: url,
4406
- onChange: (event) => setUrl(event.target.value),
4407
- className: "border-input bg-background min-w-0 flex-1 rounded-md border px-2 py-1"
4408
- }
4409
- ),
4410
- /* @__PURE__ */ jsx(
4411
- Button,
4412
- {
4413
- type: "button",
4414
- size: "sm",
4415
- variant: "secondary",
4416
- onClick: applyUrl,
4417
- children: copy.importApply
4418
- }
4419
- )
4420
- ] })
4421
- ] }),
4422
- urlError ? /* @__PURE__ */ jsx("p", { className: "text-destructive text-xs", role: "alert", children: urlError }) : null
4423
- ] })
4424
- ] })
4425
- ]
4426
- }
4427
- );
4428
- });
4429
-
4430
- // src/components/video/castHls.ts
4431
- var CAST_SENDER_SRC = "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";
4432
- var DEFAULT_RECEIVER_ID = "CC1AD845";
4433
- var loadPromise = null;
4434
- function loadCastSender() {
4435
- if (typeof window === "undefined") return Promise.resolve();
4436
- if (window.cast?.framework && window.chrome?.cast) return Promise.resolve();
4437
- if (loadPromise) return loadPromise;
4438
- loadPromise = new Promise((resolve, reject) => {
4439
- window.__onGCastApiAvailable = (available) => {
4440
- if (available) resolve();
4441
- else reject(new Error("Cast API unavailable"));
4442
- };
4443
- const existing = document.querySelector(`script[src="${CAST_SENDER_SRC}"]`);
4444
- if (existing) return;
4445
- const script = document.createElement("script");
4446
- script.src = CAST_SENDER_SRC;
4447
- script.async = true;
4448
- script.onerror = () => reject(new Error("Cast sender failed to load"));
4449
- document.head.appendChild(script);
4450
- });
4451
- return loadPromise;
4452
- }
4453
- async function castHlsUrl(hlsUrl) {
4454
- await loadCastSender();
4455
- const framework = window.cast?.framework;
4456
- const chromeCast = window.chrome?.cast;
4457
- if (!framework || !chromeCast) {
4458
- throw new Error("Cast API unavailable");
4459
- }
4460
- const context = framework.CastContext.getInstance();
4461
- context.setOptions({
4462
- receiverApplicationId: chromeCast.media.DEFAULT_MEDIA_RECEIVER_APP_ID || DEFAULT_RECEIVER_ID,
4463
- autoJoinPolicy: chromeCast.AutoJoinPolicy?.ORIGIN_SCOPED
4464
- });
4465
- if (!context.getCurrentSession()) {
4466
- await context.requestSession();
4467
- }
4468
- const session = context.getCurrentSession();
4469
- if (!session) throw new Error("No Cast session");
4470
- const media = new chromeCast.media.MediaInfo(hlsUrl, "application/x-mpegURL");
4471
- const request = new chromeCast.media.LoadRequest(media);
4472
- await session.loadMedia(request);
4473
- }
4474
-
4475
- // src/components/video/seekPreview.ts
4476
- var XYWH_RE = /#xywh=(\d+),(\d+),(\d+),(\d+)\s*$/;
4477
- function thumbnailsVttUrlFromPlayback(src) {
4478
- const trimmed = src.trim();
4479
- if (!trimmed) return null;
4480
- const replaced = trimmed.replace(
4481
- /index\.m3u8(?:\?.*)?$/i,
4482
- "thumbs/preview.vtt"
4483
- );
4484
- if (replaced === trimmed) return null;
4485
- return replaced;
4486
- }
4487
- function parseVttTimestamp(value) {
4488
- const parts = value.trim().split(":");
4489
- if (parts.length === 3) {
4490
- const hours = Number(parts[0]);
4491
- const minutes = Number(parts[1]);
4492
- const seconds2 = Number(parts[2]);
4493
- if ([hours, minutes, seconds2].some((n) => Number.isNaN(n))) return 0;
4494
- return hours * 3600 + minutes * 60 + seconds2;
4495
- }
4496
- if (parts.length === 2) {
4497
- const minutes = Number(parts[0]);
4498
- const seconds2 = Number(parts[1]);
4499
- if ([minutes, seconds2].some((n) => Number.isNaN(n))) return 0;
4500
- return minutes * 60 + seconds2;
4501
- }
4502
- const seconds = Number(value);
4503
- return Number.isFinite(seconds) ? seconds : 0;
4504
- }
4505
- function parseThumbnailsVtt(text, vttUrl) {
4506
- const cues = [];
4507
- const blocks = text.replace(/^\uFEFF?WEBVTT[^\n]*\n/i, "").split(/\n\s*\n/);
4508
- for (const block of blocks) {
4509
- const lines = block.split("\n").map((line) => line.trim()).filter(Boolean);
4510
- const timing = lines.find((line) => line.includes("-->"));
4511
- const payload = lines.find((line) => XYWH_RE.test(line));
4512
- if (!timing || !payload) continue;
4513
- const [startRaw, endRaw] = timing.split("-->").map((part) => part.trim());
4514
- const match = payload.match(XYWH_RE);
4515
- if (!startRaw || !endRaw || !match) continue;
4516
- const spriteName = payload.slice(0, match.index);
4517
- cues.push({
4518
- start: parseVttTimestamp(startRaw),
4519
- end: parseVttTimestamp(endRaw),
4520
- spriteUrl: new URL(spriteName, vttUrl).toString(),
4521
- x: Number(match[1]),
4522
- y: Number(match[2]),
4523
- width: Number(match[3]),
4524
- height: Number(match[4])
4525
- });
4526
- }
4527
- return cues;
4528
- }
4529
- function cueAtTime(cues, time) {
4530
- if (cues.length === 0 || !Number.isFinite(time)) return null;
4531
- const hit = cues.find((cue) => time >= cue.start && time < cue.end);
4532
- if (hit) return hit;
4533
- const last = cues[cues.length - 1];
4534
- if (last && time >= last.start) return last;
4535
- return cues[0] ?? null;
4536
- }
4537
- function hoverTimeFromClientX(clientX, rect, duration) {
4538
- if (rect.width <= 0 || !Number.isFinite(duration) || duration <= 0) return 0;
4539
- const ratio = Math.min(1, Math.max(0, (clientX - rect.left) / rect.width));
4540
- return ratio * duration;
4541
- }
4542
- function finitePlaybackDuration(duration, seekable, mode) {
4543
- if (Number.isFinite(duration) && duration > 0) return duration;
4544
- if (mode === "vod" && seekable.length > 0) {
4545
- const span = seekable.end(seekable.length - 1) - seekable.start(0);
4546
- if (Number.isFinite(span) && span > 0) return span;
4547
- }
4548
- return 0;
4549
- }
4550
- async function loadThumbnailsVtt(src) {
4551
- const vttUrl = thumbnailsVttUrlFromPlayback(src);
4552
- if (!vttUrl) return [];
4553
- try {
4554
- const response = await fetch(vttUrl);
4555
- if (!response.ok) return [];
4556
- const text = await response.text();
4557
- return parseThumbnailsVtt(text, vttUrl);
4558
- } catch {
4559
- return [];
4560
- }
4561
- }
4562
- function SeekBar({
4563
- src,
4564
- duration,
4565
- currentTime,
4566
- buffered,
4567
- onSeek,
4568
- formatTime: formatTime2
4569
- }) {
4570
- const trackRef = React11.useRef(null);
4571
- const [hoverTime, setHoverTime] = React11.useState(null);
4572
- const [cues, setCues] = React11.useState(null);
4573
- const loadedSrc = React11.useRef(null);
4574
- React11.useEffect(() => {
4575
- setCues(null);
4576
- loadedSrc.current = null;
4577
- }, [src]);
4578
- const ensureCues = React11.useCallback(() => {
4579
- if (loadedSrc.current === src) return;
4580
- loadedSrc.current = src;
4581
- void loadThumbnailsVtt(src).then((next) => {
4582
- setCues(next);
4583
- });
4584
- }, [src]);
4585
- const updateHover = React11.useCallback(
4586
- (clientX) => {
4587
- const rect = trackRef.current?.getBoundingClientRect();
4588
- if (!rect) return;
4589
- setHoverTime(hoverTimeFromClientX(clientX, rect, duration));
4590
- },
4591
- [duration]
4592
- );
4593
- const cue = hoverTime !== null && Number.isFinite(duration) && duration > 0 && cues && cues.length > 0 ? cueAtTime(cues, hoverTime) : null;
4594
- const hoverPercent = hoverTime !== null && duration > 0 ? Math.min(100, Math.max(0, hoverTime / duration * 100)) : 0;
4595
- return /* @__PURE__ */ jsxs(
4596
- "div",
4597
- {
4598
- ref: trackRef,
4599
- className: "relative w-full",
4600
- onPointerEnter: ensureCues,
4601
- onPointerDown: (event) => {
4602
- ensureCues();
4603
- updateHover(event.clientX);
4604
- },
4605
- onPointerMove: (event) => {
4606
- ensureCues();
4607
- updateHover(event.clientX);
4608
- },
4609
- onPointerLeave: () => setHoverTime(null),
4610
- onPointerUp: () => setHoverTime(null),
4611
- children: [
4612
- hoverTime !== null ? /* @__PURE__ */ jsxs(
4613
- "div",
4614
- {
4615
- className: "pointer-events-none absolute bottom-full mb-2 flex flex-col items-center gap-1",
4616
- style: { left: `${hoverPercent}%`, transform: "translateX(-50%)" },
4617
- "data-slot": "seek-preview",
4618
- children: [
4619
- cue ? /* @__PURE__ */ jsx(
4620
- "div",
4621
- {
4622
- "aria-hidden": "true",
4623
- className: "overflow-hidden rounded border border-white/20 bg-black shadow-md",
4624
- style: {
4625
- width: cue.width,
4626
- height: cue.height,
4627
- backgroundImage: `url(${cue.spriteUrl})`,
4628
- backgroundPosition: `-${cue.x}px -${cue.y}px`,
4629
- backgroundRepeat: "no-repeat"
4630
- }
4631
- }
4632
- ) : null,
4633
- /* @__PURE__ */ jsx("span", { className: "rounded-full bg-black/80 px-1.5 py-0.5 text-[10px] tabular-nums text-white", children: formatTime2(hoverTime) })
4634
- ]
4635
- }
4636
- ) : null,
4637
- /* @__PURE__ */ jsx(
4638
- Slider,
4639
- {
4640
- "aria-label": "Seek",
4641
- min: 0,
4642
- max: duration || 0,
4643
- step: 0.1,
4644
- value: [Math.min(currentTime, duration || 0)],
4645
- onValueChange: (value) => onSeek(value[0] ?? 0),
4646
- className: "w-full"
4647
- }
4648
- ),
4649
- duration > 0 && buffered > currentTime ? /* @__PURE__ */ jsx(
4650
- "span",
4651
- {
4652
- "aria-hidden": "true",
4653
- className: "pointer-events-none absolute top-1/2 left-0 h-1.5 -translate-y-1/2 rounded-full bg-white/25",
4654
- style: {
4655
- width: `${Math.min(buffered / duration * 100, 100)}%`
4656
- }
4657
- }
4658
- ) : null
4659
- ]
4660
- }
4661
- );
4662
- }
4663
-
4664
- // src/components/video/captions.ts
4665
- var CAPTION_LOCALES = ["en", "es", "pt"];
4666
- var LIVE_CUE_EXTRA_LAG_MS = 2e3;
4667
- var LIVE_STACK_MAX_CUES = 150;
4668
- var CAPTION_CHARS_PER_SECOND = 17;
4669
- var CAPTION_MIN_DWELL_MS = 1200;
4670
- var CAPTION_MAX_DWELL_MS = 6e3;
4671
- var CAPTION_RUSH_DWELL_MS = 2500;
4672
- var CAPTION_MAX_CHARS_PER_LINE = 42;
4673
- var CAPTION_COMPACT_CHARS_PER_LINE = 32;
4674
- var CAPTION_MAX_LINES = 2;
4675
- var CAPTION_BACKLOG_DROP = 8;
4676
- var CAPTION_GAP_FILL_MS = 1e3;
4677
- var LIVE_LAG_SPIKE_MS = 2500;
4678
- var CAPTION_BREAK_PUNCT = /[.,;:?!]$/;
4679
- var CAPTION_MIN_PUNCT_LINE = 8;
4680
- var EMPTY_LIVE_CAPTION_PLAYOUT = {
4681
- screen: null,
4682
- hideAt: 0,
4683
- cursor: 0,
4684
- queue: []
4685
- };
4686
- function stabilizeLiveLagMs(previous, next) {
4687
- if (previous == null || !Number.isFinite(previous)) return next;
4688
- if (next <= previous) return next;
4689
- if (next - previous < LIVE_LAG_SPIKE_MS) return previous;
4690
- return next;
4691
- }
4692
- function isCaptionLocale(value) {
4693
- return CAPTION_LOCALES.includes(value);
4694
- }
4695
- function isLivePlaylistSrc(src) {
4696
- return /\/live\//i.test(src);
4697
- }
4698
- function captionsVttUrlFromPlayback(src, locale) {
4699
- const trimmed = src.trim();
4700
- if (!trimmed) return null;
4701
- const replaced = trimmed.replace(
4702
- /index\.m3u8(?:\?.*)?$/i,
4703
- `subs/${locale}.vtt`
4704
- );
4705
- if (replaced === trimmed) return null;
4706
- return replaced;
4707
- }
4708
- function liveCaptionsUrl(base, locale) {
4709
- return `${base.replace(/\/$/, "")}/${locale}`;
4710
- }
4711
- function parseCaptionVtt(text) {
4712
- const cues = [];
4713
- const blocks = text.replace(/^\uFEFF?WEBVTT[^\n]*\n/i, "").split(/\n\s*\n/);
4714
- for (const block of blocks) {
4715
- const lines = block.split("\n").map((line) => line.trim()).filter(Boolean);
4716
- const timing = lines.find((line) => line.includes("-->"));
4717
- if (!timing) continue;
4718
- const [startRaw, endRaw] = timing.split("-->").map((part) => part.trim());
4719
- if (!startRaw || !endRaw) continue;
4720
- const textLines = lines.filter(
4721
- (line) => line !== timing && !/^\d+$/.test(line)
4722
- );
4723
- const payload = textLines.join("\n").trim();
4724
- if (!payload) continue;
4725
- cues.push({
4726
- start: parseVttTimestamp(startRaw.split(" ")[0] ?? startRaw),
4727
- end: parseVttTimestamp(endRaw.split(" ")[0] ?? endRaw),
4728
- text: payload
4729
- });
4730
- }
4731
- return cues;
4732
- }
4733
- function captionScreenRow(text, speaker) {
4734
- return speaker == null ? { text } : { text, speaker };
4735
- }
4736
- function chunkLongWord(word, maxCharsPerLine) {
4737
- if (word.length <= maxCharsPerLine) return [word];
4738
- const parts = [];
4739
- for (let index = 0; index < word.length; index += maxCharsPerLine) {
4740
- parts.push(word.slice(index, index + maxCharsPerLine));
4741
- }
4742
- return parts;
4743
- }
4744
- function wrapCaptionLines(text, maxCharsPerLine) {
4745
- const tokens = text.split(" ").filter(Boolean).flatMap((word) => chunkLongWord(word, maxCharsPerLine));
4746
- const lines = [];
4747
- let index = 0;
4748
- while (index < tokens.length) {
4749
- let end = index;
4750
- let length = 0;
4751
- while (end < tokens.length) {
4752
- const added = tokens[end].length + (end > index ? 1 : 0);
4753
- if (length + added > maxCharsPerLine && end > index) break;
4754
- length += added;
4755
- end += 1;
4756
- }
4757
- let breakAt = end;
4758
- if (end < tokens.length) {
4759
- for (let cursor = end - 1; cursor > index; cursor -= 1) {
4760
- if (!CAPTION_BREAK_PUNCT.test(tokens[cursor])) continue;
4761
- const firstLen = tokens.slice(index, cursor + 1).join(" ").length;
4762
- if (firstLen >= Math.min(CAPTION_MIN_PUNCT_LINE, maxCharsPerLine)) {
4763
- breakAt = cursor + 1;
4764
- }
4765
- break;
4766
- }
4767
- }
4768
- lines.push(tokens.slice(index, breakAt).join(" "));
4769
- index = breakAt;
4770
- }
4771
- return lines;
4772
- }
4773
- function balanceCaptionLines(lines, maxCharsPerLine) {
4774
- const next = [...lines];
4775
- for (let index = 0; index + 1 < next.length; index += CAPTION_MAX_LINES) {
4776
- const left = next[index].split(" ");
4777
- const right = next[index + 1].split(" ");
4778
- if (right.length !== 1 || left.length < 3) continue;
4779
- const moved = left[left.length - 1];
4780
- const newRight = `${moved} ${right[0]}`;
4781
- if (newRight.length > maxCharsPerLine) continue;
4782
- next[index] = left.slice(0, -1).join(" ");
4783
- next[index + 1] = newRight;
4784
- }
4785
- return next;
4786
- }
4787
- function splitCaptionScreens(text, maxCharsPerLine = CAPTION_MAX_CHARS_PER_LINE) {
4788
- const trimmed = text.trim().replace(/\s+/g, " ");
4789
- if (!trimmed) return [];
4790
- const lines = balanceCaptionLines(
4791
- wrapCaptionLines(trimmed, maxCharsPerLine),
4792
- maxCharsPerLine
4793
- );
4794
- const screens = [];
4795
- for (let index = 0; index < lines.length; index += CAPTION_MAX_LINES) {
4796
- screens.push(lines.slice(index, index + CAPTION_MAX_LINES).join("\n"));
4797
- }
4798
- return screens;
4799
- }
4800
- function captionDwellMs(text, backlog = 0) {
4801
- const chars = text.replace(/\s+/g, " ").trim().length;
4802
- const raw = chars / CAPTION_CHARS_PER_SECOND * 1e3;
4803
- const max = backlog > 0 ? CAPTION_RUSH_DWELL_MS : CAPTION_MAX_DWELL_MS;
4804
- return Math.min(max, Math.max(CAPTION_MIN_DWELL_MS, raw));
4805
- }
4806
- function advanceLiveCaptionPlayout(state, cues, now, lagMs, maxCharsPerLine = CAPTION_MAX_CHARS_PER_LINE) {
4807
- let screen = state.screen;
4808
- let hideAt = state.hideAt;
4809
- let cursor = state.cursor;
4810
- let queue = state.queue.slice();
4811
- if (lagMs != null && Number.isFinite(lagMs) && lagMs >= 0) {
4812
- const threshold = lagMs + LIVE_CUE_EXTRA_LAG_MS;
4813
- const incoming = cues.filter(
4814
- (cue) => Boolean(cue.text.trim()) && Number.isFinite(cue.receivedAt) && cue.receivedAt > cursor && now - cue.receivedAt >= threshold
4815
- ).sort((left, right) => left.receivedAt - right.receivedAt);
4816
- for (const cue of incoming) {
4817
- for (const text of splitCaptionScreens(cue.text, maxCharsPerLine)) {
4818
- queue.push(captionScreenRow(text, cue.speaker));
4819
- }
4820
- cursor = cue.receivedAt;
4821
- }
4822
- if (queue.length > CAPTION_BACKLOG_DROP) {
4823
- queue = queue.slice(queue.length - CAPTION_BACKLOG_DROP);
4824
- }
4825
- }
4826
- if (now >= hideAt) {
4827
- const next = queue.shift();
4828
- if (next) {
4829
- screen = next;
4830
- hideAt = now + captionDwellMs(next.text, queue.length);
4831
- } else {
4832
- screen = null;
4833
- }
4834
- }
4835
- return { screen, hideAt, cursor, queue };
4836
- }
4837
- function cueEndWithGapFill(cues, index) {
4838
- const cue = cues[index];
4839
- if (!cue) return 0;
4840
- const next = cues[index + 1];
4841
- if (!next || !Number.isFinite(next.start)) return cue.end;
4842
- const gapMs = (next.start - cue.end) * 1e3;
4843
- if (gapMs > 0 && gapMs < CAPTION_GAP_FILL_MS) return next.start;
4844
- return cue.end;
4845
- }
4846
- function captionScreenAtTime(cues, time, maxCharsPerLine = CAPTION_MAX_CHARS_PER_LINE) {
4847
- if (!Number.isFinite(time)) return null;
4848
- const ordered = cues.filter(
4849
- (cue) => Boolean(cue.text.trim()) && Number.isFinite(cue.start) && Number.isFinite(cue.end)
4850
- ).sort((left, right) => left.start - right.start);
4851
- for (let index = 0; index < ordered.length; index += 1) {
4852
- const cue = ordered[index];
4853
- const end = cueEndWithGapFill(ordered, index);
4854
- if (time < cue.start || time >= end) continue;
4855
- const screens = splitCaptionScreens(cue.text, maxCharsPerLine);
4856
- if (screens.length === 0) return null;
4857
- const weights = screens.map(
4858
- (text) => Math.max(1, text.replace(/\s+/g, "").length)
4859
- );
4860
- const total = weights.reduce((sum, weight) => sum + weight, 0);
4861
- const duration = Math.max(end - cue.start, 0);
4862
- let cursor = cue.start;
4863
- for (let screenIndex = 0; screenIndex < screens.length; screenIndex += 1) {
4864
- const isLast = screenIndex === screens.length - 1;
4865
- const slice = isLast ? end - cursor : duration * (weights[screenIndex] / total);
4866
- const sliceEnd = cursor + slice;
4867
- if (time >= cursor && time < sliceEnd) {
4868
- return captionScreenRow(screens[screenIndex]);
4869
- }
4870
- cursor = sliceEnd;
4871
- }
4872
- return captionScreenRow(screens[screens.length - 1]);
4873
- }
4874
- return null;
4875
- }
4876
- var LIVE_OVERLAP_MIN_WORDS = 4;
4877
- function normalizeLiveCaptionText(text) {
4878
- return text.trim().replace(/\s+/g, " ").toLowerCase();
4879
- }
4880
- function lastSubseqIndex(haystack, needle) {
4881
- if (needle.length === 0 || needle.length > haystack.length) return -1;
4882
- let found = -1;
4883
- for (let index = 0; index <= haystack.length - needle.length; index += 1) {
4884
- let match = true;
4885
- for (let offset = 0; offset < needle.length; offset += 1) {
4886
- if (haystack[index + offset] !== needle[offset]) {
4887
- match = false;
4888
- break;
4889
- }
4890
- }
4891
- if (match) found = index;
4892
- }
4893
- return found;
4894
- }
4895
- function remainderAfterOverlap(previous, next) {
4896
- const prevWords = normalizeLiveCaptionText(previous).split(" ").filter(Boolean);
4897
- const nextWords = next.trim().replace(/\s+/g, " ").split(" ").filter(Boolean);
4898
- const nextNorm = nextWords.map((word) => word.toLowerCase());
4899
- const maxN = Math.min(prevWords.length, nextNorm.length);
4900
- for (let size = maxN; size >= LIVE_OVERLAP_MIN_WORDS; size -= 1) {
4901
- for (let start = prevWords.length - size; start >= 0; start -= 1) {
4902
- const gram = prevWords.slice(start, start + size);
4903
- const index = lastSubseqIndex(nextNorm, gram);
4904
- if (index !== -1) {
4905
- return nextWords.slice(index + size).join(" ");
4906
- }
4907
- }
4908
- }
4909
- return null;
4910
- }
4911
- function liveCaptionRow(text, receivedAt, speaker) {
4912
- return speaker == null ? { text, receivedAt } : { text, receivedAt, speaker };
4913
- }
4914
- function coalesceLiveCaptionCues(cues) {
4915
- const out = [];
4916
- for (const cue of cues) {
4917
- const text = cue.text.trim();
4918
- if (!text) continue;
4919
- const last = out[out.length - 1];
4920
- if (!last) {
4921
- out.push(liveCaptionRow(text, cue.receivedAt, cue.speaker));
4922
- continue;
4923
- }
4924
- if (last.speaker !== cue.speaker && (last.speaker != null || cue.speaker != null)) {
4925
- out.push(liveCaptionRow(text, cue.receivedAt, cue.speaker));
4926
- continue;
4927
- }
4928
- const lastNorm = normalizeLiveCaptionText(last.text);
4929
- const nextNorm = normalizeLiveCaptionText(text);
4930
- if (lastNorm === nextNorm) continue;
4931
- if (nextNorm.startsWith(lastNorm) || lastNorm.startsWith(nextNorm)) {
4932
- out[out.length - 1] = liveCaptionRow(
4933
- nextNorm.length >= lastNorm.length ? text : last.text,
4934
- cue.receivedAt,
4935
- cue.speaker ?? last.speaker
4936
- );
4937
- continue;
4938
- }
4939
- const remainder = remainderAfterOverlap(last.text, text);
4940
- if (remainder !== null) {
4941
- if (!remainder) continue;
4942
- out.push(liveCaptionRow(remainder, cue.receivedAt, cue.speaker));
4943
- continue;
4944
- }
4945
- out.push(liveCaptionRow(text, cue.receivedAt, cue.speaker));
4946
- }
4947
- return out;
4948
- }
4949
- function mergeLiveCaptionCues(existing, incoming, cap = LIVE_STACK_MAX_CUES) {
4950
- const map = /* @__PURE__ */ new Map();
4951
- for (const cue of existing) {
4952
- if (Number.isFinite(cue.receivedAt)) map.set(cue.receivedAt, cue);
4953
- }
4954
- for (const cue of incoming) {
4955
- if (Number.isFinite(cue.receivedAt)) map.set(cue.receivedAt, cue);
4956
- }
4957
- return [...map.values()].sort((left, right) => left.receivedAt - right.receivedAt).slice(-Math.max(1, cap));
4958
- }
4959
- async function loadCaptionVtt(url) {
4960
- try {
4961
- const response = await fetch(url, { cache: "no-store" });
4962
- if (!response.ok) return [];
4963
- return parseCaptionVtt(await response.text());
4964
- } catch {
4965
- return [];
4966
- }
4967
- }
4968
- async function loadLiveCaptions(url) {
4969
- try {
4970
- const response = await fetch(url, {
4971
- cache: "no-store",
4972
- headers: { Accept: "application/json" }
4973
- });
4974
- if (!response.ok) return { ok: false, cues: [] };
4975
- const body = await response.json();
4976
- if (!body || typeof body !== "object" || !("cues" in body)) {
4977
- return { ok: false, cues: [] };
4978
- }
4979
- const rows = body.cues;
4980
- if (!Array.isArray(rows)) return { ok: false, cues: [] };
4981
- const cues = [];
4982
- for (const row of rows) {
4983
- if (!row || typeof row !== "object") continue;
4984
- const record = row;
4985
- if (typeof record.text !== "string" || !record.text.trim()) continue;
4986
- if (typeof record.receivedAt !== "number" || !Number.isFinite(record.receivedAt)) {
4987
- continue;
4988
- }
4989
- const parsed = {
4990
- text: record.text.trim(),
4991
- receivedAt: record.receivedAt
4992
- };
4993
- if (typeof record.speaker === "number" && Number.isFinite(record.speaker)) {
4994
- parsed.speaker = record.speaker;
4995
- }
4996
- cues.push(parsed);
4997
- }
4998
- return { ok: true, cues };
4999
- } catch {
5000
- return { ok: false, cues: [] };
5001
- }
5002
- }
5003
-
5004
- // src/components/video/hls-config.ts
5005
- function shouldRetryLiveEdge404(retryConfig, retryCount, _isTimeout, loaderResponse, defaultRetry) {
5006
- if (loaderResponse?.code === 404) {
5007
- return retryConfig != null && retryCount < retryConfig.maxNumRetry;
5008
- }
5009
- return defaultRetry;
5010
- }
5011
- var liveEdgeErrorRetry = {
5012
- maxNumRetry: 8,
5013
- retryDelayMs: 250,
5014
- maxRetryDelayMs: 4e3,
5015
- backoff: "exponential",
5016
- shouldRetry: shouldRetryLiveEdge404
5017
- };
5018
- function createLiveHlsConfig() {
5019
- return {
5020
- enableWorker: true,
5021
- // No custom request headers: Cache-Control/Pragma are not
5022
- // CORS-safelisted and would force an OPTIONS preflight before every
5023
- // manifest poll and segment fetch. Freshness is controlled by the
5024
- // origin's response Cache-Control headers instead.
5025
- liveSyncDurationCount: 4,
5026
- liveMaxLatencyDurationCount: 12,
5027
- fragLoadPolicy: {
5028
- default: {
5029
- maxTimeToFirstByteMs: 1e4,
5030
- maxLoadTimeMs: 12e4,
5031
- timeoutRetry: {
5032
- maxNumRetry: 4,
5033
- retryDelayMs: 0,
5034
- maxRetryDelayMs: 0
5035
- },
5036
- errorRetry: liveEdgeErrorRetry
5037
- }
5038
- },
5039
- playlistLoadPolicy: {
5040
- default: {
5041
- maxTimeToFirstByteMs: 1e4,
5042
- maxLoadTimeMs: 3e4,
5043
- timeoutRetry: {
5044
- maxNumRetry: 2,
5045
- retryDelayMs: 0,
5046
- maxRetryDelayMs: 0
5047
- },
5048
- errorRetry: {
5049
- ...liveEdgeErrorRetry,
5050
- maxNumRetry: 6
5051
- }
5052
- }
5053
- }
5054
- };
5055
- }
5056
- function createVodHlsConfig() {
5057
- return {
5058
- enableWorker: true,
5059
- startPosition: 0
5060
- };
5061
- }
5062
-
5063
- // src/components/video/hls-errors.ts
5064
- var MEDIA_ERROR_NAMES = {
5065
- 1: "MEDIA_ERR_ABORTED",
5066
- 2: "MEDIA_ERR_NETWORK",
5067
- 3: "MEDIA_ERR_DECODE",
5068
- 4: "MEDIA_ERR_SRC_NOT_SUPPORTED"
5069
- };
5070
- var MEDIA_ERR_NETWORK = 2;
5071
- var MEDIA_ERR_DECODE = 3;
5072
- var MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
5073
- function errorMessageFromUnknown(error) {
5074
- if (error instanceof Error) return error.message;
5075
- if (typeof error === "string") return error;
5076
- return void 0;
5077
- }
5078
- function isNotFound(httpStatus, details) {
5079
- return httpStatus === 404 || details === "manifestLoadError" || details === "levelLoadError" || details === "fragLoadError";
5080
- }
5081
- function kindForHls(input) {
5082
- const httpStatus = input.response?.code;
5083
- if (input.type === "networkError" && isNotFound(httpStatus, input.details)) {
5084
- return input.context.mode === "vod" || !input.context.manifestParsed ? "unavailable" : "network";
5085
- }
5086
- if (input.type === "mediaError" || input.details === "bufferAppendError" || input.details === "bufferSeekOverHole") {
5087
- return "media";
5088
- }
5089
- return "generic";
5090
- }
5091
- function kindForNative(input) {
5092
- const code = input.mediaError?.code;
5093
- if (code === MEDIA_ERR_DECODE) return "media";
5094
- if (code === MEDIA_ERR_SRC_NOT_SUPPORTED) return "unsupported";
5095
- if (code === MEDIA_ERR_NETWORK) return "unavailable";
5096
- return "generic";
5097
- }
5098
- function describeAvResync(input) {
5099
- const lag = Number.isFinite(input.lagSeconds) ? input.lagSeconds : 0;
5100
- return {
5101
- summary: `av-resync lag=${lag.toFixed(3)}s (non-fatal)`,
5102
- kind: "resync",
5103
- detail: {
5104
- source: input.context.source,
5105
- kind: "resync",
5106
- fatal: false,
5107
- reason: `presented frame lag ${lag.toFixed(3)}s`,
5108
- context: input.context
5109
- }
5110
- };
5111
- }
5112
- function describePlaybackError(input) {
5113
- if (input.source === "unsupported") {
5114
- return {
5115
- summary: "playback unsupported (hls.js unavailable, native HLS unsupported)",
5116
- kind: "unsupported",
5117
- detail: {
5118
- source: "unsupported",
5119
- kind: "unsupported",
5120
- context: input.context
5121
- }
5122
- };
5123
- }
5124
- if (input.source === "native") {
5125
- const code = input.mediaError?.code;
5126
- const kind2 = kindForNative(input);
5127
- const detail2 = {
5128
- source: "native",
5129
- kind: kind2,
5130
- mediaErrorCode: code,
5131
- mediaErrorName: code !== void 0 ? MEDIA_ERROR_NAMES[code] : void 0,
5132
- errorMessage: input.mediaError?.message,
5133
- context: input.context
5134
- };
5135
- const name = detail2.mediaErrorName ?? "MEDIA_ERR_UNKNOWN";
5136
- return {
5137
- summary: `native ${name}${input.mediaError?.message ? `: ${input.mediaError.message}` : ""}`,
5138
- kind: kind2,
5139
- detail: detail2
5140
- };
5141
- }
5142
- const httpStatus = input.response?.code;
5143
- const kind = kindForHls(input);
5144
- const detail = {
5145
- source: "hls",
5146
- kind,
5147
- type: input.type,
5148
- details: input.details,
5149
- fatal: input.fatal,
5150
- httpStatus,
5151
- url: input.url,
5152
- reason: input.reason,
5153
- errorMessage: errorMessageFromUnknown(input.error),
5154
- context: input.context
5155
- };
5156
- const statusSuffix = httpStatus !== void 0 ? ` ${httpStatus}` : "";
5157
- const summary = [
5158
- "hls",
5159
- input.type ?? "unknown",
5160
- input.details ?? "unknown",
5161
- input.fatal ? "(fatal)" : "(non-fatal)",
5162
- statusSuffix.trim()
5163
- ].filter(Boolean).join(" ");
5164
- return { summary, kind, detail };
5165
- }
5166
-
5167
- // src/components/video/useHlsPlayback.ts
5168
- function effectivePlaybackMode(src, mode, sealed) {
5169
- if (isLivePlaylistSrc(src)) return sealed ? "vod" : "live";
5170
- return mode;
5171
- }
5172
- var RETRY_INTERVAL_MS = 3e3;
5173
- var MAX_MEDIA_ERROR_RETRIES = 5;
5174
- var DRIFT_THRESHOLD_S = 0.4;
5175
- var DRIFT_CONSECUTIVE_SAMPLES = 3;
5176
- var RESYNC_COOLDOWN_MS = 1e4;
5177
- var LIVE_EDGE_RESYNC_THRESHOLD_S = 8;
5178
- function useHlsPlayback({
5179
- src,
5180
- mode,
5181
- active,
5182
- autoPlay = false,
5183
- muted = false,
5184
- onError,
5185
- onPlayingChange,
5186
- onRebuffer,
5187
- onQualityChange
5188
- }) {
5189
- const videoRef = React11.useRef(null);
5190
- const hlsRef = React11.useRef(null);
5191
- const [state, setState] = React11.useState("idle");
5192
- const [qualities, setQualities] = React11.useState([]);
5193
- const [activeLevel, setActiveLevel] = React11.useState(-1);
5194
- const [autoplayState, setAutoplayState] = React11.useState("none");
5195
- const [error, setError] = React11.useState(null);
5196
- const [reloadKey, setReloadKey] = React11.useState(0);
5197
- const [sealed, setSealed] = React11.useState(false);
5198
- const modeRef = React11.useRef(mode);
5199
- const lastSrcRef = React11.useRef(src);
5200
- const sealedRef = React11.useRef(false);
5201
- const sawLiveRef = React11.useRef(false);
5202
- const sealedDuringSessionRef = React11.useRef(false);
5203
- React11.useEffect(() => {
5204
- modeRef.current = mode;
5205
- }, [mode]);
5206
- const onErrorRef = React11.useRef(onError);
5207
- const onPlayingChangeRef = React11.useRef(onPlayingChange);
5208
- const onRebufferRef = React11.useRef(onRebuffer);
5209
- const onQualityChangeRef = React11.useRef(onQualityChange);
5210
- React11.useEffect(() => {
5211
- onErrorRef.current = onError;
5212
- onPlayingChangeRef.current = onPlayingChange;
5213
- onRebufferRef.current = onRebuffer;
5214
- onQualityChangeRef.current = onQualityChange;
5215
- }, [onError, onPlayingChange, onRebuffer, onQualityChange]);
5216
- const retry = React11.useCallback(() => {
5217
- setError(null);
5218
- setState("loading");
5219
- setAutoplayState("none");
5220
- setReloadKey((k) => k + 1);
5221
- }, []);
5222
- React11.useEffect(() => {
5223
- const media = videoRef.current;
5224
- if (!media || !src || !active) {
5225
- setState("idle");
5226
- return;
5227
- }
5228
- let cancelled = false;
5229
- let retryTimer = null;
5230
- let manifestParsed = false;
5231
- let mediaErrorRetries = 0;
5232
- let playbackSource = "hls";
5233
- const teardown = [];
5234
- const liveSrc = isLivePlaylistSrc(src);
5235
- if (lastSrcRef.current !== src) {
5236
- lastSrcRef.current = src;
5237
- sealedRef.current = false;
5238
- sawLiveRef.current = false;
5239
- sealedDuringSessionRef.current = false;
5240
- setSealed(false);
5241
- }
5242
- applyMute(media);
5243
- setState("loading");
5244
- setError(null);
5245
- setAutoplayState("none");
5246
- setQualities([]);
5247
- setActiveLevel(-1);
5248
- function baseContext() {
5249
- return {
5250
- mode: modeRef.current,
5251
- src,
5252
- manifestParsed,
5253
- retryCount: mediaErrorRetries,
5254
- source: playbackSource
5255
- };
5256
- }
5257
- function shouldAutoplay() {
5258
- if (sealedDuringSessionRef.current) return false;
5259
- return modeRef.current === "live" || autoPlay;
5260
- }
5261
- function hlsConfig() {
5262
- if (liveSrc) {
5263
- return sealedRef.current ? createVodHlsConfig() : createLiveHlsConfig();
5264
- }
5265
- return modeRef.current === "live" ? createLiveHlsConfig() : createVodHlsConfig();
5266
- }
5267
- function clearRetryTimer() {
5268
- if (retryTimer !== null) {
5269
- clearTimeout(retryTimer);
5270
- retryTimer = null;
5271
- }
5272
- }
5273
- function destroyHls() {
5274
- hlsRef.current?.destroy();
5275
- hlsRef.current = null;
5276
- }
5277
- function reportFatal(input) {
5278
- const described = describePlaybackError(input);
5279
- onErrorRef.current?.(described);
5280
- setError(described);
5281
- setState("error");
5282
- }
5283
- function applyMute(el) {
5284
- el.muted = muted;
5285
- }
5286
- function preserveMute(el, fn) {
5287
- const wasMuted = el.muted;
5288
- fn();
5289
- el.muted = wasMuted;
5290
- }
5291
- function attemptAutoplay(el) {
5292
- applyMute(el);
5293
- void el.play().then(
5294
- () => {
5295
- applyMute(el);
5296
- setAutoplayState("playing");
5297
- },
5298
- () => {
5299
- el.muted = true;
5300
- void el.play().then(
5301
- () => setAutoplayState(muted ? "playing" : "muted"),
5302
- () => {
5303
- if (el.paused) {
5304
- setAutoplayState("blocked");
5305
- return;
5306
- }
5307
- setAutoplayState(el.muted && !muted ? "muted" : "playing");
5308
- }
5309
- );
5310
- }
5311
- );
5312
- }
5313
- function scheduleRetry(retryFn) {
5314
- clearRetryTimer();
5315
- if (cancelled) return;
5316
- setState("waiting");
5317
- retryTimer = setTimeout(() => {
5318
- retryTimer = null;
5319
- if (!cancelled) retryFn();
5320
- }, RETRY_INTERVAL_MS);
5321
- }
5322
- function startDriftWatchdog(el) {
5323
- if (typeof el.requestVideoFrameCallback !== "function") return;
5324
- let consecutiveLagSamples = 0;
5325
- let lastResyncAt = 0;
5326
- let handle = null;
5327
- const tick = (_now, metadata) => {
5328
- if (cancelled) return;
5329
- handle = el.requestVideoFrameCallback(tick);
5330
- if (el.paused || el.ended) {
5331
- consecutiveLagSamples = 0;
5332
- return;
5333
- }
5334
- const lag = el.currentTime - metadata.mediaTime;
5335
- if (!(lag > DRIFT_THRESHOLD_S)) {
5336
- consecutiveLagSamples = 0;
5337
- return;
5338
- }
5339
- consecutiveLagSamples += 1;
5340
- if (consecutiveLagSamples < DRIFT_CONSECUTIVE_SAMPLES) return;
5341
- const nowMs = performance.now();
5342
- if (nowMs - lastResyncAt < RESYNC_COOLDOWN_MS) return;
5343
- lastResyncAt = nowMs;
5344
- consecutiveLagSamples = 0;
5345
- if (modeRef.current === "live" && el.seekable.length > 0) {
5346
- const edge = el.seekable.end(el.seekable.length - 1);
5347
- if (edge - el.currentTime > LIVE_EDGE_RESYNC_THRESHOLD_S) {
5348
- el.currentTime = edge;
5349
- } else {
5350
- el.currentTime = el.currentTime + 1e-3;
5351
- }
5352
- } else {
5353
- el.currentTime = el.currentTime + 1e-3;
5354
- }
5355
- onErrorRef.current?.(
5356
- describeAvResync({
5357
- lagSeconds: lag,
5358
- context: baseContext()
5359
- })
5360
- );
5361
- };
5362
- handle = el.requestVideoFrameCallback(tick);
5363
- teardown.push(() => {
5364
- if (handle != null && typeof el.cancelVideoFrameCallback === "function") {
5365
- el.cancelVideoFrameCallback(handle);
5366
- }
5367
- });
5368
- }
5369
- let hasPlayed = false;
5370
- let waitingSince = null;
5371
- function onPlaying() {
5372
- manifestParsed = true;
5373
- mediaErrorRetries = 0;
5374
- clearRetryTimer();
5375
- setState("ready");
5376
- setAutoplayState(
5377
- (prev) => prev === "blocked" || prev === "none" ? "playing" : prev
5378
- );
5379
- if (waitingSince != null) {
5380
- const seconds = (performance.now() - waitingSince) / 1e3;
5381
- waitingSince = null;
5382
- if (seconds > 0) onRebufferRef.current?.(seconds);
5383
- }
5384
- hasPlayed = true;
5385
- onPlayingChangeRef.current?.(true);
5386
- }
5387
- function onPaused() {
5388
- onPlayingChangeRef.current?.(false);
5389
- }
5390
- function onWaiting() {
5391
- if (!hasPlayed || waitingSince != null) return;
5392
- waitingSince = performance.now();
5393
- }
5394
- media.addEventListener("playing", onPlaying);
5395
- media.addEventListener("pause", onPaused);
5396
- media.addEventListener("ended", onPaused);
5397
- media.addEventListener("waiting", onWaiting);
5398
- teardown.push(() => {
5399
- media.removeEventListener("playing", onPlaying);
5400
- media.removeEventListener("pause", onPaused);
5401
- media.removeEventListener("ended", onPaused);
5402
- media.removeEventListener("waiting", onWaiting);
5403
- });
5404
- startDriftWatchdog(media);
5405
- function initNative() {
5406
- playbackSource = "native";
5407
- manifestParsed = false;
5408
- media.removeAttribute("src");
5409
- media.load();
5410
- media.src = src;
5411
- applyMute(media);
5412
- const onReady = () => {
5413
- manifestParsed = true;
5414
- clearRetryTimer();
5415
- setState("ready");
5416
- if (shouldAutoplay()) attemptAutoplay(media);
5417
- };
5418
- const onErr = () => {
5419
- if (manifestParsed) {
5420
- reportFatal({
5421
- source: "native",
5422
- mediaError: media.error,
5423
- context: baseContext()
5424
- });
5425
- return;
5426
- }
5427
- onErrorRef.current?.(
5428
- describePlaybackError({
5429
- source: "native",
5430
- mediaError: media.error,
5431
- context: baseContext()
5432
- })
5433
- );
5434
- scheduleRetry(() => {
5435
- media.src = src;
5436
- media.load();
5437
- });
5438
- };
5439
- media.addEventListener("loadedmetadata", onReady);
5440
- media.addEventListener("error", onErr);
5441
- teardown.push(() => {
5442
- media.removeEventListener("loadedmetadata", onReady);
5443
- media.removeEventListener("error", onErr);
5444
- });
5445
- }
5446
- function initHlsJs(Hls) {
5447
- playbackSource = "hls";
5448
- destroyHls();
5449
- manifestParsed = false;
5450
- const config = hlsConfig();
5451
- const hls = new Hls(config);
5452
- hlsRef.current = hls;
5453
- hls.loadSource(src);
5454
- hls.attachMedia(media);
5455
- applyMute(media);
5456
- hls.on(Hls.Events.LEVEL_LOADED, (_e, data) => {
5457
- if (!liveSrc || cancelled) return;
5458
- const details = data.details;
5459
- if (!details) return;
5460
- if (details.live) {
5461
- sawLiveRef.current = true;
5462
- return;
5463
- }
5464
- if (sealedRef.current) return;
5465
- sealedRef.current = true;
5466
- setSealed(true);
5467
- if (sawLiveRef.current) {
5468
- sealedDuringSessionRef.current = true;
5469
- }
5470
- setReloadKey((k) => k + 1);
5471
- });
5472
- hls.on(Hls.Events.MANIFEST_PARSED, (_e, data) => {
5473
- manifestParsed = true;
5474
- clearRetryTimer();
5475
- setQualities(
5476
- data.levels.map((l, index) => ({ index, height: l.height }))
5477
- );
5478
- setState("ready");
5479
- if (shouldAutoplay()) attemptAutoplay(media);
5480
- });
5481
- hls.on(Hls.Events.LEVEL_SWITCHED, (_e, data) => {
5482
- if (hls.autoLevelEnabled) setActiveLevel(-1);
5483
- else setActiveLevel(data.level);
5484
- const height = hls.levels?.[data.level]?.height;
5485
- onQualityChangeRef.current?.(
5486
- typeof height === "number" && height > 0 ? `${height}p` : "auto"
5487
- );
5488
- });
5489
- hls.on(Hls.Events.ERROR, (_e, data) => {
5490
- onErrorRef.current?.(
5491
- describePlaybackError({
5492
- source: "hls",
5493
- type: data.type,
5494
- details: data.details,
5495
- fatal: data.fatal,
5496
- url: data.url,
5497
- response: data.response,
5498
- reason: data.reason,
5499
- error: data.error,
5500
- context: baseContext()
5501
- })
5502
- );
5503
- if (!data.fatal) return;
5504
- if (data.type === Hls.ErrorTypes.NETWORK_ERROR) {
5505
- if (!manifestParsed) {
5506
- scheduleRetry(() => initHlsJs(Hls));
5507
- return;
5508
- }
5509
- hls.startLoad();
5510
- return;
5511
- }
5512
- mediaErrorRetries += 1;
5513
- if (mediaErrorRetries === 1) {
5514
- preserveMute(media, () => hls.recoverMediaError());
5515
- return;
5516
- }
5517
- if (mediaErrorRetries === 2) {
5518
- preserveMute(media, () => {
5519
- hls.swapAudioCodec();
5520
- hls.recoverMediaError();
5521
- });
5522
- return;
5523
- }
5524
- if (mediaErrorRetries < MAX_MEDIA_ERROR_RETRIES) {
5525
- scheduleRetry(() => initHlsJs(Hls));
5526
- return;
5527
- }
5528
- reportFatal({
5529
- source: "hls",
5530
- type: data.type,
5531
- details: data.details,
5532
- fatal: true,
5533
- url: data.url,
5534
- response: data.response,
5535
- reason: data.reason,
5536
- error: data.error,
5537
- context: baseContext()
5538
- });
5539
- });
5540
- }
5541
- async function setup() {
5542
- let Hls = null;
5543
- try {
5544
- Hls = (await import(
5545
- /* turbopackOptional: true */
5546
- 'hls.js'
5547
- )).default;
5548
- } catch {
5549
- Hls = null;
5550
- }
5551
- if (cancelled) return;
5552
- if (Hls && Hls.isSupported()) {
5553
- initHlsJs(Hls);
5554
- } else if (media.canPlayType("application/vnd.apple.mpegurl")) {
5555
- initNative();
5556
- } else {
5557
- playbackSource = "unsupported";
5558
- reportFatal({
5559
- source: "unsupported",
5560
- context: baseContext()
5561
- });
5562
- }
5563
- }
5564
- void setup();
5565
- return () => {
5566
- cancelled = true;
5567
- clearRetryTimer();
5568
- for (const fn of teardown) fn();
5569
- destroyHls();
5570
- };
5571
- }, [src, active, autoPlay, muted, reloadKey]);
5572
- const setLevel = React11.useCallback((index) => {
5573
- const hls = hlsRef.current;
5574
- if (!hls) return;
5575
- hls.nextLevel = index;
5576
- setActiveLevel(index);
5577
- }, []);
5578
- return {
5579
- videoRef,
5580
- state,
5581
- qualities,
5582
- activeLevel,
5583
- setLevel,
5584
- autoplayState,
5585
- error,
5586
- retry,
5587
- effectiveMode: effectivePlaybackMode(src, mode, sealed)
5588
- };
5589
- }
5590
-
5591
- // src/components/video/fullscreen.ts
5592
- function asWebkitVideo(video) {
5593
- return video;
5594
- }
5595
- function hasWebkitVideoFullscreen(video) {
5596
- return typeof asWebkitVideo(video)?.webkitEnterFullscreen === "function";
5597
- }
5598
- function hasStandardFullscreen() {
5599
- if (typeof document === "undefined") return false;
5600
- if (document.fullscreenEnabled) return true;
5601
- const doc = document;
5602
- return !!doc.webkitFullscreenEnabled;
5603
- }
5604
- function isEmbeddedWindow(win = window) {
5605
- try {
5606
- return win.self !== win.top;
5607
- } catch {
5608
- return true;
5609
- }
5610
- }
5611
- function CaptionOverlay({ screen }) {
5612
- const lastSpeakerRef = React11.useRef(void 0);
5613
- const lastSpeaker = lastSpeakerRef.current;
5614
- React11.useLayoutEffect(() => {
5615
- if (screen?.speaker != null) lastSpeakerRef.current = screen.speaker;
5616
- }, [screen]);
5617
- if (!screen) return null;
5618
- const turnDash = screen.speaker != null && lastSpeaker != null && screen.speaker !== lastSpeaker;
5619
- const text = turnDash ? `\u2013 ${screen.text}` : screen.text;
5620
- return /* @__PURE__ */ jsx(
5621
- "div",
5622
- {
5623
- className: "pointer-events-none absolute inset-x-0 bottom-16 z-[1] flex justify-center px-4",
5624
- "data-slot": "video-captions",
5625
- children: /* @__PURE__ */ jsx(
5626
- "p",
5627
- {
5628
- role: "status",
5629
- "aria-live": "polite",
5630
- className: "line-clamp-2 max-w-[90%] whitespace-pre-line break-words rounded-sm bg-black/70 px-3 py-1.5 text-center text-[length:clamp(10px,2.6cqh,0.875rem)] font-medium text-white shadow-sm [-webkit-text-size-adjust:100%] [text-size-adjust:100%]",
5631
- children: text
5632
- }
5633
- )
5634
- }
5635
- );
5636
- }
5637
-
5638
- // src/components/video/nativeCaptionTrack.ts
5639
- var NATIVE_CAPTION_HOLD_S = 4;
5640
- var NATIVE_SUBTITLE_KIND = "subtitles";
5641
- function clearNativeCaptionCues(track) {
5642
- const cues = track.cues;
5643
- if (!cues) return;
5644
- for (let index = cues.length - 1; index >= 0; index -= 1) {
5645
- const cue = cues[index];
5646
- if (cue) track.removeCue(cue);
5647
- }
5648
- }
5649
- function subtitleTracksForLocales(video) {
5650
- return Array.from(video.textTracks).filter(
5651
- (track) => track.kind === NATIVE_SUBTITLE_KIND && isCaptionLocale(track.language)
5652
- );
5653
- }
5654
- function findSubtitleTrack(video, locale) {
5655
- return subtitleTracksForLocales(video).find(
5656
- (track) => track.language === locale
5657
- ) ?? null;
5658
- }
5659
- function showingCaptionLocale(video) {
5660
- for (const track of subtitleTracksForLocales(video)) {
5661
- if (track.mode === "showing" && isCaptionLocale(track.language)) {
5662
- return track.language;
5663
- }
5664
- }
5665
- return "off";
5666
- }
5667
- function applyCaptionTrackModes(video, locale, nativeVisible) {
5668
- for (const track of subtitleTracksForLocales(video)) {
5669
- if (locale !== "off" && track.language === locale) {
5670
- track.mode = nativeVisible ? "showing" : "hidden";
5671
- } else {
5672
- track.mode = "disabled";
5673
- }
5674
- }
5675
- }
5676
- function ensureLiveSubtitleTracks(video, labels) {
5677
- const existing = subtitleTracksForLocales(video);
5678
- return CAPTION_LOCALES.map((locale) => {
5679
- const found = existing.find((track2) => track2.language === locale);
5680
- if (found) return found;
5681
- const track = video.addTextTrack(
5682
- NATIVE_SUBTITLE_KIND,
5683
- labels[locale],
5684
- locale
5685
- );
5686
- track.mode = "disabled";
5687
- return track;
5688
- });
5689
- }
5690
- function syncNativeCaptionCue(video, track, text, holdSeconds = NATIVE_CAPTION_HOLD_S) {
5691
- clearNativeCaptionCues(track);
5692
- const trimmed = text.trim();
5693
- if (!trimmed) return;
5694
- const start = Number.isFinite(video.currentTime) ? video.currentTime : 0;
5695
- const hold = Number.isFinite(holdSeconds) ? Math.max(0.2, holdSeconds) : NATIVE_CAPTION_HOLD_S;
5696
- track.addCue(new VTTCue(start, start + hold, trimmed));
5697
- }
5698
- function listenTextTracksChange(tracks, onChange) {
5699
- if (typeof tracks.addEventListener === "function") {
5700
- tracks.addEventListener("change", onChange);
5701
- return () => {
5702
- if (typeof tracks.removeEventListener === "function") {
5703
- tracks.removeEventListener("change", onChange);
5704
- }
5705
- };
5706
- }
5707
- tracks.onchange = onChange;
5708
- return () => {
5709
- if (tracks.onchange === onChange) tracks.onchange = null;
5710
- };
5711
- }
5712
- var DEFAULT_LABELS3 = {
5713
- play: "Play",
5714
- pause: "Pause",
5715
- mute: "Mute",
5716
- unmute: "Unmute",
5717
- enterFullscreen: "Fullscreen",
5718
- exitFullscreen: "Exit fullscreen",
5719
- pictureInPicture: "Picture in picture",
5720
- cast: "Cast",
5721
- settings: "Settings",
5722
- more: "More",
5723
- back: "Back",
5724
- quality: "Quality",
5725
- auto: "Auto",
5726
- speed: "Speed",
5727
- live: "LIVE",
5728
- goLive: "Go live",
5729
- tapToUnmute: "Tap to unmute",
5730
- loading: "Loading\u2026",
5731
- waiting: "Waiting for stream\u2026",
5732
- retry: "Retry",
5733
- errorUnavailable: "This video isn't available yet.",
5734
- errorNetwork: "We couldn't load the video. Check your connection.",
5735
- errorMedia: "There was a playback problem.",
5736
- errorUnsupported: "Your browser can't play this video.",
5737
- errorGeneric: "We couldn't play this video.",
5738
- captions: "Captions",
5739
- captionsOff: "Off",
5740
- captionsEn: "English",
5741
- captionsEs: "Espa\xF1ol",
5742
- captionsPt: "Portugu\xEAs",
5743
- captionsLatest: "Latest"
5744
- };
5745
- var PLAYBACK_RATES = [0.75, 1, 1.25, 1.5, 2];
5746
- var CONTROLS_HIDE_MS = 3e3;
5747
- var LIVE_EDGE_THRESHOLD_S = 8;
5748
- var SEEK_STEP_S = 5;
5749
- var PROGRESS_THROTTLE_MS = 5e3;
5750
- var LIVE_CAPTION_PLAYOUT_MS = 250;
5751
- var COMPACT_CHROME_PX = 640;
5752
- var VIDEO_MEDIA_STYLE = `
5753
- .livo-video-player-media::-webkit-media-controls-start-playback-button {
5754
- display: none !important;
5755
- -webkit-appearance: none;
5756
- }
5757
- .livo-video-player-media::-webkit-media-controls {
5758
- display: none !important;
5759
- }
5760
- `;
5761
- function hasCaptionSource(mode, src, liveCaptionsBaseUrl) {
5762
- if (mode === "live") {
5763
- return Boolean(liveCaptionsBaseUrl?.trim());
5764
- }
5765
- return CAPTION_LOCALES.some(
5766
- (locale) => captionsVttUrlFromPlayback(src, locale) != null
5767
- );
5768
- }
5769
- function captionLocaleLabel(locale, labels) {
5770
- switch (locale) {
5771
- case "en":
5772
- return labels.captionsEn;
5773
- case "es":
5774
- return labels.captionsEs;
5775
- case "pt":
5776
- return labels.captionsPt;
5777
- default: {
5778
- const _exhaustive = locale;
5779
- return _exhaustive;
5780
- }
5781
- }
5782
- }
5783
- function formatTime(seconds) {
5784
- if (!Number.isFinite(seconds) || seconds < 0) return "0:00";
5785
- const total = Math.floor(seconds);
5786
- const h = Math.floor(total / 3600);
5787
- const m = Math.floor(total % 3600 / 60);
5788
- const s = total % 60;
5789
- const mm = h > 0 ? String(m).padStart(2, "0") : String(m);
5790
- const ss = String(s).padStart(2, "0");
5791
- return h > 0 ? `${h}:${mm}:${ss}` : `${mm}:${ss}`;
5792
- }
5793
- function VideoPlayer({
5794
- src,
5795
- mode,
5796
- poster,
5797
- autoPlay = false,
5798
- muted = false,
5799
- stats,
5800
- labels,
5801
- showQualitySelector = true,
5802
- paused = false,
5803
- onPlayingChange,
5804
- onFirstPlay,
5805
- onError,
5806
- onPlaybackProgress,
5807
- onRebuffer,
5808
- onQualityChange,
5809
- fit = "aspect-video",
5810
- className,
5811
- defaultCaptionLocale,
5812
- captionsEnabled = true,
5813
- liveCaptionsBaseUrl
5814
- }) {
5815
- const t = { ...DEFAULT_LABELS3, ...labels };
5816
- const containerRef = React11.useRef(null);
5817
- const firstPlayFiredRef = React11.useRef(false);
5818
- const lastProgressAtRef = React11.useRef(-PROGRESS_THROTTLE_MS);
5819
- const onPlaybackProgressRef = React11.useRef(onPlaybackProgress);
5820
- onPlaybackProgressRef.current = onPlaybackProgress;
5821
- const applyingTrackModesRef = React11.useRef(false);
5822
- const captionLocaleRef = React11.useRef("off");
5823
- const cssFullscreenRef = React11.useRef(false);
5824
- const webkitFsRef = React11.useRef(false);
5825
- const [userStarted, setUserStarted] = React11.useState(false);
5826
- const active = autoPlay || !poster || userStarted;
5827
- const autoplayActive = autoPlay || userStarted;
5828
- const handlePlayingChange = React11.useCallback(
5829
- (playing) => {
5830
- setIsPlaying(playing);
5831
- if (playing && !firstPlayFiredRef.current) {
5832
- firstPlayFiredRef.current = true;
5833
- onFirstPlay?.();
5834
- }
5835
- onPlayingChange?.(playing);
5836
- },
5837
- [onFirstPlay, onPlayingChange]
5838
- );
5839
- const {
5840
- videoRef,
5841
- state,
5842
- qualities,
5843
- activeLevel,
5844
- setLevel,
5845
- autoplayState,
5846
- error,
5847
- retry,
5848
- effectiveMode
5849
- } = useHlsPlayback({
5850
- src,
5851
- mode,
5852
- active,
5853
- autoPlay: autoplayActive,
5854
- muted,
5855
- onError,
5856
- onPlayingChange: handlePlayingChange,
5857
- onRebuffer,
5858
- onQualityChange
5859
- });
5860
- const liveCaptionPollUrl = liveCaptionsBaseUrl?.trim() || void 0;
5861
- const showCaptionsMenu = captionsEnabled && hasCaptionSource(mode, src, liveCaptionPollUrl);
5862
- const activeLiveCaptionsBaseUrl = showCaptionsMenu ? liveCaptionPollUrl : void 0;
5863
- const [isPlaying, setIsPlaying] = React11.useState(false);
5864
- const [isMuted, setIsMuted] = React11.useState(muted);
5865
- const isMutedRef = React11.useRef(isMuted);
5866
- isMutedRef.current = isMuted;
5867
- const [volume, setVolume] = React11.useState(1);
5868
- const [currentTime, setCurrentTime] = React11.useState(0);
5869
- const [duration, setDuration] = React11.useState(0);
5870
- const [buffered, setBuffered] = React11.useState(0);
5871
- const [isFullscreen, setIsFullscreen] = React11.useState(false);
5872
- const [pipActive, setPipActive] = React11.useState(false);
5873
- const [controlsVisible, setControlsVisible] = React11.useState(true);
5874
- const [playbackRate, setPlaybackRate] = React11.useState(1);
5875
- const [openMenu, setOpenMenu] = React11.useState(null);
5876
- const [morePane, setMorePane] = React11.useState(
5877
- "root"
5878
- );
5879
- const [compactChrome, setCompactChrome] = React11.useState(false);
5880
- const [captionLocale, setCaptionLocale] = React11.useState(defaultCaptionLocale ?? "off");
5881
- const [captionCues, setCaptionCues] = React11.useState([]);
5882
- const [liveCaptionCues, setLiveCaptionCues] = React11.useState([]);
5883
- const [livePlayout, setLivePlayout] = React11.useState(
5884
- EMPTY_LIVE_CAPTION_PLAYOUT
5885
- );
5886
- const [liveLagMs, setLiveLagMs] = React11.useState(null);
5887
- const [behindLive, setBehindLive] = React11.useState(false);
5888
- const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React11.useState(false);
5889
- const [embedded, setEmbedded] = React11.useState(false);
5890
- const [cssFullscreen, setCssFullscreen] = React11.useState(false);
5891
- const [webkitNativeFs, setWebkitNativeFs] = React11.useState(false);
5892
- const hideTimerRef = React11.useRef(null);
5893
- const lastPointerTypeRef = React11.useRef("mouse");
5894
- const liveCaptionCuesRef = React11.useRef(liveCaptionCues);
5895
- const liveLagMsRef = React11.useRef(liveLagMs);
5896
- const compactChromeRef = React11.useRef(compactChrome);
5897
- liveCaptionCuesRef.current = liveCaptionCues;
5898
- liveLagMsRef.current = liveLagMs;
5899
- compactChromeRef.current = compactChrome;
5900
- cssFullscreenRef.current = cssFullscreen;
5901
- captionLocaleRef.current = captionLocale;
5902
- React11.useEffect(() => {
5903
- const el = containerRef.current;
5904
- if (!el || typeof ResizeObserver === "undefined") return;
5905
- const apply = (width) => {
5906
- if (width <= 0) return;
5907
- setCompactChrome(width < COMPACT_CHROME_PX);
5908
- };
5909
- apply(el.clientWidth);
5910
- const observer = new ResizeObserver((entries) => {
5911
- const width = entries[0]?.contentRect.width;
5912
- if (typeof width === "number") apply(width);
5913
- });
5914
- observer.observe(el);
5915
- return () => observer.disconnect();
5916
- }, [active]);
5917
- React11.useEffect(() => {
5918
- if (openMenu !== "more") setMorePane("root");
5919
- }, [openMenu]);
5920
- const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
5921
- const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported || !embedded;
5922
- React11.useEffect(() => {
5923
- const video = videoRef.current;
5924
- if (!video || !active) return;
5925
- const onTimeUpdate = () => {
5926
- setCurrentTime(video.currentTime);
5927
- if (video.buffered.length > 0) {
5928
- setBuffered(video.buffered.end(video.buffered.length - 1));
5929
- }
5930
- const progress = onPlaybackProgressRef.current;
5931
- if (progress) {
5932
- const now = performance.now();
5933
- if (now - lastProgressAtRef.current >= PROGRESS_THROTTLE_MS) {
5934
- lastProgressAtRef.current = now;
5935
- progress(
5936
- video.currentTime,
5937
- finitePlaybackDuration(
5938
- video.duration,
5939
- video.seekable,
5940
- effectiveMode
5941
- )
5942
- );
5943
- }
5944
- }
5945
- if (effectiveMode === "live" && video.seekable.length > 0) {
5946
- const edge = video.seekable.end(video.seekable.length - 1);
5947
- const lagSeconds = edge - video.currentTime;
5948
- setBehindLive(lagSeconds > LIVE_EDGE_THRESHOLD_S);
5949
- if (activeLiveCaptionsBaseUrl) {
5950
- setLiveLagMs((prev) => stabilizeLiveLagMs(prev, lagSeconds * 1e3));
5951
- }
5952
- }
5953
- };
5954
- const onDuration = () => setDuration(
5955
- finitePlaybackDuration(video.duration, video.seekable, effectiveMode)
5956
- );
5957
- const onVolume = () => {
5958
- setIsMuted(video.muted);
5959
- setVolume(video.volume);
5960
- };
5961
- const onRate = () => setPlaybackRate(video.playbackRate);
5962
- const onPlaying = () => {
5963
- if (isMutedRef.current && !video.muted) video.muted = true;
5964
- };
5965
- video.addEventListener("timeupdate", onTimeUpdate);
5966
- video.addEventListener("durationchange", onDuration);
5967
- video.addEventListener("loadedmetadata", onDuration);
5968
- video.addEventListener("volumechange", onVolume);
5969
- video.addEventListener("ratechange", onRate);
5970
- video.addEventListener("playing", onPlaying);
5971
- onVolume();
5972
- return () => {
5973
- video.removeEventListener("timeupdate", onTimeUpdate);
5974
- video.removeEventListener("durationchange", onDuration);
5975
- video.removeEventListener("loadedmetadata", onDuration);
5976
- video.removeEventListener("volumechange", onVolume);
5977
- video.removeEventListener("ratechange", onRate);
5978
- video.removeEventListener("playing", onPlaying);
5979
- };
5980
- }, [videoRef, active, effectiveMode, activeLiveCaptionsBaseUrl]);
5981
- React11.useLayoutEffect(() => {
5982
- const video = videoRef.current;
5983
- if (video) video.muted = isMuted;
5984
- }, [isMuted, active, videoRef]);
5985
- React11.useEffect(() => {
5986
- const video = videoRef.current;
5987
- if (!paused || !video || !isPlaying) return;
5988
- video.pause();
5989
- }, [paused, videoRef, isPlaying]);
5990
- React11.useEffect(() => {
5991
- setEmbedded(isEmbeddedWindow());
5992
- setWebkitFullscreenSupported(hasWebkitVideoFullscreen(videoRef.current));
5993
- videoRef.current?.setAttribute("x-webkit-airplay", "allow");
5994
- videoRef.current?.setAttribute("webkit-playsinline", "");
5995
- }, [videoRef, active]);
5996
- React11.useEffect(() => {
5997
- const onFsChange = () => {
5998
- if (document.fullscreenElement === containerRef.current) {
5999
- setIsFullscreen(true);
6000
- return;
6001
- }
6002
- if (cssFullscreenRef.current || webkitFsRef.current) return;
6003
- setIsFullscreen(false);
6004
- };
6005
- document.addEventListener("fullscreenchange", onFsChange);
6006
- return () => document.removeEventListener("fullscreenchange", onFsChange);
6007
- }, []);
6008
- function applyNativeTrackModes(video, locale, nativeVisible) {
6009
- applyingTrackModesRef.current = true;
6010
- try {
6011
- applyCaptionTrackModes(video, locale, nativeVisible);
6012
- } finally {
6013
- applyingTrackModesRef.current = false;
6014
- }
6015
- }
6016
- function onSidecarTrackLoad(event) {
6017
- const track = event.currentTarget.track;
6018
- if (!track) return;
6019
- const video = videoRef.current;
6020
- if (video) {
6021
- applyNativeTrackModes(
6022
- video,
6023
- captionLocaleRef.current,
6024
- webkitFsRef.current
6025
- );
6026
- }
6027
- }
6028
- React11.useEffect(() => {
6029
- const video = asWebkitVideo(videoRef.current);
6030
- if (!video) return;
6031
- const onBegin = () => {
6032
- webkitFsRef.current = true;
6033
- setWebkitNativeFs(true);
6034
- setIsFullscreen(true);
6035
- applyNativeTrackModes(video, captionLocaleRef.current, true);
6036
- };
6037
- const onEnd = () => {
6038
- webkitFsRef.current = false;
6039
- setWebkitNativeFs(false);
6040
- applyNativeTrackModes(video, captionLocaleRef.current, false);
6041
- if (!cssFullscreenRef.current) setIsFullscreen(false);
6042
- };
6043
- video.addEventListener("webkitbeginfullscreen", onBegin);
6044
- video.addEventListener("webkitendfullscreen", onEnd);
6045
- return () => {
6046
- video.removeEventListener("webkitbeginfullscreen", onBegin);
6047
- video.removeEventListener("webkitendfullscreen", onEnd);
6048
- };
6049
- }, [videoRef, active]);
6050
- React11.useEffect(() => {
6051
- if (!cssFullscreen) return;
6052
- const previousOverflow = document.body.style.overflow;
6053
- document.body.style.overflow = "hidden";
6054
- const onKey = (event) => {
6055
- if (event.key !== "Escape") return;
6056
- setCssFullscreen(false);
6057
- setIsFullscreen(false);
6058
- };
6059
- document.addEventListener("keydown", onKey);
6060
- return () => {
6061
- document.body.style.overflow = previousOverflow;
6062
- document.removeEventListener("keydown", onKey);
6063
- };
6064
- }, [cssFullscreen]);
6065
- React11.useEffect(() => {
6066
- const video = videoRef.current;
6067
- if (!video) return;
6068
- const onEnter = () => setPipActive(true);
6069
- const onLeave = () => setPipActive(false);
6070
- video.addEventListener("enterpictureinpicture", onEnter);
6071
- video.addEventListener("leavepictureinpicture", onLeave);
6072
- return () => {
6073
- video.removeEventListener("enterpictureinpicture", onEnter);
6074
- video.removeEventListener("leavepictureinpicture", onLeave);
6075
- };
6076
- }, [videoRef]);
6077
- const scheduleHide = React11.useCallback(() => {
6078
- if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
6079
- hideTimerRef.current = setTimeout(() => {
6080
- setControlsVisible(false);
6081
- setOpenMenu(null);
6082
- }, CONTROLS_HIDE_MS);
6083
- }, []);
6084
- const revealControls = React11.useCallback(() => {
6085
- setControlsVisible(true);
6086
- scheduleHide();
6087
- }, [scheduleHide]);
6088
- React11.useEffect(() => {
6089
- return () => {
6090
- if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
6091
- };
6092
- }, []);
6093
- React11.useEffect(() => {
6094
- if (captionLocale === "off" || !showCaptionsMenu) {
6095
- setCaptionCues([]);
6096
- setLiveCaptionCues([]);
6097
- return;
6098
- }
6099
- setLiveCaptionCues([]);
6100
- let cancelled = false;
6101
- const load = async () => {
6102
- const liveBase = activeLiveCaptionsBaseUrl;
6103
- if (liveBase) {
6104
- const loaded = await loadLiveCaptions(
6105
- liveCaptionsUrl(liveBase, captionLocale)
6106
- );
6107
- if (!cancelled && loaded.ok) {
6108
- setLiveCaptionCues((prev) => mergeLiveCaptionCues(prev, loaded.cues));
6109
- }
6110
- return;
6111
- }
6112
- const url = captionsVttUrlFromPlayback(src, captionLocale);
6113
- if (!url) {
6114
- if (!cancelled) setCaptionCues([]);
6115
- return;
6116
- }
6117
- const cues = await loadCaptionVtt(url);
6118
- if (!cancelled) setCaptionCues(cues);
6119
- };
6120
- void load();
6121
- if (!activeLiveCaptionsBaseUrl) return;
6122
- const timer = window.setInterval(() => void load(), 2e3);
6123
- return () => {
6124
- cancelled = true;
6125
- window.clearInterval(timer);
6126
- };
6127
- }, [captionLocale, activeLiveCaptionsBaseUrl, showCaptionsMenu, src]);
6128
- React11.useEffect(() => {
6129
- if (!activeLiveCaptionsBaseUrl || captionLocale === "off") {
6130
- setLivePlayout(EMPTY_LIVE_CAPTION_PLAYOUT);
6131
- return;
6132
- }
6133
- const tick = () => {
6134
- setLivePlayout(
6135
- (prev) => advanceLiveCaptionPlayout(
6136
- prev,
6137
- coalesceLiveCaptionCues(liveCaptionCuesRef.current),
6138
- Date.now(),
6139
- liveLagMsRef.current,
6140
- compactChromeRef.current ? CAPTION_COMPACT_CHARS_PER_LINE : CAPTION_MAX_CHARS_PER_LINE
6141
- )
6142
- );
6143
- };
6144
- tick();
6145
- const timer = window.setInterval(tick, LIVE_CAPTION_PLAYOUT_MS);
6146
- return () => window.clearInterval(timer);
6147
- }, [activeLiveCaptionsBaseUrl, captionLocale]);
6148
- const captionWrapWidth = compactChrome ? CAPTION_COMPACT_CHARS_PER_LINE : CAPTION_MAX_CHARS_PER_LINE;
6149
- const captionScreen = activeLiveCaptionsBaseUrl ? livePlayout.screen : captionScreenAtTime(captionCues, currentTime, captionWrapWidth);
6150
- React11.useEffect(() => {
6151
- const video = videoRef.current;
6152
- if (!video || !activeLiveCaptionsBaseUrl) return;
6153
- try {
6154
- ensureLiveSubtitleTracks(video, {
6155
- en: t.captionsEn,
6156
- es: t.captionsEs,
6157
- pt: t.captionsPt
6158
- });
6159
- } catch {
6160
- return;
6161
- }
6162
- applyNativeTrackModes(video, captionLocale, webkitFsRef.current);
6163
- }, [
6164
- videoRef,
6165
- active,
6166
- activeLiveCaptionsBaseUrl,
6167
- captionLocale,
6168
- t.captionsEn,
6169
- t.captionsEs,
6170
- t.captionsPt
6171
- ]);
6172
- React11.useEffect(() => {
6173
- const video = videoRef.current;
6174
- if (!video) return;
6175
- applyNativeTrackModes(video, captionLocale, webkitFsRef.current);
6176
- }, [videoRef, active, captionLocale, src]);
6177
- React11.useEffect(() => {
6178
- const video = videoRef.current;
6179
- if (!video) return;
6180
- const onChange = () => {
6181
- if (applyingTrackModesRef.current) return;
6182
- const showing = showingCaptionLocale(video);
6183
- if (!webkitFsRef.current) {
6184
- if (showing !== "off") setCaptionLocale(showing);
6185
- return;
6186
- }
6187
- setCaptionLocale(showing);
6188
- };
6189
- return listenTextTracksChange(video.textTracks, onChange);
6190
- }, [videoRef, active, src, activeLiveCaptionsBaseUrl]);
6191
- React11.useEffect(() => {
6192
- const video = videoRef.current;
6193
- if (!video || captionLocale === "off" || !activeLiveCaptionsBaseUrl) return;
6194
- const track = findSubtitleTrack(video, captionLocale);
6195
- if (!track) return;
6196
- const remaining = livePlayout.screen ? Math.max(0.2, (livePlayout.hideAt - Date.now()) / 1e3) : 0;
6197
- syncNativeCaptionCue(
6198
- video,
6199
- track,
6200
- livePlayout.screen?.text ?? "",
6201
- remaining
6202
- );
6203
- }, [livePlayout, captionLocale, activeLiveCaptionsBaseUrl]);
6204
- function togglePlay() {
6205
- const video = videoRef.current;
6206
- if (!video) return;
6207
- if (video.paused) void video.play();
6208
- else video.pause();
6209
- }
6210
- function toggleMute() {
6211
- const video = videoRef.current;
6212
- if (!video) return;
6213
- video.muted = !video.muted;
6214
- }
6215
- function changeVolume(next) {
6216
- const video = videoRef.current;
6217
- if (!video) return;
6218
- video.volume = next;
6219
- video.muted = next === 0;
6220
- }
6221
- function seekTo(next) {
6222
- const video = videoRef.current;
6223
- if (!video) return;
6224
- video.currentTime = next;
6225
- setCurrentTime(next);
6226
- }
6227
- function seekBy(delta) {
6228
- const video = videoRef.current;
6229
- if (!video) return;
6230
- seekTo(Math.min(Math.max(video.currentTime + delta, 0), duration || 0));
6231
- }
6232
- function goToLiveEdge() {
6233
- const video = videoRef.current;
6234
- if (!video || video.seekable.length === 0) return;
6235
- video.currentTime = video.seekable.end(video.seekable.length - 1);
6236
- if (video.paused) void video.play();
6237
- }
6238
- function exitCssFullscreen() {
6239
- setCssFullscreen(false);
6240
- setIsFullscreen(false);
6241
- }
6242
- function toggleFullscreen() {
6243
- const el = containerRef.current;
6244
- const video = asWebkitVideo(videoRef.current);
6245
- if (el && document.fullscreenElement === el) {
6246
- void document.exitFullscreen();
6247
- return;
6248
- }
6249
- if (video?.webkitDisplayingFullscreen && video.webkitExitFullscreen) {
6250
- video.webkitExitFullscreen();
6251
- return;
6252
- }
6253
- if (cssFullscreen) {
6254
- exitCssFullscreen();
6255
- return;
6256
- }
6257
- if (video && typeof video.webkitEnterFullscreen === "function") {
6258
- try {
6259
- video.webkitEnterFullscreen();
6260
- } catch {
6261
- setCssFullscreen(true);
6262
- setIsFullscreen(true);
6263
- }
6264
- return;
6265
- }
6266
- if (el && hasStandardFullscreen() && typeof el.requestFullscreen === "function") {
6267
- void el.requestFullscreen();
6268
- return;
6269
- }
6270
- setCssFullscreen(true);
6271
- setIsFullscreen(true);
6272
- }
6273
- function togglePip() {
6274
- const video = videoRef.current;
6275
- if (!video) return;
6276
- if (document.pictureInPictureElement === video) {
6277
- void document.exitPictureInPicture();
6278
- } else {
6279
- void video.requestPictureInPicture?.();
6280
- }
6281
- }
6282
- function changeRate(rate) {
6283
- const video = videoRef.current;
6284
- if (video) video.playbackRate = rate;
6285
- setPlaybackRate(rate);
6286
- setOpenMenu(null);
6287
- }
6288
- function chooseLevel(index) {
6289
- setLevel(index);
6290
- setOpenMenu(null);
6291
- }
6292
- function chooseCaption(locale) {
6293
- setCaptionLocale(locale);
6294
- setOpenMenu(null);
6295
- }
6296
- function toggleControls() {
6297
- setOpenMenu(null);
6298
- setControlsVisible((current) => {
6299
- const next = !current;
6300
- if (next) scheduleHide();
6301
- return next;
6302
- });
6303
- }
6304
- function recordPointerType(e) {
6305
- lastPointerTypeRef.current = e.pointerType;
6306
- }
6307
- function handlePointerMove(e) {
6308
- if (e.pointerType === "mouse") lastPointerTypeRef.current = "mouse";
6309
- }
6310
- function handleMouseMove() {
6311
- if (lastPointerTypeRef.current === "touch") return;
6312
- revealControls();
6313
- }
6314
- function handleMouseLeave() {
6315
- if (lastPointerTypeRef.current === "touch") return;
6316
- if (isPlaying) setControlsVisible(false);
6317
- }
6318
- function handleKeyDown(e) {
6319
- if (!active) return;
6320
- switch (e.key) {
6321
- case " ":
6322
- case "k":
6323
- e.preventDefault();
6324
- togglePlay();
6325
- break;
6326
- case "m":
6327
- toggleMute();
6328
- break;
6329
- case "f":
6330
- toggleFullscreen();
6331
- break;
6332
- case "Escape":
6333
- if (cssFullscreen) {
6334
- e.preventDefault();
6335
- exitCssFullscreen();
6336
- }
6337
- break;
6338
- case "ArrowLeft":
6339
- if (effectiveMode === "vod") {
6340
- e.preventDefault();
6341
- seekBy(-SEEK_STEP_S);
6342
- }
6343
- break;
6344
- case "ArrowRight":
6345
- if (effectiveMode === "vod") {
6346
- e.preventDefault();
6347
- seekBy(SEEK_STEP_S);
6348
- }
6349
- break;
6350
- case "ArrowUp":
6351
- e.preventDefault();
6352
- changeVolume(Math.min((videoRef.current?.volume ?? 1) + 0.1, 1));
6353
- break;
6354
- case "ArrowDown":
6355
- e.preventDefault();
6356
- changeVolume(Math.max((videoRef.current?.volume ?? 0) - 0.1, 0));
6357
- break;
6358
- }
6359
- revealControls();
6360
- }
6361
- function errorMessage(err) {
6362
- switch (err.kind) {
6363
- case "unavailable":
6364
- return t.errorUnavailable;
6365
- case "network":
6366
- return t.errorNetwork;
6367
- case "media":
6368
- return t.errorMedia;
6369
- case "unsupported":
6370
- return t.errorUnsupported;
6371
- case "resync":
6372
- return t.errorMedia;
6373
- case "generic":
6374
- return t.errorGeneric;
6375
- default: {
6376
- const _exhaustive = err.kind;
6377
- return _exhaustive;
6378
- }
6379
- }
6380
- }
6381
- const VolumeIcon = isMuted || volume === 0 ? VolumeX : volume < 0.5 ? Volume1 : Volume2;
6382
- const showSpinner = active && (state === "loading" || state === "waiting");
6383
- const showControls = active && state === "ready" && controlsVisible;
6384
- const showPoster = !active && !!poster;
6385
- const currentLevelLabel = activeLevel < 0 ? t.auto : `${qualities.find((q) => q.index === activeLevel)?.height ?? ""}p`;
6386
- const showQuality = showQualitySelector && qualities.length > 1;
6387
- return /* @__PURE__ */ jsxs(
6388
- "div",
6389
- {
6390
- ref: containerRef,
6391
- "data-slot": "video-player",
6392
- "data-mode": effectiveMode,
6393
- "data-fit": fit,
6394
- "data-css-fullscreen": cssFullscreen ? "" : void 0,
6395
- className: cn(
6396
- "@container group relative w-full overflow-hidden rounded-lg bg-black text-white select-none",
6397
- fit === "contain" ? "h-full min-h-0 aspect-auto" : "aspect-video",
6398
- cssFullscreen && "fixed inset-0 z-50 h-dvh w-dvw rounded-none",
6399
- className
6400
- ),
6401
- onPointerDown: recordPointerType,
6402
- onPointerMove: handlePointerMove,
6403
- onMouseMove: handleMouseMove,
6404
- onMouseLeave: handleMouseLeave,
6405
- onKeyDown: handleKeyDown,
6406
- tabIndex: 0,
6407
- role: "region",
6408
- "aria-label": "Video player",
6409
- children: [
6410
- /* @__PURE__ */ jsx("style", { children: VIDEO_MEDIA_STYLE }),
6411
- /* @__PURE__ */ jsx(
6412
- "video",
6413
- {
6414
- ref: videoRef,
6415
- playsInline: true,
6416
- muted: isMuted,
6417
- className: "livo-video-player-media h-full w-full bg-black object-contain",
6418
- onClick: active ? toggleControls : void 0,
6419
- poster,
6420
- children: showCaptionsMenu && !activeLiveCaptionsBaseUrl ? CAPTION_LOCALES.map((locale) => {
6421
- const url = captionsVttUrlFromPlayback(src, locale);
6422
- if (!url) return null;
6423
- return /* @__PURE__ */ jsx(
6424
- "track",
6425
- {
6426
- kind: "subtitles",
6427
- srcLang: locale,
6428
- label: captionLocaleLabel(locale, t),
6429
- src: url,
6430
- onLoad: onSidecarTrackLoad
6431
- },
6432
- `${locale}:${url}`
6433
- );
6434
- }) : null
6435
- }
6436
- ),
6437
- showPoster && /* @__PURE__ */ jsx(
6438
- "button",
6439
- {
6440
- type: "button",
6441
- "aria-label": t.play,
6442
- onClick: () => {
6443
- setUserStarted(true);
6444
- revealControls();
6445
- },
6446
- className: "absolute inset-0 flex items-center justify-center bg-black bg-contain bg-center bg-no-repeat",
6447
- style: poster ? { backgroundImage: `url(${poster})` } : void 0,
6448
- children: /* @__PURE__ */ jsx("span", { className: "flex size-16 items-center justify-center rounded-full bg-black/50 backdrop-blur-sm transition group-hover:bg-black/70", children: /* @__PURE__ */ jsx(Play, { className: "size-8 translate-x-0.5", fill: "currentColor" }) })
6449
- }
6450
- ),
6451
- showSpinner && /* @__PURE__ */ jsxs("div", { className: "absolute inset-0 flex flex-col items-center justify-center gap-3 bg-black/50 text-sm", children: [
6452
- /* @__PURE__ */ jsx(Loader2, { className: "size-8 animate-spin" }),
6453
- /* @__PURE__ */ jsx("span", { children: state === "loading" ? t.loading : t.waiting })
6454
- ] }),
6455
- state === "error" && error && /* @__PURE__ */ jsxs("div", { className: "absolute inset-0 flex flex-col items-center justify-center gap-4 bg-black/70 px-6 text-center text-sm", children: [
6456
- /* @__PURE__ */ jsx(AlertCircle, { className: "text-red-400 size-8" }),
6457
- /* @__PURE__ */ jsx("p", { className: "text-red-200", children: errorMessage(error) }),
6458
- /* @__PURE__ */ jsxs(
6459
- "button",
6460
- {
6461
- type: "button",
6462
- onClick: retry,
6463
- className: "inline-flex items-center gap-2 rounded-md bg-primary/15 px-3 py-1.5 text-sm hover:bg-primary/25",
6464
- children: [
6465
- /* @__PURE__ */ jsx(RotateCw, { className: "size-4" }),
6466
- t.retry
6467
- ]
6468
- }
6469
- )
6470
- ] }),
6471
- state === "ready" && autoplayState === "blocked" && !isPlaying && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/40", children: /* @__PURE__ */ jsx(
6472
- "button",
6473
- {
6474
- type: "button",
6475
- "aria-label": t.play,
6476
- onClick: togglePlay,
6477
- className: "flex size-16 items-center justify-center rounded-full bg-white/20 backdrop-blur-sm transition hover:bg-white/30",
6478
- children: /* @__PURE__ */ jsx(Play, { className: "size-8 translate-x-0.5", fill: "currentColor" })
6479
- }
6480
- ) }),
6481
- state === "ready" && autoplayState === "muted" && /* @__PURE__ */ jsxs(
6482
- "button",
6483
- {
6484
- type: "button",
6485
- onClick: toggleMute,
6486
- className: "absolute top-3 right-3 flex items-center gap-1.5 rounded-full bg-black/70 px-3 py-1.5 text-xs backdrop-blur-sm transition hover:bg-black/90",
6487
- children: [
6488
- /* @__PURE__ */ jsx(VolumeX, { className: "size-4" }),
6489
- t.tapToUnmute
6490
- ]
6491
- }
6492
- ),
6493
- effectiveMode === "live" && active && state === "ready" && /* @__PURE__ */ jsxs("div", { className: "absolute top-3 left-3 flex items-center gap-2", children: [
6494
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 rounded bg-red-600 px-2 py-0.5 text-xs font-semibold tracking-wide", children: [
6495
- /* @__PURE__ */ jsx("span", { className: "size-1.5 animate-pulse rounded-full bg-white" }),
6496
- t.live
6497
- ] }),
6498
- typeof stats?.viewers === "number" && /* @__PURE__ */ jsx("span", { className: "rounded bg-black/60 px-2 py-0.5 text-xs", children: t.formatViewers ? t.formatViewers(stats.viewers) : `\u{1F441} ${stats.viewers}` })
6499
- ] }),
6500
- captionLocale !== "off" && !webkitNativeFs && /* @__PURE__ */ jsx(CaptionOverlay, { screen: captionScreen }),
6501
- active && /* @__PURE__ */ jsxs(
6502
- "div",
6503
- {
6504
- className: cn(
6505
- "absolute inset-x-0 bottom-0 flex flex-col gap-1 bg-gradient-to-t from-black/80 to-transparent px-3 pt-8 pb-2 transition-opacity",
6506
- showControls ? "opacity-100" : "pointer-events-none opacity-0"
6507
- ),
6508
- "data-slot": "video-controls",
6509
- children: [
6510
- effectiveMode === "vod" && /* @__PURE__ */ jsx(
6511
- SeekBar,
6512
- {
6513
- src,
6514
- duration,
6515
- currentTime,
6516
- buffered,
6517
- onSeek: seekTo,
6518
- formatTime
6519
- }
6520
- ),
6521
- /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-1 sm:gap-2", children: [
6522
- /* @__PURE__ */ jsx(
6523
- ControlButton,
6524
- {
6525
- label: isPlaying ? t.pause : t.play,
6526
- onClick: togglePlay,
6527
- children: isPlaying ? /* @__PURE__ */ jsx(Pause, { className: "size-5", fill: "currentColor" }) : /* @__PURE__ */ jsx(Play, { className: "size-5", fill: "currentColor" })
6528
- }
6529
- ),
6530
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
6531
- /* @__PURE__ */ jsx(
6532
- ControlButton,
6533
- {
6534
- label: isMuted ? t.unmute : t.mute,
6535
- onClick: toggleMute,
6536
- children: /* @__PURE__ */ jsx(VolumeIcon, { className: "size-5" })
6537
- }
6538
- ),
6539
- !compactChrome && /* @__PURE__ */ jsx("div", { className: "w-20 px-1", children: /* @__PURE__ */ jsx(
6540
- Slider,
6541
- {
6542
- "aria-label": "Volume",
6543
- min: 0,
6544
- max: 1,
6545
- step: 0.05,
6546
- value: [isMuted ? 0 : volume],
6547
- onValueChange: (v) => changeVolume(v[0] ?? 0)
6548
- }
6549
- ) })
6550
- ] }),
6551
- effectiveMode === "vod" && /* @__PURE__ */ jsxs("span", { className: "ml-1 shrink-0 text-xs tabular-nums", children: [
6552
- formatTime(currentTime),
6553
- !compactChrome && ` / ${formatTime(duration)}`
6554
- ] }),
6555
- effectiveMode === "live" && behindLive && /* @__PURE__ */ jsxs(
6556
- "button",
6557
- {
6558
- type: "button",
6559
- onClick: goToLiveEdge,
6560
- className: "ml-1 flex shrink-0 items-center gap-1 rounded bg-primary/15 px-2 py-0.5 text-xs hover:bg-primary/25",
6561
- children: [
6562
- /* @__PURE__ */ jsx("span", { className: "size-1.5 rounded-full bg-red-500" }),
6563
- t.goLive
6564
- ]
6565
- }
6566
- ),
6567
- /* @__PURE__ */ jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-1", children: [
6568
- !compactChrome && effectiveMode === "vod" && typeof stats?.views === "number" && /* @__PURE__ */ jsx("span", { className: "mr-1 text-xs", children: t.formatViews ? t.formatViews(stats.views) : `${stats.views} views` }),
6569
- showCaptionsMenu && /* @__PURE__ */ jsxs(
6570
- MenuControl,
6571
- {
6572
- label: t.captions,
6573
- open: openMenu === "captions",
6574
- onOpenChange: (o) => setOpenMenu(o ? "captions" : null),
6575
- trigger: /* @__PURE__ */ jsx(Captions, { className: "size-5" }),
6576
- children: [
6577
- /* @__PURE__ */ jsx(
6578
- MenuItem,
6579
- {
6580
- selected: captionLocale === "off",
6581
- onSelect: () => chooseCaption("off"),
6582
- children: t.captionsOff
6583
- }
6584
- ),
6585
- CAPTION_LOCALES.map((locale) => /* @__PURE__ */ jsx(
6586
- MenuItem,
6587
- {
6588
- selected: captionLocale === locale,
6589
- onSelect: () => chooseCaption(locale),
6590
- children: captionLocaleLabel(locale, t)
6591
- },
6592
- locale
6593
- ))
6594
- ]
6595
- }
6596
- ),
6597
- !compactChrome && effectiveMode === "vod" && /* @__PURE__ */ jsx(
6598
- MenuControl,
6599
- {
6600
- label: t.speed,
6601
- open: openMenu === "speed",
6602
- onOpenChange: (o) => setOpenMenu(o ? "speed" : null),
6603
- trigger: /* @__PURE__ */ jsxs("span", { className: "text-xs font-semibold", children: [
6604
- playbackRate,
6605
- "\xD7"
6606
- ] }),
6607
- children: PLAYBACK_RATES.map((rate) => /* @__PURE__ */ jsxs(
6608
- MenuItem,
6609
- {
6610
- selected: rate === playbackRate,
6611
- onSelect: () => changeRate(rate),
6612
- children: [
6613
- rate,
6614
- "\xD7"
6615
- ]
6616
- },
6617
- rate
6618
- ))
6619
- }
6620
- ),
6621
- !compactChrome && showQuality && /* @__PURE__ */ jsxs(
6622
- MenuControl,
6623
- {
6624
- label: t.quality,
6625
- open: openMenu === "quality",
6626
- onOpenChange: (o) => setOpenMenu(o ? "quality" : null),
6627
- trigger: /* @__PURE__ */ jsx(Settings, { className: "size-5" }),
6628
- triggerBadge: currentLevelLabel,
6629
- children: [
6630
- /* @__PURE__ */ jsx(
6631
- MenuItem,
6632
- {
6633
- selected: activeLevel < 0,
6634
- onSelect: () => chooseLevel(-1),
6635
- children: t.auto
6636
- }
6637
- ),
6638
- qualities.map((q) => /* @__PURE__ */ jsxs(
6639
- MenuItem,
6640
- {
6641
- selected: activeLevel === q.index,
6642
- onSelect: () => chooseLevel(q.index),
6643
- children: [
6644
- q.height,
6645
- "p"
6646
- ]
6647
- },
6648
- q.index
6649
- ))
6650
- ]
6651
- }
6652
- ),
6653
- !compactChrome && /* @__PURE__ */ jsx(
6654
- ControlButton,
6655
- {
6656
- label: t.cast,
6657
- onClick: () => {
6658
- void castHlsUrl(src).catch(() => void 0);
6659
- },
6660
- children: /* @__PURE__ */ jsx(Cast, { className: "size-5" })
6661
- }
6662
- ),
6663
- !compactChrome && pipSupported && /* @__PURE__ */ jsx(ControlButton, { label: t.pictureInPicture, onClick: togglePip, children: /* @__PURE__ */ jsx(
6664
- PictureInPicture2,
6665
- {
6666
- className: cn("size-5", pipActive && "text-primary")
6667
- }
6668
- ) }),
6669
- compactChrome && /* @__PURE__ */ jsx(
6670
- MenuControl,
6671
- {
6672
- label: t.more,
6673
- open: openMenu === "more",
6674
- onOpenChange: (o) => setOpenMenu(o ? "more" : null),
6675
- trigger: /* @__PURE__ */ jsx(EllipsisVertical, { className: "size-5" }),
6676
- children: morePane === "speed" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6677
- /* @__PURE__ */ jsx(
6678
- MenuBack,
6679
- {
6680
- label: t.back,
6681
- title: t.speed,
6682
- onSelect: () => setMorePane("root")
6683
- }
6684
- ),
6685
- PLAYBACK_RATES.map((rate) => /* @__PURE__ */ jsxs(
6686
- MenuItem,
6687
- {
6688
- selected: rate === playbackRate,
6689
- onSelect: () => changeRate(rate),
6690
- children: [
6691
- rate,
6692
- "\xD7"
6693
- ]
6694
- },
6695
- rate
6696
- ))
6697
- ] }) : morePane === "quality" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6698
- /* @__PURE__ */ jsx(
6699
- MenuBack,
6700
- {
6701
- label: t.back,
6702
- title: t.quality,
6703
- onSelect: () => setMorePane("root")
6704
- }
6705
- ),
6706
- /* @__PURE__ */ jsx(
6707
- MenuItem,
6708
- {
6709
- selected: activeLevel < 0,
6710
- onSelect: () => chooseLevel(-1),
6711
- children: t.auto
6712
- }
6713
- ),
6714
- qualities.map((q) => /* @__PURE__ */ jsxs(
6715
- MenuItem,
6716
- {
6717
- selected: activeLevel === q.index,
6718
- onSelect: () => chooseLevel(q.index),
6719
- children: [
6720
- q.height,
6721
- "p"
6722
- ]
6723
- },
6724
- q.index
6725
- ))
6726
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
6727
- effectiveMode === "vod" && /* @__PURE__ */ jsx(
6728
- MenuNavRow,
6729
- {
6730
- icon: /* @__PURE__ */ jsx(Gauge, { className: "size-4" }),
6731
- label: t.speed,
6732
- value: `${playbackRate}\xD7`,
6733
- onSelect: () => setMorePane("speed")
6734
- }
6735
- ),
6736
- showQuality && /* @__PURE__ */ jsx(
6737
- MenuNavRow,
6738
- {
6739
- icon: /* @__PURE__ */ jsx(Settings, { className: "size-4" }),
6740
- label: t.quality,
6741
- value: currentLevelLabel,
6742
- onSelect: () => setMorePane("quality")
6743
- }
6744
- ),
6745
- (effectiveMode === "vod" || showQuality) && /* @__PURE__ */ jsx("div", { className: "my-1 h-px bg-primary/15" }),
6746
- /* @__PURE__ */ jsx(
6747
- MenuAction,
6748
- {
6749
- icon: /* @__PURE__ */ jsx(Cast, { className: "size-4" }),
6750
- onSelect: () => {
6751
- setOpenMenu(null);
6752
- void castHlsUrl(src).catch(() => void 0);
6753
- },
6754
- children: t.cast
6755
- }
6756
- ),
6757
- pipSupported && /* @__PURE__ */ jsx(
6758
- MenuAction,
6759
- {
6760
- icon: /* @__PURE__ */ jsx(PictureInPicture2, { className: "size-4" }),
6761
- active: pipActive,
6762
- onSelect: () => {
6763
- setOpenMenu(null);
6764
- togglePip();
6765
- },
6766
- children: t.pictureInPicture
6767
- }
6768
- )
6769
- ] })
6770
- }
6771
- ),
6772
- fullscreenSupported && /* @__PURE__ */ jsx(
6773
- ControlButton,
6774
- {
6775
- label: isFullscreen ? t.exitFullscreen : t.enterFullscreen,
6776
- onClick: toggleFullscreen,
6777
- children: isFullscreen ? /* @__PURE__ */ jsx(Minimize, { className: "size-5" }) : /* @__PURE__ */ jsx(Maximize, { className: "size-5" })
6778
- }
6779
- )
6780
- ] })
6781
- ] })
6782
- ]
6783
- }
6784
- )
6785
- ]
6786
- }
6787
- );
6788
- }
6789
- function ControlButton({
6790
- label,
6791
- onClick,
6792
- children
6793
- }) {
6794
- return /* @__PURE__ */ jsx(
6795
- "button",
6796
- {
6797
- type: "button",
6798
- "aria-label": label,
6799
- title: label,
6800
- onClick,
6801
- className: "flex size-8 items-center justify-center rounded-md text-white/90 outline-none hover:bg-primary/15 hover:text-white focus-visible:ring-2 focus-visible:ring-white/60",
6802
- children
6803
- }
6804
- );
6805
- }
6806
- function MenuControl({
6807
- label,
6808
- open,
6809
- onOpenChange,
6810
- trigger,
6811
- triggerBadge,
6812
- children
6813
- }) {
6814
- return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
6815
- /* @__PURE__ */ jsxs(
6816
- "button",
6817
- {
6818
- type: "button",
6819
- "aria-label": label,
6820
- "aria-haspopup": "menu",
6821
- "aria-expanded": open,
6822
- title: label,
6823
- onClick: () => onOpenChange(!open),
6824
- className: "flex h-8 items-center gap-1 rounded-md px-1.5 text-white/90 outline-none hover:bg-primary/15 hover:text-white focus-visible:ring-2 focus-visible:ring-white/60",
6825
- children: [
6826
- trigger,
6827
- triggerBadge && /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium", children: triggerBadge })
6828
- ]
6829
- }
6830
- ),
6831
- open && /* @__PURE__ */ jsx(
6832
- "div",
6833
- {
6834
- role: "menu",
6835
- className: "absolute right-0 bottom-full z-10 mb-2 min-w-52 rounded-md bg-black/90 p-1 text-sm shadow-lg backdrop-blur-sm",
6836
- children
6837
- }
6838
- )
6839
- ] });
6840
- }
6841
- function MenuItem({
6842
- selected,
6843
- onSelect,
6844
- children
6845
- }) {
6846
- return /* @__PURE__ */ jsxs(
6847
- "button",
6848
- {
6849
- type: "button",
6850
- role: "menuitemradio",
6851
- "aria-checked": selected,
6852
- onClick: onSelect,
6853
- className: "flex w-full items-center justify-between gap-3 rounded px-2 py-2.5 text-left text-white/90 hover:bg-primary/15",
6854
- children: [
6855
- children,
6856
- selected && /* @__PURE__ */ jsx(Check, { className: "size-4" })
6857
- ]
6858
- }
6859
- );
6860
- }
6861
- function MenuNavRow({
6862
- icon,
6863
- label,
6864
- value,
6865
- onSelect
6866
- }) {
6867
- return /* @__PURE__ */ jsxs(
6868
- "button",
6869
- {
6870
- type: "button",
6871
- role: "menuitem",
6872
- "aria-label": `${label}, ${value}`,
6873
- onClick: onSelect,
6874
- className: "flex w-full items-center gap-2.5 rounded px-2 py-2.5 text-left text-white/90 hover:bg-primary/15",
6875
- children: [
6876
- /* @__PURE__ */ jsx("span", { className: "text-white/70", children: icon }),
6877
- /* @__PURE__ */ jsx("span", { className: "flex-1", children: label }),
6878
- /* @__PURE__ */ jsx("span", { className: "text-white/50", children: value }),
6879
- /* @__PURE__ */ jsx(ChevronRight, { className: "size-4 text-white/50" })
6880
- ]
6881
- }
6882
- );
6883
- }
6884
- function MenuBack({
6885
- label,
6886
- title,
6887
- onSelect
6888
- }) {
6889
- return /* @__PURE__ */ jsxs(
6890
- "button",
6891
- {
6892
- type: "button",
6893
- role: "menuitem",
6894
- "aria-label": label,
6895
- onClick: onSelect,
6896
- className: "flex w-full items-center gap-2 rounded px-2 py-2.5 text-left text-white/90 hover:bg-primary/15",
6897
- children: [
6898
- /* @__PURE__ */ jsx(ChevronLeft, { className: "size-4" }),
6899
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: title })
6900
- ]
6901
- }
6902
- );
6903
- }
6904
- function MenuAction({
6905
- onSelect,
6906
- icon,
6907
- active,
6908
- children
6909
- }) {
6910
- return /* @__PURE__ */ jsxs(
6911
- "button",
6912
- {
6913
- type: "button",
6914
- role: "menuitem",
6915
- onClick: onSelect,
6916
- className: cn(
6917
- "flex w-full items-center gap-2.5 rounded px-2 py-2.5 text-left text-white/90 hover:bg-primary/15",
6918
- active && "text-primary"
6919
- ),
6920
- children: [
6921
- icon ? /* @__PURE__ */ jsx("span", { className: cn("text-white/70", active && "text-primary"), children: icon }) : null,
6922
- children
6923
- ]
6924
- }
6925
- );
6926
- }
6927
-
6928
- // src/components/video/feedPlaybackCoordinator.ts
6929
- var players = /* @__PURE__ */ new Map();
6930
- function registerFeedPlayer(id, pause) {
6931
- players.set(id, pause);
6932
- return () => {
6933
- if (players.get(id) === pause) {
6934
- players.delete(id);
6935
- }
6936
- };
6937
- }
6938
- function claimFeedPlaying(id) {
6939
- for (const [otherId, pause] of players) {
6940
- if (otherId !== id) pause();
6941
- }
6942
- }
6943
-
6944
- // src/components/video/useFeedExclusivePlayback.ts
6945
- var VISIBILITY_THRESHOLDS = [0, 0.5, 1];
6946
- var MIN_VISIBLE_RATIO = 0.5;
6947
- function videoInPictureInPicture(container) {
6948
- if (typeof document === "undefined" || !container) return false;
6949
- const pip = document.pictureInPictureElement;
6950
- if (!pip) return false;
6951
- return container.contains(pip);
6952
- }
6953
- function useFeedExclusivePlayback(playbackId) {
6954
- const containerRef = React11.useRef(null);
6955
- const [forcePaused, setForcePaused] = React11.useState(false);
6956
- const requestPause = React11.useCallback(() => {
6957
- if (videoInPictureInPicture(containerRef.current)) return;
6958
- setForcePaused(true);
6959
- }, []);
6960
- React11.useEffect(() => {
6961
- return registerFeedPlayer(playbackId, requestPause);
6962
- }, [playbackId, requestPause]);
6963
- React11.useEffect(() => {
6964
- const node = containerRef.current;
6965
- if (!node || typeof IntersectionObserver === "undefined") return;
6966
- const observer = new IntersectionObserver(
6967
- (entries) => {
6968
- const entry = entries[0];
6969
- if (!entry) return;
6970
- if (!entry.isIntersecting || entry.intersectionRatio < MIN_VISIBLE_RATIO) {
6971
- requestPause();
6972
- }
6973
- },
6974
- { threshold: [...VISIBILITY_THRESHOLDS] }
6975
- );
6976
- observer.observe(node);
6977
- return () => observer.disconnect();
6978
- }, [requestPause]);
6979
- React11.useEffect(() => {
6980
- const onVisibility = () => {
6981
- if (document.hidden) requestPause();
6982
- };
6983
- document.addEventListener("visibilitychange", onVisibility);
6984
- return () => document.removeEventListener("visibilitychange", onVisibility);
6985
- }, [requestPause]);
6986
- const onPlayingChange = React11.useCallback(
6987
- (playing) => {
6988
- if (!playing) return;
6989
- setForcePaused(false);
6990
- claimFeedPlaying(playbackId);
6991
- },
6992
- [playbackId]
6993
- );
6994
- return {
6995
- containerRef,
6996
- paused: forcePaused,
6997
- onPlayingChange
6998
- };
6999
- }
7000
- function FeedVideoPlayer({
7001
- playbackId,
7002
- onPlayingChange,
7003
- paused: pausedProp,
7004
- fit = "aspect-video",
7005
- className,
7006
- ...playerProps
7007
- }) {
7008
- const {
7009
- containerRef,
7010
- paused: exclusivePaused,
7011
- onPlayingChange: onExclusivePlayingChange
7012
- } = useFeedExclusivePlayback(playbackId);
7013
- const handlePlayingChange = React11.useCallback(
7014
- (playing) => {
7015
- onExclusivePlayingChange(playing);
7016
- onPlayingChange?.(playing);
7017
- },
7018
- [onExclusivePlayingChange, onPlayingChange]
7019
- );
7020
- return /* @__PURE__ */ jsx(
7021
- "div",
7022
- {
7023
- ref: containerRef,
7024
- "data-slot": "feed-video-player",
7025
- className: cn(fit === "contain" && "h-full min-h-0 w-full", className),
7026
- children: /* @__PURE__ */ jsx(
7027
- VideoPlayer,
7028
- {
7029
- ...playerProps,
7030
- fit,
7031
- paused: pausedProp || exclusivePaused,
7032
- onPlayingChange: handlePlayingChange,
7033
- className: fit === "contain" ? "h-full min-h-0" : void 0
7034
- }
7035
- )
7036
- }
7037
- );
7038
- }
7039
- function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {}) {
7040
- const [stats, setStats] = React11.useState({});
7041
- React11.useEffect(() => {
7042
- if (!statsUrl || !enabled) return;
7043
- let cancelled = false;
7044
- const controller = new AbortController();
7045
- async function poll() {
7046
- try {
7047
- const res = await fetch(statsUrl, {
7048
- signal: controller.signal
7049
- });
7050
- if (!res.ok) return;
7051
- const data = await res.json();
7052
- if (cancelled) return;
7053
- setStats({
7054
- viewers: typeof data.viewers === "number" ? data.viewers : void 0,
7055
- views: typeof data.views === "number" ? data.views : void 0
7056
- });
7057
- } catch {
7058
- }
7059
- }
7060
- void poll();
7061
- const timer = setInterval(() => void poll(), intervalMs);
7062
- return () => {
7063
- cancelled = true;
7064
- controller.abort();
7065
- clearInterval(timer);
7066
- };
7067
- }, [statsUrl, intervalMs, enabled]);
7068
- return stats;
7069
- }
7070
-
7071
2351
  // src/components/upload/part-math.ts
7072
2352
  function partRanges(fileSize, partSize) {
7073
2353
  if (partSize <= 0) {
@@ -7671,6 +2951,18 @@ function createMultipartUploadController(options) {
7671
2951
  getStatus: () => state.status
7672
2952
  };
7673
2953
  }
2954
+ function useMediaQuery2(query) {
2955
+ const [matches, setMatches] = useState(false);
2956
+ useEffect(() => {
2957
+ if (typeof window === "undefined" || !window.matchMedia) return;
2958
+ const mql = window.matchMedia(query);
2959
+ const onChange = () => setMatches(mql.matches);
2960
+ onChange();
2961
+ mql.addEventListener("change", onChange);
2962
+ return () => mql.removeEventListener("change", onChange);
2963
+ }, [query]);
2964
+ return matches;
2965
+ }
7674
2966
 
7675
2967
  // src/lib/avatar.ts
7676
2968
  var EMPTY_COLORS = {
@@ -7752,99 +3044,6 @@ function getAvatarColors(name) {
7752
3044
  function avatarFallbackStyle(name) {
7753
3045
  return getAvatarColors(name);
7754
3046
  }
7755
-
7756
- // src/lib/playbackBeacon.ts
7757
- var DEFAULT_INTERVAL_MS = 5e3;
7758
- function canUseWindow() {
7759
- return typeof window !== "undefined" && typeof document !== "undefined";
7760
- }
7761
- function createPlaybackBeaconClient({
7762
- endpoint,
7763
- sessionId,
7764
- surface,
7765
- getContext,
7766
- fetchFn,
7767
- intervalMs = DEFAULT_INTERVAL_MS,
7768
- now = () => Date.now()
7769
- }) {
7770
- let queue = [];
7771
- let destroyed = false;
7772
- let timer = null;
7773
- let flushing = null;
7774
- function enqueue(event) {
7775
- if (destroyed) return;
7776
- const context = getContext?.() ?? {};
7777
- queue.push({
7778
- type: event.type,
7779
- ...context,
7780
- ...event,
7781
- surface,
7782
- ts: event.ts ?? now()
7783
- });
7784
- }
7785
- async function send(events, keepalive) {
7786
- if (events.length === 0) return;
7787
- const body = JSON.stringify({ sessionId, events });
7788
- const post = fetchFn ?? (typeof fetch === "function" ? fetch : void 0);
7789
- if (!post) return;
7790
- try {
7791
- await post(endpoint, {
7792
- method: "POST",
7793
- headers: { "Content-Type": "application/json" },
7794
- body,
7795
- keepalive
7796
- });
7797
- } catch {
7798
- }
7799
- }
7800
- async function flush(keepalive = false) {
7801
- if (queue.length === 0) return;
7802
- const events = queue;
7803
- queue = [];
7804
- await send(events, keepalive);
7805
- }
7806
- function scheduleFlush() {
7807
- if (flushing) return flushing;
7808
- flushing = flush(false).finally(() => {
7809
- flushing = null;
7810
- });
7811
- return flushing;
7812
- }
7813
- function onPageHide() {
7814
- void flush(true);
7815
- }
7816
- function onVisibility() {
7817
- if (document.visibilityState === "hidden") void flush(true);
7818
- }
7819
- if (canUseWindow()) {
7820
- timer = setInterval(() => {
7821
- void scheduleFlush();
7822
- }, intervalMs);
7823
- window.addEventListener("pagehide", onPageHide);
7824
- document.addEventListener("visibilitychange", onVisibility);
7825
- }
7826
- return {
7827
- track(event) {
7828
- enqueue(event);
7829
- },
7830
- flush() {
7831
- return flush(false);
7832
- },
7833
- destroy() {
7834
- if (destroyed) return;
7835
- destroyed = true;
7836
- if (timer !== null) {
7837
- clearInterval(timer);
7838
- timer = null;
7839
- }
7840
- if (canUseWindow()) {
7841
- window.removeEventListener("pagehide", onPageHide);
7842
- document.removeEventListener("visibilitychange", onVisibility);
7843
- }
7844
- void flush(true);
7845
- }
7846
- };
7847
- }
7848
3047
  function StatHighlightCard({
7849
3048
  label,
7850
3049
  value,
@@ -7965,7 +3164,7 @@ function SparklineStat({
7965
3164
  );
7966
3165
  }
7967
3166
  var TIME_RANGE_OPTIONS = ["day", "week", "month", "year"];
7968
- var DEFAULT_LABELS4 = {
3167
+ var DEFAULT_LABELS2 = {
7969
3168
  day: "Day",
7970
3169
  week: "Week",
7971
3170
  month: "Month",
@@ -7977,7 +3176,7 @@ function TimeRangePicker({
7977
3176
  labels,
7978
3177
  className
7979
3178
  }) {
7980
- const copy = { ...DEFAULT_LABELS4, ...labels };
3179
+ const copy = { ...DEFAULT_LABELS2, ...labels };
7981
3180
  return /* @__PURE__ */ jsx(
7982
3181
  "div",
7983
3182
  {
@@ -8116,6 +3315,6 @@ function MetricSkeleton({ className, bars = 4 }) {
8116
3315
  );
8117
3316
  }
8118
3317
 
8119
- export { AvatarEditor, AvatarEditorDialog, CAPTION_LOCALES, ConfirmDestructiveDialog, CostBreakdownCard, CurtainPicker, CurtainPickerSkeleton, CurtainPreview, CurtainStage, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DEFAULT_FILE_DROPZONE_LABELS, DEFAULT_FILE_UPLOAD_LABELS, DEFAULT_FILE_UPLOAD_TRAY_LABELS, DEFAULT_NOTIFICATION_BELL_LABELS, DEFAULT_SHADER_CURTAIN_CONFIG, DEFAULT_SHADER_CURTAIN_EDITOR_LABELS, DataList, DataListItem, DimensionBreakdownTable, EditableSection, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, FeedVideoPlayer, FieldMessage, FileDropzone, FileUploadMenu, FileUploadTray, LanguageContext, LanguageSwitcher, LoadingState, MetricChartCard, MetricEmptyState, MetricSkeleton, NotificationBell, SHADER_CURTAIN_PRESETS, SafeImage, ShaderCurtain, ShaderCurtainEditor, SparklineStat, StatHighlightCard, TIME_RANGE_OPTIONS, ThemeSwitcher, TimeRangePicker, VideoPlayer, WaitingRoom, avatarFallbackStyle, captionsVttUrlFromPlayback, captureShaderPoster, castHlsUrl, cn, createLiveHlsConfig, createMultipartUploadController, createPlaybackBeaconClient, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, fileMatchesAccept, getAvatarColors, getInitials, isCaptionLocale, isShaderCurtainKind, loadCastSender, mergeShaderCurtainConfig, parseShaderGradientUrl, partRanges, progressFromBytes, shouldRetryLiveEdge404, toShaderGradientUrl, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery2 as useMediaQuery, usePlaybackStats };
3318
+ export { AvatarEditor, AvatarEditorDialog, ConfirmDestructiveDialog, CostBreakdownCard, DEFAULT_EDITABLE_SECTION_LABELS, DEFAULT_FILE_DROPZONE_LABELS, DEFAULT_FILE_UPLOAD_LABELS, DEFAULT_FILE_UPLOAD_TRAY_LABELS, DEFAULT_NOTIFICATION_BELL_LABELS, DataList, DataListItem, DimensionBreakdownTable, EditableSection, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, FieldMessage, FileDropzone, FileUploadMenu, FileUploadTray, LanguageContext, LanguageSwitcher, LoadingState, MetricChartCard, MetricEmptyState, MetricSkeleton, NotificationBell, SafeImage, SparklineStat, StatHighlightCard, TIME_RANGE_OPTIONS, ThemeSwitcher, TimeRangePicker, avatarFallbackStyle, cn, createMultipartUploadController, defaultLanguages, fileMatchesAccept, getAvatarColors, getInitials, partRanges, progressFromBytes, useEditableSection, useLanguageContext, useMediaQuery2 as useMediaQuery };
8120
3319
  //# sourceMappingURL=index.js.map
8121
3320
  //# sourceMappingURL=index.js.map