@livo-tv/blocks 1.0.0 → 1.1.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.d.cts CHANGED
@@ -439,6 +439,86 @@ interface AvatarEditorDialogProps {
439
439
  }
440
440
  declare function AvatarEditorDialog({ value, onChange, onSave, displaySize, editorSize, outputSize, placeholder, editLabel, dialogTitle, acceptText, cancelText, savingText, savedText, successMessage, errorMessage, className, editorLabels, }: AvatarEditorDialogProps): React.JSX.Element;
441
441
 
442
+ type CurtainKind = "image" | "video";
443
+ interface CurtainStageProps {
444
+ kind: CurtainKind;
445
+ url: string;
446
+ alt?: string;
447
+ className?: string;
448
+ /** When true, video curtains show a static frame instead of looping. */
449
+ reducedMotion?: boolean;
450
+ }
451
+ /**
452
+ * Waiting-room backdrop: a still image or a muted looping video.
453
+ * Honors `prefers-reduced-motion` (or an explicit `reducedMotion` prop)
454
+ * by freezing video on the first frame.
455
+ */
456
+ declare function CurtainStage({ kind, url, alt, className, reducedMotion, }: CurtainStageProps): React.JSX.Element;
457
+
458
+ interface WaitingRoomCurtain {
459
+ kind: CurtainKind;
460
+ url: string;
461
+ }
462
+ interface WaitingRoomProps {
463
+ title: string;
464
+ organizationName?: string | null;
465
+ organizationImage?: string | null;
466
+ startsAt?: number | null;
467
+ durationSeconds?: number | null;
468
+ curtain?: WaitingRoomCurtain | null;
469
+ nowMs?: number;
470
+ labels?: {
471
+ startsIn?: string;
472
+ started?: string;
473
+ duration?: (minutes: number) => string;
474
+ };
475
+ className?: string;
476
+ }
477
+ /**
478
+ * Public waiting-room chrome: curtain (or calm branded fallback), title,
479
+ * org avatar, and a countdown to `startsAt`.
480
+ */
481
+ declare function WaitingRoom({ title, organizationName, organizationImage, startsAt, durationSeconds, curtain, nowMs, labels, className, }: WaitingRoomProps): React.JSX.Element;
482
+
483
+ type CastFramework = {
484
+ CastContext: {
485
+ getInstance: () => {
486
+ setOptions: (options: {
487
+ receiverApplicationId: string;
488
+ autoJoinPolicy?: string;
489
+ }) => void;
490
+ requestSession: () => Promise<unknown>;
491
+ getCurrentSession: () => {
492
+ loadMedia: (request: unknown) => Promise<unknown>;
493
+ } | null;
494
+ };
495
+ };
496
+ };
497
+ type ChromeCast = {
498
+ media: {
499
+ DEFAULT_MEDIA_RECEIVER_APP_ID: string;
500
+ MediaInfo: new (url: string, contentType: string) => unknown;
501
+ LoadRequest: new (media: unknown) => unknown;
502
+ };
503
+ AutoJoinPolicy?: {
504
+ ORIGIN_SCOPED: string;
505
+ };
506
+ };
507
+ declare global {
508
+ interface Window {
509
+ cast?: {
510
+ framework?: CastFramework;
511
+ };
512
+ chrome?: {
513
+ cast?: ChromeCast;
514
+ };
515
+ __onGCastApiAvailable?: (available: boolean) => void;
516
+ }
517
+ }
518
+ declare function loadCastSender(): Promise<void>;
519
+ /** Cast an HLS master playlist to the default Chromecast media receiver. */
520
+ declare function castHlsUrl(hlsUrl: string): Promise<void>;
521
+
442
522
  /**
443
523
  * Playback error description, ported from the app's HLS player but stripped of
444
524
  * Sentry. `@livo/blocks` must stay reporting-agnostic: the player surfaces
@@ -540,6 +620,7 @@ interface VideoPlayerLabels {
540
620
  enterFullscreen?: string;
541
621
  exitFullscreen?: string;
542
622
  pictureInPicture?: string;
623
+ cast?: string;
543
624
  settings?: string;
544
625
  quality?: string;
545
626
  auto?: string;
@@ -687,4 +768,4 @@ declare function useMediaQuery(query: string): boolean;
687
768
 
688
769
  declare function cn(...inputs: ClassValue[]): string;
689
770
 
690
- export { type AutoplayState, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorLabels, type AvatarEditorProps, type BlocksLanguage, ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps, DEFAULT_EDITABLE_SECTION_LABELS, DataList, DataListItem, type DataListItemProps, type DataListProps, type DescribedPlaybackError, EditableSection, type EditableSectionLabels, type EditableSectionMode, type EditableSectionProps, type EditableSectionSlots, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, type EmptyStateProps, EmptyTitle, ErrorState, FeedVideoPlayer, type FeedVideoPlayerProps, FieldMessage, type FieldMessageProps, type HlsPlayerMode, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, LoadingState, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type QualityLevel, SafeImage, type SafeImageProps, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, type UseEditableSectionOptions, type UseEditableSectionResult, type UseFeedExclusivePlaybackResult, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery, usePlaybackStats };
771
+ export { type AutoplayState, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorLabels, type AvatarEditorProps, type BlocksLanguage, ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps, type CurtainKind, CurtainStage, type CurtainStageProps, DEFAULT_EDITABLE_SECTION_LABELS, DataList, DataListItem, type DataListItemProps, type DataListProps, type DescribedPlaybackError, EditableSection, type EditableSectionLabels, type EditableSectionMode, type EditableSectionProps, type EditableSectionSlots, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, type EmptyStateProps, EmptyTitle, ErrorState, FeedVideoPlayer, type FeedVideoPlayerProps, FieldMessage, type FieldMessageProps, type HlsPlayerMode, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, LoadingState, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type QualityLevel, SafeImage, type SafeImageProps, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, type UseEditableSectionOptions, type UseEditableSectionResult, type UseFeedExclusivePlaybackResult, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, WaitingRoom, type WaitingRoomCurtain, type WaitingRoomProps, castHlsUrl, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, loadCastSender, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery, usePlaybackStats };
package/dist/index.d.ts CHANGED
@@ -439,6 +439,86 @@ interface AvatarEditorDialogProps {
439
439
  }
440
440
  declare function AvatarEditorDialog({ value, onChange, onSave, displaySize, editorSize, outputSize, placeholder, editLabel, dialogTitle, acceptText, cancelText, savingText, savedText, successMessage, errorMessage, className, editorLabels, }: AvatarEditorDialogProps): React.JSX.Element;
441
441
 
442
+ type CurtainKind = "image" | "video";
443
+ interface CurtainStageProps {
444
+ kind: CurtainKind;
445
+ url: string;
446
+ alt?: string;
447
+ className?: string;
448
+ /** When true, video curtains show a static frame instead of looping. */
449
+ reducedMotion?: boolean;
450
+ }
451
+ /**
452
+ * Waiting-room backdrop: a still image or a muted looping video.
453
+ * Honors `prefers-reduced-motion` (or an explicit `reducedMotion` prop)
454
+ * by freezing video on the first frame.
455
+ */
456
+ declare function CurtainStage({ kind, url, alt, className, reducedMotion, }: CurtainStageProps): React.JSX.Element;
457
+
458
+ interface WaitingRoomCurtain {
459
+ kind: CurtainKind;
460
+ url: string;
461
+ }
462
+ interface WaitingRoomProps {
463
+ title: string;
464
+ organizationName?: string | null;
465
+ organizationImage?: string | null;
466
+ startsAt?: number | null;
467
+ durationSeconds?: number | null;
468
+ curtain?: WaitingRoomCurtain | null;
469
+ nowMs?: number;
470
+ labels?: {
471
+ startsIn?: string;
472
+ started?: string;
473
+ duration?: (minutes: number) => string;
474
+ };
475
+ className?: string;
476
+ }
477
+ /**
478
+ * Public waiting-room chrome: curtain (or calm branded fallback), title,
479
+ * org avatar, and a countdown to `startsAt`.
480
+ */
481
+ declare function WaitingRoom({ title, organizationName, organizationImage, startsAt, durationSeconds, curtain, nowMs, labels, className, }: WaitingRoomProps): React.JSX.Element;
482
+
483
+ type CastFramework = {
484
+ CastContext: {
485
+ getInstance: () => {
486
+ setOptions: (options: {
487
+ receiverApplicationId: string;
488
+ autoJoinPolicy?: string;
489
+ }) => void;
490
+ requestSession: () => Promise<unknown>;
491
+ getCurrentSession: () => {
492
+ loadMedia: (request: unknown) => Promise<unknown>;
493
+ } | null;
494
+ };
495
+ };
496
+ };
497
+ type ChromeCast = {
498
+ media: {
499
+ DEFAULT_MEDIA_RECEIVER_APP_ID: string;
500
+ MediaInfo: new (url: string, contentType: string) => unknown;
501
+ LoadRequest: new (media: unknown) => unknown;
502
+ };
503
+ AutoJoinPolicy?: {
504
+ ORIGIN_SCOPED: string;
505
+ };
506
+ };
507
+ declare global {
508
+ interface Window {
509
+ cast?: {
510
+ framework?: CastFramework;
511
+ };
512
+ chrome?: {
513
+ cast?: ChromeCast;
514
+ };
515
+ __onGCastApiAvailable?: (available: boolean) => void;
516
+ }
517
+ }
518
+ declare function loadCastSender(): Promise<void>;
519
+ /** Cast an HLS master playlist to the default Chromecast media receiver. */
520
+ declare function castHlsUrl(hlsUrl: string): Promise<void>;
521
+
442
522
  /**
443
523
  * Playback error description, ported from the app's HLS player but stripped of
444
524
  * Sentry. `@livo/blocks` must stay reporting-agnostic: the player surfaces
@@ -540,6 +620,7 @@ interface VideoPlayerLabels {
540
620
  enterFullscreen?: string;
541
621
  exitFullscreen?: string;
542
622
  pictureInPicture?: string;
623
+ cast?: string;
543
624
  settings?: string;
544
625
  quality?: string;
545
626
  auto?: string;
@@ -687,4 +768,4 @@ declare function useMediaQuery(query: string): boolean;
687
768
 
688
769
  declare function cn(...inputs: ClassValue[]): string;
689
770
 
690
- export { type AutoplayState, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorLabels, type AvatarEditorProps, type BlocksLanguage, ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps, DEFAULT_EDITABLE_SECTION_LABELS, DataList, DataListItem, type DataListItemProps, type DataListProps, type DescribedPlaybackError, EditableSection, type EditableSectionLabels, type EditableSectionMode, type EditableSectionProps, type EditableSectionSlots, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, type EmptyStateProps, EmptyTitle, ErrorState, FeedVideoPlayer, type FeedVideoPlayerProps, FieldMessage, type FieldMessageProps, type HlsPlayerMode, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, LoadingState, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type QualityLevel, SafeImage, type SafeImageProps, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, type UseEditableSectionOptions, type UseEditableSectionResult, type UseFeedExclusivePlaybackResult, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery, usePlaybackStats };
771
+ export { type AutoplayState, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorLabels, type AvatarEditorProps, type BlocksLanguage, ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps, type CurtainKind, CurtainStage, type CurtainStageProps, DEFAULT_EDITABLE_SECTION_LABELS, DataList, DataListItem, type DataListItemProps, type DataListProps, type DescribedPlaybackError, EditableSection, type EditableSectionLabels, type EditableSectionMode, type EditableSectionProps, type EditableSectionSlots, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, type EmptyStateProps, EmptyTitle, ErrorState, FeedVideoPlayer, type FeedVideoPlayerProps, FieldMessage, type FieldMessageProps, type HlsPlayerMode, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, LoadingState, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type QualityLevel, SafeImage, type SafeImageProps, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, type UseEditableSectionOptions, type UseEditableSectionResult, type UseFeedExclusivePlaybackResult, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, WaitingRoom, type WaitingRoomCurtain, type WaitingRoomProps, castHlsUrl, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, loadCastSender, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery, usePlaybackStats };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import * as React3 from 'react';
2
+ import * as React5 from 'react';
3
3
  import { createContext, useContext, useState, useRef, useId, useEffect, useCallback, useLayoutEffect } from 'react';
4
- import { Loader2, AlertTriangle, Inbox, Monitor, Sun, Moon, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Settings, PictureInPicture2, Minimize, Maximize, XIcon } from 'lucide-react';
4
+ import { Loader2, AlertTriangle, Inbox, Monitor, Sun, Moon, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Settings, Cast, PictureInPicture2, Minimize, Maximize, XIcon } from 'lucide-react';
5
5
  import { clsx } from 'clsx';
6
6
  import { twMerge } from 'tailwind-merge';
7
7
  import { cva } from 'class-variance-authority';
@@ -1196,7 +1196,7 @@ function Slider({
1196
1196
  max = 100,
1197
1197
  ...props
1198
1198
  }) {
1199
- const _values = React3.useMemo(
1199
+ const _values = React5.useMemo(
1200
1200
  () => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
1201
1201
  [value, defaultValue, min, max]
1202
1202
  );
@@ -2232,6 +2232,177 @@ function AvatarEditorDialog({
2232
2232
  ] }) })
2233
2233
  ] });
2234
2234
  }
2235
+ function usePrefersReducedMotion() {
2236
+ const [reduced, setReduced] = React5.useState(false);
2237
+ React5.useEffect(() => {
2238
+ const media = window.matchMedia("(prefers-reduced-motion: reduce)");
2239
+ const sync = () => setReduced(media.matches);
2240
+ sync();
2241
+ media.addEventListener("change", sync);
2242
+ return () => media.removeEventListener("change", sync);
2243
+ }, []);
2244
+ return reduced;
2245
+ }
2246
+ function CurtainStage({
2247
+ kind,
2248
+ url,
2249
+ alt = "",
2250
+ className,
2251
+ reducedMotion
2252
+ }) {
2253
+ const prefersReduced = usePrefersReducedMotion();
2254
+ const freeze = reducedMotion ?? prefersReduced;
2255
+ if (kind === "video" && !freeze) {
2256
+ return /* @__PURE__ */ jsx(
2257
+ "video",
2258
+ {
2259
+ src: url,
2260
+ className: cn("h-full w-full object-cover", className),
2261
+ autoPlay: true,
2262
+ muted: true,
2263
+ loop: true,
2264
+ playsInline: true,
2265
+ "aria-hidden": alt ? void 0 : true
2266
+ }
2267
+ );
2268
+ }
2269
+ if (kind === "video" && freeze) {
2270
+ return /* @__PURE__ */ jsx(
2271
+ "video",
2272
+ {
2273
+ src: url,
2274
+ className: cn("h-full w-full object-cover", className),
2275
+ muted: true,
2276
+ playsInline: true,
2277
+ preload: "metadata",
2278
+ "aria-hidden": alt ? void 0 : true
2279
+ }
2280
+ );
2281
+ }
2282
+ return /* @__PURE__ */ jsx(
2283
+ "img",
2284
+ {
2285
+ src: url,
2286
+ alt,
2287
+ className: cn("h-full w-full object-cover", className)
2288
+ }
2289
+ );
2290
+ }
2291
+ function formatCountdown(ms) {
2292
+ if (ms <= 0) return "0:00";
2293
+ const total = Math.floor(ms / 1e3);
2294
+ const h = Math.floor(total / 3600);
2295
+ const m = Math.floor(total % 3600 / 60);
2296
+ const s = total % 60;
2297
+ const mm = String(m).padStart(2, "0");
2298
+ const ss = String(s).padStart(2, "0");
2299
+ return h > 0 ? `${h}:${mm}:${ss}` : `${m}:${ss}`;
2300
+ }
2301
+ function WaitingRoom({
2302
+ title,
2303
+ organizationName,
2304
+ organizationImage,
2305
+ startsAt,
2306
+ durationSeconds,
2307
+ curtain,
2308
+ nowMs,
2309
+ labels,
2310
+ className
2311
+ }) {
2312
+ const [now, setNow] = React5.useState(nowMs ?? Date.now());
2313
+ React5.useEffect(() => {
2314
+ if (nowMs != null) {
2315
+ setNow(nowMs);
2316
+ return;
2317
+ }
2318
+ const timer = window.setInterval(() => setNow(Date.now()), 1e3);
2319
+ return () => window.clearInterval(timer);
2320
+ }, [nowMs]);
2321
+ const remaining = startsAt != null ? startsAt - now : null;
2322
+ const durationMinutes = durationSeconds != null ? Math.max(1, Math.round(durationSeconds / 60)) : null;
2323
+ return /* @__PURE__ */ jsxs(
2324
+ "div",
2325
+ {
2326
+ className: cn(
2327
+ "relative flex min-h-[16rem] w-full overflow-hidden rounded-lg bg-zinc-950 text-white",
2328
+ className
2329
+ ),
2330
+ children: [
2331
+ curtain ? /* @__PURE__ */ jsx(
2332
+ CurtainStage,
2333
+ {
2334
+ kind: curtain.kind,
2335
+ url: curtain.url,
2336
+ className: "absolute inset-0"
2337
+ }
2338
+ ) : /* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-gradient-to-br from-zinc-900 to-zinc-950" }),
2339
+ /* @__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: [
2340
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
2341
+ organizationImage ? /* @__PURE__ */ jsx(
2342
+ "img",
2343
+ {
2344
+ src: organizationImage,
2345
+ alt: "",
2346
+ className: "size-10 rounded-lg object-cover"
2347
+ }
2348
+ ) : /* @__PURE__ */ jsx("div", { className: "flex size-10 items-center justify-center rounded-lg bg-white/15 text-sm font-semibold", children: (organizationName ?? title).slice(0, 1).toUpperCase() }),
2349
+ /* @__PURE__ */ jsxs("div", { children: [
2350
+ /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold tracking-tight", children: title }),
2351
+ organizationName ? /* @__PURE__ */ jsx("p", { className: "text-sm text-white/80", children: organizationName }) : null
2352
+ ] })
2353
+ ] }),
2354
+ remaining != null ? /* @__PURE__ */ jsx("p", { className: "text-sm tabular-nums", children: remaining > 0 ? `${labels?.startsIn ?? "Starts in"} ${formatCountdown(remaining)}` : labels?.started ?? "Starting soon" }) : null,
2355
+ durationMinutes != null ? /* @__PURE__ */ jsx("p", { className: "text-xs text-white/70", children: labels?.duration ? labels.duration(durationMinutes) : `${durationMinutes} min` }) : null
2356
+ ] })
2357
+ ]
2358
+ }
2359
+ );
2360
+ }
2361
+
2362
+ // src/components/video/castHls.ts
2363
+ var CAST_SENDER_SRC = "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";
2364
+ var DEFAULT_RECEIVER_ID = "CC1AD845";
2365
+ var loadPromise = null;
2366
+ function loadCastSender() {
2367
+ if (typeof window === "undefined") return Promise.resolve();
2368
+ if (window.cast?.framework && window.chrome?.cast) return Promise.resolve();
2369
+ if (loadPromise) return loadPromise;
2370
+ loadPromise = new Promise((resolve, reject) => {
2371
+ window.__onGCastApiAvailable = (available) => {
2372
+ if (available) resolve();
2373
+ else reject(new Error("Cast API unavailable"));
2374
+ };
2375
+ const existing = document.querySelector(`script[src="${CAST_SENDER_SRC}"]`);
2376
+ if (existing) return;
2377
+ const script = document.createElement("script");
2378
+ script.src = CAST_SENDER_SRC;
2379
+ script.async = true;
2380
+ script.onerror = () => reject(new Error("Cast sender failed to load"));
2381
+ document.head.appendChild(script);
2382
+ });
2383
+ return loadPromise;
2384
+ }
2385
+ async function castHlsUrl(hlsUrl) {
2386
+ await loadCastSender();
2387
+ const framework = window.cast?.framework;
2388
+ const chromeCast = window.chrome?.cast;
2389
+ if (!framework || !chromeCast) {
2390
+ throw new Error("Cast API unavailable");
2391
+ }
2392
+ const context = framework.CastContext.getInstance();
2393
+ context.setOptions({
2394
+ receiverApplicationId: chromeCast.media.DEFAULT_MEDIA_RECEIVER_APP_ID || DEFAULT_RECEIVER_ID,
2395
+ autoJoinPolicy: chromeCast.AutoJoinPolicy?.ORIGIN_SCOPED
2396
+ });
2397
+ if (!context.getCurrentSession()) {
2398
+ await context.requestSession();
2399
+ }
2400
+ const session = context.getCurrentSession();
2401
+ if (!session) throw new Error("No Cast session");
2402
+ const media = new chromeCast.media.MediaInfo(hlsUrl, "application/x-mpegURL");
2403
+ const request = new chromeCast.media.LoadRequest(media);
2404
+ await session.loadMedia(request);
2405
+ }
2235
2406
 
2236
2407
  // src/components/video/hls-config.ts
2237
2408
  function shouldRetryLiveEdge404(retryConfig, retryCount, _isTimeout, loaderResponse, defaultRetry) {
@@ -2411,27 +2582,27 @@ function useHlsPlayback({
2411
2582
  onError,
2412
2583
  onPlayingChange
2413
2584
  }) {
2414
- const videoRef = React3.useRef(null);
2415
- const hlsRef = React3.useRef(null);
2416
- const [state, setState] = React3.useState("idle");
2417
- const [qualities, setQualities] = React3.useState([]);
2418
- const [activeLevel, setActiveLevel] = React3.useState(-1);
2419
- const [autoplayState, setAutoplayState] = React3.useState("none");
2420
- const [error, setError] = React3.useState(null);
2421
- const [reloadKey, setReloadKey] = React3.useState(0);
2422
- const onErrorRef = React3.useRef(onError);
2423
- const onPlayingChangeRef = React3.useRef(onPlayingChange);
2424
- React3.useEffect(() => {
2585
+ const videoRef = React5.useRef(null);
2586
+ const hlsRef = React5.useRef(null);
2587
+ const [state, setState] = React5.useState("idle");
2588
+ const [qualities, setQualities] = React5.useState([]);
2589
+ const [activeLevel, setActiveLevel] = React5.useState(-1);
2590
+ const [autoplayState, setAutoplayState] = React5.useState("none");
2591
+ const [error, setError] = React5.useState(null);
2592
+ const [reloadKey, setReloadKey] = React5.useState(0);
2593
+ const onErrorRef = React5.useRef(onError);
2594
+ const onPlayingChangeRef = React5.useRef(onPlayingChange);
2595
+ React5.useEffect(() => {
2425
2596
  onErrorRef.current = onError;
2426
2597
  onPlayingChangeRef.current = onPlayingChange;
2427
2598
  }, [onError, onPlayingChange]);
2428
- const retry = React3.useCallback(() => {
2599
+ const retry = React5.useCallback(() => {
2429
2600
  setError(null);
2430
2601
  setState("loading");
2431
2602
  setAutoplayState("none");
2432
2603
  setReloadKey((k) => k + 1);
2433
2604
  }, []);
2434
- React3.useEffect(() => {
2605
+ React5.useEffect(() => {
2435
2606
  const media = videoRef.current;
2436
2607
  if (!media || !src || !active) {
2437
2608
  setState("idle");
@@ -2701,7 +2872,7 @@ function useHlsPlayback({
2701
2872
  destroyHls();
2702
2873
  };
2703
2874
  }, [src, mode, active, autoPlay, muted, reloadKey]);
2704
- const setLevel = React3.useCallback((index) => {
2875
+ const setLevel = React5.useCallback((index) => {
2705
2876
  const hls = hlsRef.current;
2706
2877
  if (!hls) return;
2707
2878
  hls.nextLevel = index;
@@ -2726,6 +2897,7 @@ var DEFAULT_LABELS2 = {
2726
2897
  enterFullscreen: "Fullscreen",
2727
2898
  exitFullscreen: "Exit fullscreen",
2728
2899
  pictureInPicture: "Picture in picture",
2900
+ cast: "Cast",
2729
2901
  settings: "Settings",
2730
2902
  quality: "Quality",
2731
2903
  auto: "Auto",
@@ -2786,12 +2958,12 @@ function VideoPlayer({
2786
2958
  className
2787
2959
  }) {
2788
2960
  const t = { ...DEFAULT_LABELS2, ...labels };
2789
- const containerRef = React3.useRef(null);
2790
- const firstPlayFiredRef = React3.useRef(false);
2791
- const [userStarted, setUserStarted] = React3.useState(false);
2961
+ const containerRef = React5.useRef(null);
2962
+ const firstPlayFiredRef = React5.useRef(false);
2963
+ const [userStarted, setUserStarted] = React5.useState(false);
2792
2964
  const active = autoPlay || !poster || userStarted;
2793
2965
  const autoplayActive = autoPlay || userStarted;
2794
- const handlePlayingChange = React3.useCallback(
2966
+ const handlePlayingChange = React5.useCallback(
2795
2967
  (playing) => {
2796
2968
  setIsPlaying(playing);
2797
2969
  if (playing && !firstPlayFiredRef.current) {
@@ -2820,25 +2992,25 @@ function VideoPlayer({
2820
2992
  onError,
2821
2993
  onPlayingChange: handlePlayingChange
2822
2994
  });
2823
- const [isPlaying, setIsPlaying] = React3.useState(false);
2824
- const [isMuted, setIsMuted] = React3.useState(muted);
2825
- const [volume, setVolume] = React3.useState(1);
2826
- const [currentTime, setCurrentTime] = React3.useState(0);
2827
- const [duration, setDuration] = React3.useState(0);
2828
- const [buffered, setBuffered] = React3.useState(0);
2829
- const [isFullscreen, setIsFullscreen] = React3.useState(false);
2830
- const [pipActive, setPipActive] = React3.useState(false);
2831
- const [controlsVisible, setControlsVisible] = React3.useState(true);
2832
- const [playbackRate, setPlaybackRate] = React3.useState(1);
2833
- const [openMenu, setOpenMenu] = React3.useState(
2995
+ const [isPlaying, setIsPlaying] = React5.useState(false);
2996
+ const [isMuted, setIsMuted] = React5.useState(muted);
2997
+ const [volume, setVolume] = React5.useState(1);
2998
+ const [currentTime, setCurrentTime] = React5.useState(0);
2999
+ const [duration, setDuration] = React5.useState(0);
3000
+ const [buffered, setBuffered] = React5.useState(0);
3001
+ const [isFullscreen, setIsFullscreen] = React5.useState(false);
3002
+ const [pipActive, setPipActive] = React5.useState(false);
3003
+ const [controlsVisible, setControlsVisible] = React5.useState(true);
3004
+ const [playbackRate, setPlaybackRate] = React5.useState(1);
3005
+ const [openMenu, setOpenMenu] = React5.useState(
2834
3006
  null
2835
3007
  );
2836
- const [behindLive, setBehindLive] = React3.useState(false);
2837
- const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React3.useState(false);
2838
- const hideTimerRef = React3.useRef(null);
3008
+ const [behindLive, setBehindLive] = React5.useState(false);
3009
+ const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React5.useState(false);
3010
+ const hideTimerRef = React5.useRef(null);
2839
3011
  const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
2840
3012
  const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported;
2841
- React3.useEffect(() => {
3013
+ React5.useEffect(() => {
2842
3014
  const video = videoRef.current;
2843
3015
  if (!video || !active) return;
2844
3016
  const onTimeUpdate = () => {
@@ -2871,20 +3043,21 @@ function VideoPlayer({
2871
3043
  video.removeEventListener("ratechange", onRate);
2872
3044
  };
2873
3045
  }, [videoRef, active, mode]);
2874
- React3.useEffect(() => {
3046
+ React5.useEffect(() => {
2875
3047
  const video = videoRef.current;
2876
3048
  if (!paused || !video || !isPlaying) return;
2877
3049
  video.pause();
2878
3050
  }, [paused, videoRef, isPlaying]);
2879
- React3.useEffect(() => {
3051
+ React5.useEffect(() => {
2880
3052
  setWebkitFullscreenSupported(hasWebkitVideoFullscreen(videoRef.current));
3053
+ videoRef.current?.setAttribute("x-webkit-airplay", "allow");
2881
3054
  }, [videoRef, active]);
2882
- React3.useEffect(() => {
3055
+ React5.useEffect(() => {
2883
3056
  const onFsChange = () => setIsFullscreen(document.fullscreenElement === containerRef.current);
2884
3057
  document.addEventListener("fullscreenchange", onFsChange);
2885
3058
  return () => document.removeEventListener("fullscreenchange", onFsChange);
2886
3059
  }, []);
2887
- React3.useEffect(() => {
3060
+ React5.useEffect(() => {
2888
3061
  const video = asWebkitVideo(videoRef.current);
2889
3062
  if (!video) return;
2890
3063
  const onBegin = () => setIsFullscreen(true);
@@ -2896,7 +3069,7 @@ function VideoPlayer({
2896
3069
  video.removeEventListener("webkitendfullscreen", onEnd);
2897
3070
  };
2898
3071
  }, [videoRef, active]);
2899
- React3.useEffect(() => {
3072
+ React5.useEffect(() => {
2900
3073
  const video = videoRef.current;
2901
3074
  if (!video) return;
2902
3075
  const onEnter = () => setPipActive(true);
@@ -2908,18 +3081,18 @@ function VideoPlayer({
2908
3081
  video.removeEventListener("leavepictureinpicture", onLeave);
2909
3082
  };
2910
3083
  }, [videoRef]);
2911
- const scheduleHide = React3.useCallback(() => {
3084
+ const scheduleHide = React5.useCallback(() => {
2912
3085
  if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
2913
3086
  hideTimerRef.current = setTimeout(() => {
2914
3087
  setControlsVisible(false);
2915
3088
  setOpenMenu(null);
2916
3089
  }, CONTROLS_HIDE_MS);
2917
3090
  }, []);
2918
- const revealControls = React3.useCallback(() => {
3091
+ const revealControls = React5.useCallback(() => {
2919
3092
  setControlsVisible(true);
2920
3093
  scheduleHide();
2921
3094
  }, [scheduleHide]);
2922
- React3.useEffect(() => {
3095
+ React5.useEffect(() => {
2923
3096
  return () => {
2924
3097
  if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
2925
3098
  };
@@ -3290,6 +3463,16 @@ function VideoPlayer({
3290
3463
  ]
3291
3464
  }
3292
3465
  ),
3466
+ /* @__PURE__ */ jsx(
3467
+ ControlButton,
3468
+ {
3469
+ label: t.cast,
3470
+ onClick: () => {
3471
+ void castHlsUrl(src).catch(() => void 0);
3472
+ },
3473
+ children: /* @__PURE__ */ jsx(Cast, { className: "size-5" })
3474
+ }
3475
+ ),
3293
3476
  pipSupported && /* @__PURE__ */ jsx(ControlButton, { label: t.pictureInPicture, onClick: togglePip, children: /* @__PURE__ */ jsx(
3294
3477
  PictureInPicture2,
3295
3478
  {
@@ -3412,16 +3595,16 @@ function videoInPictureInPicture(container) {
3412
3595
  return container.contains(pip);
3413
3596
  }
3414
3597
  function useFeedExclusivePlayback(playbackId) {
3415
- const containerRef = React3.useRef(null);
3416
- const [forcePaused, setForcePaused] = React3.useState(false);
3417
- const requestPause = React3.useCallback(() => {
3598
+ const containerRef = React5.useRef(null);
3599
+ const [forcePaused, setForcePaused] = React5.useState(false);
3600
+ const requestPause = React5.useCallback(() => {
3418
3601
  if (videoInPictureInPicture(containerRef.current)) return;
3419
3602
  setForcePaused(true);
3420
3603
  }, []);
3421
- React3.useEffect(() => {
3604
+ React5.useEffect(() => {
3422
3605
  return registerFeedPlayer(playbackId, requestPause);
3423
3606
  }, [playbackId, requestPause]);
3424
- React3.useEffect(() => {
3607
+ React5.useEffect(() => {
3425
3608
  const node = containerRef.current;
3426
3609
  if (!node || typeof IntersectionObserver === "undefined") return;
3427
3610
  const observer = new IntersectionObserver(
@@ -3437,14 +3620,14 @@ function useFeedExclusivePlayback(playbackId) {
3437
3620
  observer.observe(node);
3438
3621
  return () => observer.disconnect();
3439
3622
  }, [requestPause]);
3440
- React3.useEffect(() => {
3623
+ React5.useEffect(() => {
3441
3624
  const onVisibility = () => {
3442
3625
  if (document.hidden) requestPause();
3443
3626
  };
3444
3627
  document.addEventListener("visibilitychange", onVisibility);
3445
3628
  return () => document.removeEventListener("visibilitychange", onVisibility);
3446
3629
  }, [requestPause]);
3447
- const onPlayingChange = React3.useCallback(
3630
+ const onPlayingChange = React5.useCallback(
3448
3631
  (playing) => {
3449
3632
  if (!playing) return;
3450
3633
  setForcePaused(false);
@@ -3471,7 +3654,7 @@ function FeedVideoPlayer({
3471
3654
  paused: exclusivePaused,
3472
3655
  onPlayingChange: onExclusivePlayingChange
3473
3656
  } = useFeedExclusivePlayback(playbackId);
3474
- const handlePlayingChange = React3.useCallback(
3657
+ const handlePlayingChange = React5.useCallback(
3475
3658
  (playing) => {
3476
3659
  onExclusivePlayingChange(playing);
3477
3660
  onPlayingChange?.(playing);
@@ -3498,8 +3681,8 @@ function FeedVideoPlayer({
3498
3681
  );
3499
3682
  }
3500
3683
  function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {}) {
3501
- const [stats, setStats] = React3.useState({});
3502
- React3.useEffect(() => {
3684
+ const [stats, setStats] = React5.useState({});
3685
+ React5.useEffect(() => {
3503
3686
  if (!statsUrl || !enabled) return;
3504
3687
  let cancelled = false;
3505
3688
  const controller = new AbortController();
@@ -3622,6 +3805,6 @@ function avatarFallbackStyle(name) {
3622
3805
  return getAvatarColors(name);
3623
3806
  }
3624
3807
 
3625
- export { AvatarEditor, AvatarEditorDialog, ConfirmDestructiveDialog, DEFAULT_EDITABLE_SECTION_LABELS, DataList, DataListItem, EditableSection, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, FeedVideoPlayer, FieldMessage, LanguageContext, LanguageSwitcher, LoadingState, SafeImage, ThemeSwitcher, VideoPlayer, avatarFallbackStyle, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, getAvatarColors, getInitials, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery2 as useMediaQuery, usePlaybackStats };
3808
+ export { AvatarEditor, AvatarEditorDialog, ConfirmDestructiveDialog, CurtainStage, DEFAULT_EDITABLE_SECTION_LABELS, DataList, DataListItem, EditableSection, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, FeedVideoPlayer, FieldMessage, LanguageContext, LanguageSwitcher, LoadingState, SafeImage, ThemeSwitcher, VideoPlayer, WaitingRoom, avatarFallbackStyle, castHlsUrl, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, getAvatarColors, getInitials, loadCastSender, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery2 as useMediaQuery, usePlaybackStats };
3626
3809
  //# sourceMappingURL=index.js.map
3627
3810
  //# sourceMappingURL=index.js.map