@xhub-reel/embed 0.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/LICENSE +22 -0
- package/README.md +178 -0
- package/dist/index.d.mts +49 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +9 -0
- package/dist/index.mjs +9 -0
- package/package.json +99 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 XHubReel Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# @xhub-reel/embed
|
|
2
|
+
|
|
3
|
+
> Embeddable video widget for XHubReel
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @xhub-reel/embed
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @xhub-reel/embed
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Peer Dependencies
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install react react-dom hls.js motion lucide-react @tanstack/react-virtual @use-gesture/react zustand
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- 📦 **All-in-One** - Complete video player and feed
|
|
22
|
+
- 🎨 **Customizable** - Theme, colors, features
|
|
23
|
+
- 📱 **Responsive** - Works on any screen size
|
|
24
|
+
- âš¡ **Lightweight** - ~12KB gzipped (excluding peers)
|
|
25
|
+
- 🔌 **Easy Integration** - Single component
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Basic Embed
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { XHubReelEmbed } from '@xhub-reel/embed'
|
|
33
|
+
|
|
34
|
+
function App() {
|
|
35
|
+
return (
|
|
36
|
+
<XHubReelEmbed
|
|
37
|
+
videos={videos}
|
|
38
|
+
width={375}
|
|
39
|
+
height={667}
|
|
40
|
+
/>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### With Configuration
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
<XHubReelEmbed
|
|
49
|
+
videos={videos}
|
|
50
|
+
config={{
|
|
51
|
+
autoPlay: true,
|
|
52
|
+
muted: true,
|
|
53
|
+
loop: true,
|
|
54
|
+
showControls: true,
|
|
55
|
+
showActions: true,
|
|
56
|
+
showOverlay: true,
|
|
57
|
+
theme: 'dark',
|
|
58
|
+
accentColor: '#8B5CF6',
|
|
59
|
+
}}
|
|
60
|
+
onVideoChange={(video) => trackVideo(video.id)}
|
|
61
|
+
onLike={(videoId) => handleLike(videoId)}
|
|
62
|
+
onShare={(videoId) => handleShare(videoId)}
|
|
63
|
+
/>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Single Video
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import { XHubReelPlayer } from '@xhub-reel/embed'
|
|
70
|
+
|
|
71
|
+
<XHubReelPlayer
|
|
72
|
+
video={video}
|
|
73
|
+
autoPlay
|
|
74
|
+
muted
|
|
75
|
+
controls
|
|
76
|
+
/>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Iframe Embed
|
|
80
|
+
|
|
81
|
+
For cross-origin embedding:
|
|
82
|
+
|
|
83
|
+
```html
|
|
84
|
+
<iframe
|
|
85
|
+
src="https://xhubreel.stream/embed?v=VIDEO_ID"
|
|
86
|
+
width="375"
|
|
87
|
+
height="667"
|
|
88
|
+
frameborder="0"
|
|
89
|
+
allow="autoplay; fullscreen"
|
|
90
|
+
allowfullscreen
|
|
91
|
+
></iframe>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Props
|
|
95
|
+
|
|
96
|
+
### XHubReelEmbed
|
|
97
|
+
|
|
98
|
+
| Prop | Type | Default | Description |
|
|
99
|
+
|------|------|---------|-------------|
|
|
100
|
+
| `videos` | `Video[]` | `[]` | Videos to display |
|
|
101
|
+
| `width` | `number \| string` | `'100%'` | Container width |
|
|
102
|
+
| `height` | `number \| string` | `'100%'` | Container height |
|
|
103
|
+
| `config` | `EmbedConfig` | `{}` | Configuration |
|
|
104
|
+
| `onVideoChange` | `(video) => void` | - | Video change callback |
|
|
105
|
+
| `onLike` | `(videoId) => void` | - | Like callback |
|
|
106
|
+
| `onComment` | `(videoId) => void` | - | Comment callback |
|
|
107
|
+
| `onShare` | `(videoId) => void` | - | Share callback |
|
|
108
|
+
| `onSave` | `(videoId) => void` | - | Save callback |
|
|
109
|
+
| `className` | `string` | - | Container class |
|
|
110
|
+
|
|
111
|
+
### EmbedConfig
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
interface EmbedConfig {
|
|
115
|
+
autoPlay?: boolean // Auto-play videos (default: true)
|
|
116
|
+
muted?: boolean // Start muted (default: true)
|
|
117
|
+
loop?: boolean // Loop single video (default: false)
|
|
118
|
+
showControls?: boolean // Show player controls (default: true)
|
|
119
|
+
showActions?: boolean // Show like/comment/share (default: true)
|
|
120
|
+
showOverlay?: boolean // Show video info overlay (default: true)
|
|
121
|
+
theme?: 'dark' | 'light' // Theme (default: 'dark')
|
|
122
|
+
accentColor?: string // Accent color (default: '#8B5CF6')
|
|
123
|
+
preloadCount?: number // Videos to preload (default: 2)
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## CDN Usage
|
|
128
|
+
|
|
129
|
+
```html
|
|
130
|
+
<!-- Include dependencies -->
|
|
131
|
+
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
|
|
132
|
+
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
|
|
133
|
+
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
|
|
134
|
+
|
|
135
|
+
<!-- Include XHubReel Embed -->
|
|
136
|
+
<script src="https://unpkg.com/@xhub-reel/embed"></script>
|
|
137
|
+
|
|
138
|
+
<div id="xhub-reel-player"></div>
|
|
139
|
+
|
|
140
|
+
<script>
|
|
141
|
+
XHubReelEmbed.render('#xhub-reel-player', {
|
|
142
|
+
videos: [...],
|
|
143
|
+
config: {
|
|
144
|
+
autoPlay: true,
|
|
145
|
+
muted: true,
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
</script>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Re-exports
|
|
152
|
+
|
|
153
|
+
For convenience, this package re-exports from other @xhub-reel packages:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
// Components
|
|
157
|
+
export { XHubReelEmbed, XHubReelPlayer } from '@xhub-reel/embed'
|
|
158
|
+
export { VideoFeed, VideoFeedItem } from '@xhub-reel/feed'
|
|
159
|
+
export { VideoPlayer } from '@xhub-reel/player'
|
|
160
|
+
|
|
161
|
+
// Types
|
|
162
|
+
export type { Video, Author, Comment } from '@xhub-reel/core'
|
|
163
|
+
export type { EmbedConfig, EmbedProps } from '@xhub-reel/embed'
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Bundle Size
|
|
167
|
+
|
|
168
|
+
| Bundle | Size (gzip) |
|
|
169
|
+
|--------|-------------|
|
|
170
|
+
| @xhub-reel/embed | ~12KB |
|
|
171
|
+
| + peer dependencies | ~150KB |
|
|
172
|
+
|
|
173
|
+
Note: Peer dependencies are externalized. If already using React, HLS.js, etc., the actual bundle added is only ~12KB.
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT
|
|
178
|
+
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Video } from '@xhub-reel/core';
|
|
2
|
+
export { Author, Comment, Reply, Video, VideoStats } from '@xhub-reel/core';
|
|
3
|
+
export { VideoPlayer, VideoPlayerProps } from '@xhub-reel/player';
|
|
4
|
+
export { VideoFeed, VideoFeedItem, VideoFeedItemProps, VideoFeedProps } from '@xhub-reel/feed';
|
|
5
|
+
export { ActionBar, BottomSheet, IconButton, PlayPauseOverlay, Spinner, Toast } from '@xhub-reel/ui';
|
|
6
|
+
export { VideoGestureHandlers, useVideoGestures } from '@xhub-reel/gestures';
|
|
7
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
interface XHubReelEmbedProps {
|
|
10
|
+
/** Videos to display */
|
|
11
|
+
videos: Video[];
|
|
12
|
+
/** Initial video index */
|
|
13
|
+
initialIndex?: number;
|
|
14
|
+
/** Callback when more videos should be loaded */
|
|
15
|
+
onLoadMore?: () => void;
|
|
16
|
+
/** Whether there are more videos to load */
|
|
17
|
+
hasMore?: boolean;
|
|
18
|
+
/** Loading state */
|
|
19
|
+
isLoading?: boolean;
|
|
20
|
+
/** Callback when a video is liked */
|
|
21
|
+
onLike?: (video: Video) => void;
|
|
22
|
+
/** Callback when comments should be shown */
|
|
23
|
+
onComment?: (video: Video) => void;
|
|
24
|
+
/** Callback when share sheet should be shown */
|
|
25
|
+
onShare?: (video: Video) => void;
|
|
26
|
+
/** Callback when author profile should be shown */
|
|
27
|
+
onAuthorClick?: (video: Video) => void;
|
|
28
|
+
/** Callback when the current video changes */
|
|
29
|
+
onVideoChange?: (video: Video, index: number) => void;
|
|
30
|
+
/** Custom className */
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
declare function XHubReelEmbed({ videos, initialIndex, onLoadMore, hasMore, isLoading, onLike, onComment, onShare, onAuthorClick, onVideoChange, className, }: XHubReelEmbedProps): react_jsx_runtime.JSX.Element;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* createXHubReelEmbed - Factory function for creating embed instances
|
|
37
|
+
* For use in non-React environments (script tag integration)
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
interface XHubReelEmbedOptions extends Omit<XHubReelEmbedProps, 'className'> {
|
|
41
|
+
container: HTMLElement | string;
|
|
42
|
+
}
|
|
43
|
+
interface XHubReelEmbedInstance {
|
|
44
|
+
updateVideos: (videos: XHubReelEmbedProps['videos']) => void;
|
|
45
|
+
destroy: () => void;
|
|
46
|
+
}
|
|
47
|
+
declare function createXHubReelEmbed(options: XHubReelEmbedOptions): XHubReelEmbedInstance;
|
|
48
|
+
|
|
49
|
+
export { XHubReelEmbed, type XHubReelEmbedOptions, type XHubReelEmbedProps, createXHubReelEmbed };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Video } from '@xhub-reel/core';
|
|
2
|
+
export { Author, Comment, Reply, Video, VideoStats } from '@xhub-reel/core';
|
|
3
|
+
export { VideoPlayer, VideoPlayerProps } from '@xhub-reel/player';
|
|
4
|
+
export { VideoFeed, VideoFeedItem, VideoFeedItemProps, VideoFeedProps } from '@xhub-reel/feed';
|
|
5
|
+
export { ActionBar, BottomSheet, IconButton, PlayPauseOverlay, Spinner, Toast } from '@xhub-reel/ui';
|
|
6
|
+
export { VideoGestureHandlers, useVideoGestures } from '@xhub-reel/gestures';
|
|
7
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
interface XHubReelEmbedProps {
|
|
10
|
+
/** Videos to display */
|
|
11
|
+
videos: Video[];
|
|
12
|
+
/** Initial video index */
|
|
13
|
+
initialIndex?: number;
|
|
14
|
+
/** Callback when more videos should be loaded */
|
|
15
|
+
onLoadMore?: () => void;
|
|
16
|
+
/** Whether there are more videos to load */
|
|
17
|
+
hasMore?: boolean;
|
|
18
|
+
/** Loading state */
|
|
19
|
+
isLoading?: boolean;
|
|
20
|
+
/** Callback when a video is liked */
|
|
21
|
+
onLike?: (video: Video) => void;
|
|
22
|
+
/** Callback when comments should be shown */
|
|
23
|
+
onComment?: (video: Video) => void;
|
|
24
|
+
/** Callback when share sheet should be shown */
|
|
25
|
+
onShare?: (video: Video) => void;
|
|
26
|
+
/** Callback when author profile should be shown */
|
|
27
|
+
onAuthorClick?: (video: Video) => void;
|
|
28
|
+
/** Callback when the current video changes */
|
|
29
|
+
onVideoChange?: (video: Video, index: number) => void;
|
|
30
|
+
/** Custom className */
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
declare function XHubReelEmbed({ videos, initialIndex, onLoadMore, hasMore, isLoading, onLike, onComment, onShare, onAuthorClick, onVideoChange, className, }: XHubReelEmbedProps): react_jsx_runtime.JSX.Element;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* createXHubReelEmbed - Factory function for creating embed instances
|
|
37
|
+
* For use in non-React environments (script tag integration)
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
interface XHubReelEmbedOptions extends Omit<XHubReelEmbedProps, 'className'> {
|
|
41
|
+
container: HTMLElement | string;
|
|
42
|
+
}
|
|
43
|
+
interface XHubReelEmbedInstance {
|
|
44
|
+
updateVideos: (videos: XHubReelEmbedProps['videos']) => void;
|
|
45
|
+
destroy: () => void;
|
|
46
|
+
}
|
|
47
|
+
declare function createXHubReelEmbed(options: XHubReelEmbedOptions): XHubReelEmbedInstance;
|
|
48
|
+
|
|
49
|
+
export { XHubReelEmbed, type XHubReelEmbedOptions, type XHubReelEmbedProps, createXHubReelEmbed };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';var ln=require('hls.js'),zustand=require('zustand'),middleware=require('zustand/middleware'),designTokens=require('@xhub-reel/design-tokens'),react=require('react'),react$1=require('motion/react'),jsxRuntime=require('react/jsx-runtime'),react$2=require('@use-gesture/react'),client=require('react-dom/client');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ln__default=/*#__PURE__*/_interopDefault(ln);var Ct={maxBufferLength:30,maxMaxBufferLength:60,maxBufferSize:3e7,maxBufferHole:.5,abrEwmaDefaultEstimate:5e5,abrBandWidthUpFactor:.7,abrBandWidthFactor:.9,startLevel:-1,autoStartLoad:true,startPosition:-1,fragLoadingMaxRetry:3,manifestLoadingMaxRetry:3,levelLoadingMaxRetry:3,fragLoadingTimeOut:2e4,manifestLoadingTimeOut:1e4,levelLoadingTimeOut:1e4,lowLatencyMode:false,liveSyncDuration:3};var Je={ACTIVATION_THRESHOLD:.5,DEACTIVATION_THRESHOLD:.3},Re={MAX_VIDEOS_IN_DOM:5,MAX_DECODED_FRAMES:3,MAX_TOTAL_MEMORY:150*1024*1024},Ne={HEIGHT_DEFAULT:2,HEIGHT_ACTIVE:4};var kt={PLAYER_PREFERENCES:"xhub-reel-player"};var Kt={isMuted:true,volume:1,playbackSpeed:1,quality:"auto"},_e=zustand.create()(middleware.persist(e=>({...Kt,toggleMute:()=>e(t=>({isMuted:!t.isMuted})),setMuted:t=>e({isMuted:t}),setVolume:t=>e({volume:Math.max(0,Math.min(1,t)),isMuted:t===0}),setPlaybackSpeed:t=>e({playbackSpeed:t}),setQuality:t=>e({quality:t}),resetPreferences:()=>e(Kt)}),{name:kt.PLAYER_PREFERENCES}));var jt={videos:[],currentIndex:0,isLoading:false,hasMore:true,error:null},Lt=zustand.create(e=>({...jt,setVideos:t=>e({videos:t,currentIndex:0}),appendVideos:t=>e(n=>({videos:[...n.videos,...t]})),setCurrentIndex:t=>e({currentIndex:t}),goToNext:()=>e(t=>({currentIndex:Math.min(t.currentIndex+1,t.videos.length-1)})),goToPrevious:()=>e(t=>({currentIndex:Math.max(t.currentIndex-1,0)})),removeVideo:t=>e(n=>{let r=n.videos.filter(s=>s.id!==t),o=Math.min(n.currentIndex,r.length-1);return {videos:r,currentIndex:Math.max(0,o)}}),setLoading:t=>e({isLoading:t}),setHasMore:t=>e({hasMore:t}),setError:t=>e({error:t}),reset:()=>e(jt)}));function Y(...e){return Object.assign({},...e.filter(Boolean))}var Ue={flex:(e={})=>({display:"flex",flexDirection:e.direction,alignItems:e.align,justifyContent:e.justify,gap:typeof e.gap=="number"?e.gap:designTokens.spacing[e.gap||0],flexWrap:e.wrap}),flexCenter:{display:"flex",alignItems:"center",justifyContent:"center"},flexBetween:{display:"flex",alignItems:"center",justifyContent:"space-between"},flexColumn:{display:"flex",flexDirection:"column"},grid:(e={})=>({display:"grid",gridTemplateColumns:typeof e.columns=="number"?`repeat(${e.columns}, 1fr)`:e.columns,gridTemplateRows:typeof e.rows=="number"?`repeat(${e.rows}, 1fr)`:e.rows,gap:typeof e.gap=="number"?e.gap:designTokens.spacing[e.gap||0]}),absolute:(e={})=>({position:"absolute",...e.inset!==void 0&&{inset:e.inset},...e.top!==void 0&&{top:e.top},...e.right!==void 0&&{right:e.right},...e.bottom!==void 0&&{bottom:e.bottom},...e.left!==void 0&&{left:e.left}}),fixed:(e={})=>({position:"fixed",...e.inset!==void 0&&{inset:e.inset},...e.top!==void 0&&{top:e.top},...e.right!==void 0&&{right:e.right},...e.bottom!==void 0&&{bottom:e.bottom},...e.left!==void 0&&{left:e.left}}),fullScreen:{position:"fixed",inset:0,width:"100%",height:"100%"},fullSize:{width:"100%",height:"100%"},centerAbsolute:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}};({heading:{fontSize:designTokens.fontSizes.xl,fontWeight:designTokens.fontWeights.bold,color:designTokens.colors.text},body:{fontSize:designTokens.fontSizes.md,fontWeight:designTokens.fontWeights.normal,color:designTokens.colors.text},caption:{fontSize:designTokens.fontSizes.xs,fontWeight:designTokens.fontWeights.normal,color:designTokens.colors.textSecondary},videoText:{color:designTokens.colors.text,textShadow:designTokens.shadows.text}});var Ie={bg:e=>({backgroundColor:e in designTokens.colors?designTokens.colors[e]:e}),rounded:(e="md")=>({borderRadius:designTokens.radii[e]}),border:(e={})=>({borderWidth:e.width||1,borderStyle:e.style||"solid",borderColor:e.color?e.color in designTokens.colors?designTokens.colors[e.color]:e.color:designTokens.colors.border}),shadow:(e="md")=>({boxShadow:designTokens.shadows[e]}),opacity:e=>({opacity:e}),glass:(e=20)=>({backgroundColor:designTokens.colors.overlay,backdropFilter:`blur(${e}px)`,WebkitBackdropFilter:`blur(${e}px)`}),glassLight:(e=10)=>({backgroundColor:designTokens.colors.overlayLight,backdropFilter:`blur(${e}px)`,WebkitBackdropFilter:`blur(${e}px)`})},en={clickable:{cursor:"pointer",userSelect:"none"}},tn={transition:(e="all",t="normal",n="xhubReel")=>({transitionProperty:Array.isArray(e)?e.join(", "):e,transitionDuration:designTokens.durations[t],transitionTimingFunction:designTokens.easings[n]}),noTransition:{transition:"none"}},Qe={scrollY:{overflowY:"auto",overflowX:"hidden",WebkitOverflowScrolling:"touch"},hideScrollbar:{scrollbarWidth:"none",msOverflowStyle:"none"},snapY:{scrollSnapType:"y mandatory",overscrollBehaviorY:"contain"},snapStart:{scrollSnapAlign:"start",scrollSnapStop:"always"}};var nn={square:e=>({width:e,height:e}),width:e=>({width:e}),height:e=>({height:e}),minHeight:e=>({minHeight:e}),maxWidth:e=>({maxWidth:e})};({feedContainer:Y(Ue.fixed({inset:0}),Qe.scrollY,Qe.snapY,Qe.hideScrollbar,Ie.bg("background"),{touchAction:"pan-y"}),feedItem:Y(Ue.fullSize,Qe.snapStart,Ie.bg("background"),{position:"relative"}),actionButton:Y(Ue.flexCenter,nn.square(48),Ie.rounded("full"),en.clickable,tn.transition(["transform","background-color"])),bottomSheet:Y(Ue.fixed({left:0,right:0,bottom:0}),Ie.glass(),Ie.rounded("xl"),{borderBottomLeftRadius:0,borderBottomRightRadius:0})});var rn=class{callbacks={};currentInfo;constructor(){this.currentInfo=this.detectNetwork(),this.setupListeners();}detectNetwork(){let e=navigator.connection;return {online:navigator.onLine,effectiveType:e?.effectiveType??"unknown",downlink:e?.downlink??null,rtt:e?.rtt??null,saveData:e?.saveData??false,type:e?.type??"unknown"}}setupListeners(){window.addEventListener("online",this.handleOnline),window.addEventListener("offline",this.handleOffline);let e=navigator.connection;e&&e.addEventListener("change",this.handleConnectionChange);}handleOnline=()=>{this.currentInfo={...this.currentInfo,online:true},this.callbacks.onOnline?.(),this.callbacks.onNetworkChange?.(this.currentInfo);};handleOffline=()=>{this.currentInfo={...this.currentInfo,online:false},this.callbacks.onOffline?.(),this.callbacks.onNetworkChange?.(this.currentInfo);};handleConnectionChange=()=>{this.currentInfo=this.detectNetwork(),this.callbacks.onNetworkChange?.(this.currentInfo);};subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getInfo(){return this.currentInfo}isSlowNetwork(){let{effectiveType:e}=this.currentInfo;return e==="slow-2g"||e==="2g"}getRecommendedConfig(){let{effectiveType:e,saveData:t}=this.currentInfo;return t||e==="slow-2g"||e==="2g"?{maxBufferLength:10,maxMaxBufferLength:20,startLevel:0}:e==="3g"?{maxBufferLength:20,maxMaxBufferLength:40,startLevel:1}:{}}estimateDownloadTime(e){let{downlink:t}=this.currentInfo;if(!t||t===0)return 1/0;let n=t*1e6/8;return e/n}destroy(){window.removeEventListener("online",this.handleOnline),window.removeEventListener("offline",this.handleOffline);let e=navigator.connection;e&&e.removeEventListener("change",this.handleConnectionChange);}};var on=class{callbacks={};currentInfo={batteryLevel:null,isCharging:false,isLowPowerMode:false};battery=null;constructor(){this.initBattery();}async initBattery(){try{let e=navigator;e.getBattery&&(this.battery=await e.getBattery(),this.updateInfo(),this.setupListeners());}catch{}}updateInfo(){this.battery&&(this.currentInfo={batteryLevel:this.battery.level,isCharging:this.battery.charging,isLowPowerMode:this.battery.level<.2},this.callbacks.onPowerChange?.(this.currentInfo),this.currentInfo.batteryLevel!==null&&this.currentInfo.batteryLevel<.15&&this.callbacks.onLowBattery?.());}setupListeners(){this.battery&&(this.battery.addEventListener("levelchange",()=>this.updateInfo()),this.battery.addEventListener("chargingchange",()=>this.updateInfo()));}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getInfo(){return this.currentInfo}isPowerSaving(){return this.currentInfo.isLowPowerMode&&!this.currentInfo.isCharging}getRecommendedConfig(){return this.isPowerSaving()?{maxBufferLength:15,capLevelToPlayerSize:true}:{}}destroy(){this.callbacks={};}};var sn=class{queue=[];preloaded=new Set;loading=new Set;callbacks={};options;paused=false;velocityThreshold=2e3;constructor(e={}){this.options={maxConcurrent:e.maxConcurrent??2,maxQueue:e.maxQueue??5};}enqueue(e){let t=e.id??e.url;if(!(this.preloaded.has(e.url)||this.queue.some(n=>n.url===e.url))){if(this.queue.length>=this.options.maxQueue){let n=this.queue.shift();n&&this.callbacks.onPreloadCancel?.(n);}this.queue.push({...e,id:t,status:"pending"}),this.queue.sort((n,r)=>r.priority-n.priority),this.processQueue();}}enqueueMany(e){e.forEach(t=>this.enqueue(t));}cancel(e){let t=this.queue.find(n=>n.url===e);t&&(this.queue=this.queue.filter(n=>n.url!==e),this.loading.delete(t.id),this.callbacks.onPreloadCancel?.(t));}cancelAll(){this.queue.forEach(e=>{this.callbacks.onPreloadCancel?.(e);}),this.queue=[],this.loading.clear();}add(e,t,n=0){this.enqueue({id:e,url:t,priority:n});}remove(e){this.queue=this.queue.filter(t=>t.id!==e),this.loading.delete(e);}clear(){this.cancelAll(),this.preloaded.clear();}setPaused(e){this.paused=e,e||this.processQueue();}handleScrollVelocity(e){Math.abs(e)>this.velocityThreshold?this.setPaused(true):this.setPaused(false);}isPreloaded(e){return this.preloaded.has(e)}getStatus(e){let t=this.queue.find(n=>n.url===e);return t?t.status:this.preloaded.has(e)?"loaded":null}getAllStatuses(){return this.queue.map(e=>e.status)}getPreloadedUrls(){return Array.from(this.preloaded)}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}processQueue(){if(!this.paused)for(;this.loading.size<this.options.maxConcurrent&&this.queue.some(e=>e.status==="pending");){let e=this.queue.find(t=>t.status==="pending");e&&this.preloadItem(e);}}async preloadItem(e){e.status="loading",this.loading.add(e.id),this.callbacks.onPreloadStart?.(e);try{let t=document.createElement("link");t.rel="preload",t.as="fetch",t.href=e.url,t.crossOrigin="anonymous",document.head.appendChild(t),await new Promise((n,r)=>{t.onload=()=>n(),t.onerror=()=>r(new Error("Preload failed"));}),e.status="loaded",this.preloaded.add(e.url),this.callbacks.onPreloadComplete?.(e);}catch(t){e.status="error",this.callbacks.onPreloadError?.(e,t);}finally{this.loading.delete(e.id),this.processQueue();}}destroy(){this.clear(),this.callbacks={};}};var an=class{metrics=this.createEmptyMetrics();callbacks={};bufferingStartTime=null;playStartTime=null;isPlaying=false;createEmptyMetrics(){return {videoId:null,sessionStartTime:null,playbackStartTime:null,totalPlayTime:0,totalBufferingTime:0,bufferingCount:0,qualitySwitches:[],errors:[],seeks:[],avgBitrate:0,startupTime:null}}startSession(e,t){this.metrics={...this.createEmptyMetrics(),videoId:e,sessionStartTime:Date.now()},this.notifyUpdate();}endSession(){this.isPlaying&&this.playStartTime&&(this.metrics.totalPlayTime+=Date.now()-this.playStartTime),this.isPlaying=false,this.playStartTime=null;let e={...this.metrics};return this.callbacks.onSessionEnd?.(e),e}trackFirstFrame(){this.metrics.sessionStartTime&&!this.metrics.playbackStartTime&&(this.metrics.playbackStartTime=Date.now(),this.metrics.startupTime=this.metrics.playbackStartTime-this.metrics.sessionStartTime,this.isPlaying=true,this.playStartTime=Date.now(),this.notifyUpdate());}trackBuffering(e){let t=Date.now();e&&!this.bufferingStartTime?(this.bufferingStartTime=t,this.metrics.bufferingCount++):!e&&this.bufferingStartTime&&(this.metrics.totalBufferingTime+=t-this.bufferingStartTime,this.bufferingStartTime=null),this.notifyUpdate();}trackQualitySwitch(e,t,n){this.metrics.qualitySwitches.push({timestamp:Date.now(),fromLevel:e,toLevel:t,automatic:n}),this.notifyUpdate();}trackError(e,t,n){let r=typeof e=="string"?e:e.message;this.metrics.errors.push({timestamp:Date.now(),message:r,recoverable:t}),this.notifyUpdate();}trackBitrate(e){this.metrics.avgBitrate=e,this.notifyUpdate();}trackReplay(){this.playStartTime=Date.now(),this.isPlaying=true,this.notifyUpdate();}trackSeek(e,t,n){this.metrics.seeks.push({timestamp:Date.now(),from:e,to:t,latency:n}),this.notifyUpdate();}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getMetrics(){return {...this.metrics}}notifyUpdate(){this.callbacks.onMetricsUpdate?.(this.getMetrics());}destroy(){this.endSession(),this.callbacks={};}};var Rt=class hn{hls=null;video=null;options;retryCount=0;maxRetries=3;constructor(t={}){this.options=t;}static isSupported(){return ln__default.default.isSupported()}attach(t,n){if(this.destroy(),this.video=t,this.retryCount=0,!hn.isSupported()){this.options.callbacks?.onError?.(new Error("HLS.js is not supported in this browser"),false);return}this.options.callbacks?.onStateChange?.("loading"),this.hls=new ln__default.default({...Ct,...this.options.config}),this.setupHLSListeners(),this.setupVideoListeners(),this.hls.attachMedia(t),this.hls.loadSource(n);}loadSource(t){if(!this.hls||!this.video)throw new Error("HLS engine not attached to video element");this.retryCount=0,this.options.callbacks?.onStateChange?.("loading"),this.hls.loadSource(t);}destroy(){this.video&&(this.removeVideoListeners(),this.video=null),this.hls&&(this.hls.destroy(),this.hls=null);}getQualityLevels(){return this.hls?this.hls.levels.map(t=>({label:`${t.height}p`,height:t.height,bitrate:t.bitrate})):[]}setQuality(t){this.hls&&(this.hls.currentLevel=t);}getCurrentQuality(){return this.hls?.currentLevel??-1}getBandwidth(){return this.hls?.bandwidthEstimate??0}isAutoQuality(){return this.hls?.autoLevelEnabled??true}startLoad(t){this.hls?.startLoad(t);}stopLoad(){this.hls?.stopLoad();}setupHLSListeners(){this.hls&&(this.hls.on(ln.Events.MANIFEST_PARSED,(t,n)=>{let r=this.getQualityLevels();this.options.callbacks?.onQualityLevelsLoaded?.(r),this.options.callbacks?.onStateChange?.("ready"),this.video?.autoplay&&this.video.play().catch(()=>{});}),this.hls.on(ln.Events.LEVEL_SWITCHED,(t,n)=>{this.options.callbacks?.onQualityChange?.(n.level,this.isAutoQuality());}),this.hls.on(ln.Events.FRAG_LOADED,()=>{this.options.callbacks?.onBandwidthUpdate?.(this.getBandwidth());}),this.hls.on(ln.Events.ERROR,(t,n)=>{this.handleError(n);}));}setupVideoListeners(){this.video&&(this.video.addEventListener("playing",this.handlePlaying),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("canplay",this.handleCanPlay),this.video.addEventListener("error",this.handleVideoError));}removeVideoListeners(){this.video&&(this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("canplay",this.handleCanPlay),this.video.removeEventListener("error",this.handleVideoError));}handlePlaying=()=>{this.options.callbacks?.onStateChange?.("playing");};handlePause=()=>{this.options.callbacks?.onStateChange?.("paused");};handleWaiting=()=>{this.options.callbacks?.onStateChange?.("buffering");};handleEnded=()=>{this.options.callbacks?.onStateChange?.("ended");};handleCanPlay=()=>{this.video?.paused&&this.options.callbacks?.onStateChange?.("ready");};handleVideoError=()=>{let t=this.video?.error;this.options.callbacks?.onError?.(new Error(t?.message??"Video playback error"),false),this.options.callbacks?.onStateChange?.("error");};handleError(t){if(t.fatal){let n=false;switch(t.type){case ln.ErrorTypes.NETWORK_ERROR:this.retryCount<this.maxRetries&&(this.retryCount++,console.warn(`[HLSEngine] Network error, retry ${this.retryCount}/${this.maxRetries}`),this.hls?.startLoad(),n=true);break;case ln.ErrorTypes.MEDIA_ERROR:console.warn("[HLSEngine] Media error, attempting recovery"),this.hls?.recoverMediaError(),n=true;break}n?this.options.callbacks?.onError?.(new Error(`HLS error (recovering): ${t.details}`),true):(this.options.callbacks?.onError?.(new Error(`HLS fatal error: ${t.details}`),false),this.options.callbacks?.onStateChange?.("error"),this.destroy());}else console.warn("[HLSEngine] Non-fatal error:",t.details);}};async function pn(e,t={}){try{return await e.play(),{success:!0}}catch(n){let r=n;if(r.name==="NotAllowedError"){e.muted=true;try{return await e.play(),{success:!0,mutedAutoplay:!0}}catch{return t.onNeedsUserGesture?.(),{success:false,reason:"user_gesture_required"}}}return {success:false,reason:"unknown",error:r}}}var cn=[.5,1,1.5,2],rt=class It{video=null;options;lastQuality=null;bandwidthSamples=[];constructor(t={}){this.options=t;}static isSupported(){return typeof document>"u"?false:document.createElement("video").canPlayType("application/vnd.apple.mpegurl")!==""}static isIOS(){return typeof navigator>"u"?false:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}attach(t,n){this.destroy(),this.video=t,this.options.callbacks?.onStateChange?.("loading"),this.setupVideoListeners(),t.src=n,t.load();}loadSource(t){if(!this.video)throw new Error("Native HLS not attached to video element");this.options.callbacks?.onStateChange?.("loading"),this.video.src=t,this.video.load();}async play(){return this.video?pn(this.video,{onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture}):{success:false,reason:"unknown"}}destroy(){this.video&&(this.removeVideoListeners(),this.video.removeAttribute("src"),this.video.load(),this.video=null),this.bandwidthSamples=[],this.lastQuality=null;}getQualityLevels(){let t=this.estimateCurrentQuality(),n=[{label:"Auto",height:0,bitrate:0}];return t&&n.push(t),n}setQuality(t){console.warn("[NativeHLS] Quality selection not supported, using auto");}getCurrentQuality(){return -1}estimateCurrentQuality(){if(!this.video||this.video.videoHeight===0)return null;let t=this.video.videoHeight,n=this.estimateBitrate();return {label:`${t}p`,height:t,bitrate:n}}estimateBitrate(){if(this.bandwidthSamples.length>0){let n=this.bandwidthSamples.reduce((r,o)=>r+o,0);return Math.round(n/this.bandwidthSamples.length)}if(!this.video)return 0;let t=this.video.videoHeight;return t>=1080?5e6:t>=720?25e5:t>=480?1e6:t>=360?5e5:25e4}getBandwidth(){return this.estimateBitrate()}isAutoQuality(){return true}startLoad(){this.video?.load();}stopLoad(){this.video&&(this.video.preload="none");}async enterFullscreen(){let t=this.video;if(t){if(t.requestFullscreen){await t.requestFullscreen();return}t.webkitEnterFullscreen&&await t.webkitEnterFullscreen();}}async exitFullscreen(){let t=this.video;if(t){if(document.exitFullscreen){await document.exitFullscreen();return}t.webkitExitFullscreen&&await t.webkitExitFullscreen();}}isFullscreen(){let t=this.video;return t?document.fullscreenElement?document.fullscreenElement===t:t.webkitDisplayingFullscreen??false:false}isFullscreenSupported(){let t=this.video;return t?!!(t.requestFullscreen||t.webkitSupportsFullscreen):false}isPlaybackRateSupported(t){return It.isIOS()?cn.includes(t):t>=.5&&t<=2}getSupportedPlaybackRates(){return It.isIOS()?[...cn]:[.5,.75,1,1.25,1.5,2]}setupVideoListeners(){this.video&&(this.video.addEventListener("loadedmetadata",this.handleLoadedMetadata),this.video.addEventListener("playing",this.handlePlaying),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("canplay",this.handleCanPlay),this.video.addEventListener("error",this.handleError),this.video.addEventListener("resize",this.handleResize),this.video.addEventListener("progress",this.handleProgress));}removeVideoListeners(){this.video&&(this.video.removeEventListener("loadedmetadata",this.handleLoadedMetadata),this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("canplay",this.handleCanPlay),this.video.removeEventListener("error",this.handleError),this.video.removeEventListener("resize",this.handleResize),this.video.removeEventListener("progress",this.handleProgress));}handleLoadedMetadata=()=>{let t=this.getQualityLevels();this.options.callbacks?.onQualityLevelsLoaded?.(t),this.options.callbacks?.onStateChange?.("ready"),this.checkQualityChange();};handlePlaying=()=>{this.options.callbacks?.onStateChange?.("playing");};handlePause=()=>{this.options.callbacks?.onStateChange?.("paused");};handleWaiting=()=>{this.options.callbacks?.onStateChange?.("buffering");};handleEnded=()=>{this.options.callbacks?.onStateChange?.("ended");};handleCanPlay=()=>{this.video?.paused&&this.options.callbacks?.onStateChange?.("ready");};handleError=()=>{let t=this.video?.error,n=t?.message??"Video playback error",r=t?.code!==MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED;this.options.callbacks?.onError?.(new Error(n),r),this.options.callbacks?.onStateChange?.("error");};handleResize=()=>{this.checkQualityChange();};handleProgress=()=>{this.updateBandwidthEstimate();};checkQualityChange(){let t=this.estimateCurrentQuality();t&&(!this.lastQuality||this.lastQuality.height!==t.height)&&(this.lastQuality=t,this.options.callbacks?.onQualityChange?.(t));}updateBandwidthEstimate(){if(this.video&&typeof performance<"u"&&performance.getEntriesByType){let n=performance.getEntriesByType("resource").filter(r=>r.initiatorType==="video"||r.name.includes(".ts")||r.name.includes(".m3u8"));if(n.length>0){let o=n.slice(-5).filter(s=>s.transferSize>0&&s.duration>0).map(s=>s.transferSize*8/(s.duration/1e3));if(o.length>0){let s=o.reduce((d,u)=>d+u,0)/o.length;this.bandwidthSamples.push(s),this.bandwidthSamples.length>10&&this.bandwidthSamples.shift(),this.options.callbacks?.onBandwidthUpdate?.(s);}}}}},fn=class{engine=null;video=null;options;isNative=false;animationFrameId=null;isTracking=false;networkDetector=null;powerManager=null;preloadManager=null;analytics=null;cleanupFunctions=[];wasPlayingBeforeOffline=false;wasPlayingBeforeLowBattery=false;constructor(e={}){this.options={enableNetworkAdaptation:true,enablePowerAdaptation:true,enableAnalytics:false,...e},this.isNative=this.shouldUseNative(),this.initializeServices();}static isSupported(){return Rt.isSupported()||rt.isSupported()}attach(e,t,n){this.video=e,this.destroyEngine(),this.setupVideoListeners(),this.analytics&&n&&this.analytics.startSession(n,e);let r=this.getAdaptedConfig();this.isNative?this.engine=new rt({callbacks:{onStateChange:this.options.callbacks?.onStateChange,onError:this.options.callbacks?.onError,onQualityLevelsLoaded:this.options.callbacks?.onQualityLevelsLoaded,onBandwidthUpdate:this.options.callbacks?.onBandwidthUpdate,onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture,onQualityChange:o=>{this.options.callbacks?.onQualityChange?.(-1,o);}}}):this.engine=new Rt({config:r,callbacks:{onStateChange:this.options.callbacks?.onStateChange,onError:this.options.callbacks?.onError,onQualityLevelsLoaded:this.options.callbacks?.onQualityLevelsLoaded,onBandwidthUpdate:this.options.callbacks?.onBandwidthUpdate,onQualityChange:(o,s)=>{let d=this.engine?.getQualityLevels()??[],u=o>=0&&o<d.length?d[o]:void 0;this.options.callbacks?.onQualityChange?.(s?-1:o,u);}}}),this.engine.attach(e,t);}loadSource(e,t){if(!this.engine||!this.video)throw new Error("Player not attached to video element");this.analytics&&(this.analytics.endSession(),t&&this.analytics.startSession(t,this.video)),this.engine.loadSource(e);}destroy(){this.destroyEngine(),this.destroyServices();}async play(){return this.video?this.isNative&&this.engine instanceof rt?this.engine.play():pn(this.video,{onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture}):{success:false,reason:"unknown"}}pause(){this.video?.pause();}async togglePlay(){return this.video?.paused?this.play():(this.pause(),{success:true})}seek(e){if(this.video){let t=this.video.currentTime;this.video.currentTime=Math.max(0,Math.min(e,this.video.duration||0)),this.analytics?.trackSeek(t,e,0);}}seekForward(e=10){this.video&&this.seek(this.video.currentTime+e);}seekBackward(e=10){this.video&&this.seek(this.video.currentTime-e);}getCurrentTime(){return this.video?.currentTime??0}getDuration(){return this.video?.duration??0}setVolume(e){this.video&&(this.video.volume=Math.max(0,Math.min(1,e)));}getVolume(){return this.video?.volume??1}setMuted(e){this.video&&(this.video.muted=e);}isMuted(){return this.video?.muted??true}toggleMute(){this.setMuted(!this.isMuted());}setPlaybackRate(e){this.video&&(this.video.playbackRate=e);}getPlaybackRate(){return this.video?.playbackRate??1}getQualityLevels(){return this.engine?.getQualityLevels()??[]}setQuality(e){let t=this.getCurrentQuality();this.engine?.setQuality(e),t!==e&&this.analytics?.trackQualitySwitch(t,e,e===-1);}getCurrentQuality(){return this.engine?.getCurrentQuality()??-1}isUsingNative(){return this.isNative}getVideoElement(){return this.video}getBuffered(){if(!this.video)return 0;let e=this.video.buffered,t=this.video.currentTime;for(let n=0;n<e.length;n++)if(t>=e.start(n)&&t<=e.end(n))return e.end(n)-t;return 0}getNetworkInfo(){return this.networkDetector?.getInfo()??null}getPowerInfo(){return this.powerManager?.getInfo()??null}getPreloadManager(){return this.preloadManager}getAnalytics(){return this.analytics?.getMetrics()??null}isSlowNetwork(){return this.networkDetector?.isSlowNetwork()??false}isPowerSaving(){return this.powerManager?.isPowerSaving()??false}shouldUseNative(){return this.options.preferNative!==false&&rt.isSupported()?true:!Rt.isSupported()}initializeServices(){if(this.options.enableNetworkAdaptation){this.networkDetector=new rn;let e=this.networkDetector.subscribe({onNetworkChange:this.handleNetworkChange,onOffline:()=>this.options.callbacks?.onError?.(new Error("Network offline"),true)});this.cleanupFunctions.push(e);}if(this.options.enablePowerAdaptation){this.powerManager=new on;let e=this.powerManager.subscribe({onPowerChange:this.handlePowerChange});this.cleanupFunctions.push(e),this.cleanupFunctions.push(()=>this.powerManager?.destroy());}if(this.options.preloadConfig&&(this.preloadManager=new sn(this.options.preloadConfig),this.cleanupFunctions.push(()=>this.preloadManager?.destroy())),this.options.enableAnalytics){this.analytics=new an;let e=this.analytics.subscribe({onMetricsUpdate:t=>this.options.callbacks?.onAnalyticsUpdate?.(t)});this.cleanupFunctions.push(e),this.cleanupFunctions.push(()=>this.analytics?.destroy());}}destroyServices(){this.cleanupFunctions.forEach(e=>e()),this.cleanupFunctions=[],this.networkDetector=null,this.powerManager=null,this.preloadManager=null,this.analytics=null;}destroyEngine(){this.stopProgressTracking(),this.removeVideoListeners(),this.engine&&(this.engine.destroy(),this.engine=null);}getAdaptedConfig(){let e={};return this.networkDetector&&(e={...e,...this.networkDetector.getRecommendedConfig()}),this.powerManager&&(e={...e,...this.powerManager.getRecommendedConfig()}),e}isNetworkBelowThreshold(e,t){let n=["slow-2g","2g","3g","4g","5g","unknown"],r=n.indexOf(e),o=n.indexOf(t);return e==="unknown"?false:r>=0&&r<=o}handleNetworkChange=e=>{this.options.callbacks?.onNetworkChange?.(e);let t=this.options.lowQualityThreshold??"2g",n=this.isNetworkBelowThreshold(e.effectiveType,t);this.options.autoQualityOnNetworkChange&&this.engine&&(n?this.setQuality(0):(e.effectiveType==="4g"||e.effectiveType==="5g")&&this.setQuality(-1)),this.options.autoPauseOnOffline&&!e.online&&(this.wasPlayingBeforeOffline=this.video?!this.video.paused:false,this.pause()),this.options.autoResumeOnOnline&&e.online&&this.wasPlayingBeforeOffline&&(this.play(),this.wasPlayingBeforeOffline=false),this.preloadManager&&this.preloadManager.setPaused(e.effectiveType==="2g"||!e.online);};handlePowerChange=e=>{this.options.callbacks?.onPowerChange?.(e);let t=this.options.lowBatteryThreshold??.15,n=e.batteryLevel!==null&&e.batteryLevel<t;this.options.autoPauseOnLowBattery&&n&&!e.isCharging&&(this.wasPlayingBeforeLowBattery=this.video?!this.video.paused:false,this.pause()),this.wasPlayingBeforeLowBattery&&(e.isCharging||e.batteryLevel!==null&&e.batteryLevel>=t+.05)&&(this.play(),this.wasPlayingBeforeLowBattery=false),this.preloadManager&&e.isLowPowerMode&&this.preloadManager.setPaused(true);};setupVideoListeners(){this.video&&(this.video.addEventListener("timeupdate",this.handleTimeUpdate),this.video.addEventListener("progress",this.handleProgress),this.video.addEventListener("volumechange",this.handleVolumeChange),this.video.addEventListener("ratechange",this.handleRateChange),this.video.addEventListener("play",this.handlePlay),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("playing",this.handlePlaying));}removeVideoListeners(){this.video&&(this.video.removeEventListener("timeupdate",this.handleTimeUpdate),this.video.removeEventListener("progress",this.handleProgress),this.video.removeEventListener("volumechange",this.handleVolumeChange),this.video.removeEventListener("ratechange",this.handleRateChange),this.video.removeEventListener("play",this.handlePlay),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("playing",this.handlePlaying));}handleTimeUpdate=()=>{this.video&&this.options.callbacks?.onTimeUpdate?.(this.video.currentTime,this.video.duration||0);};handleProgress=()=>{this.options.callbacks?.onProgress?.(this.getBuffered());};handleVolumeChange=()=>{this.video&&this.options.callbacks?.onVolumeChange?.(this.video.volume,this.video.muted);};handleRateChange=()=>{this.video&&this.options.callbacks?.onRateChange?.(this.video.playbackRate);};handlePlay=()=>{this.options.enableSmoothTimeUpdates&&this.startProgressTracking();};handlePause=()=>{this.stopProgressTracking();};handleEnded=()=>{this.stopProgressTracking(),this.analytics&&this.analytics.endSession();};handleWaiting=()=>{this.analytics?.trackBuffering(true);};handlePlaying=()=>{this.analytics?.trackBuffering(false),this.analytics?.trackFirstFrame();};startProgressTracking(){if(this.isTracking||!this.video)return;this.isTracking=true;let e=()=>{if(!this.video||this.video.paused||this.video.ended){this.isTracking=false,this.animationFrameId=null;return}this.options.callbacks?.onTimeUpdate?.(this.video.currentTime,this.video.duration||0),this.animationFrameId=requestAnimationFrame(e);};this.animationFrameId=requestAnimationFrame(e);}stopProgressTracking(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.isTracking=false;}},Er=[{from:"idle",to:"loading"},{from:"loading",to:"ready"},{from:"loading",to:"error"},{from:"ready",to:"playing"},{from:"ready",to:"loading"},{from:"ready",to:"error"},{from:"playing",to:"paused"},{from:"playing",to:"buffering"},{from:"playing",to:"ended"},{from:"playing",to:"error"},{from:"playing",to:"loading"},{from:"paused",to:"playing"},{from:"paused",to:"buffering"},{from:"paused",to:"loading"},{from:"paused",to:"error"},{from:"buffering",to:"playing"},{from:"buffering",to:"paused"},{from:"buffering",to:"stalled"},{from:"buffering",to:"error"},{from:"stalled",to:"playing"},{from:"stalled",to:"buffering"},{from:"stalled",to:"error"},{from:"stalled",to:"loading"},{from:"ended",to:"playing"},{from:"ended",to:"loading"},{from:"ended",to:"idle"},{from:"error",to:"loading"},{from:"error",to:"idle"},{from:"*",to:"idle"}],Cr=class{_state="idle";listeners=new Set;stalledTimeout=null;stalledThreshold=3e3;get state(){return this._state}transition(e){if(!this.canTransition(e))return console.warn(`[PlayerStateMachine] Invalid transition: ${this._state} -> ${e}`),false;let n=this._state;return this._state=e,e==="buffering"?this.startStalledTimer():this.clearStalledTimer(),this.listeners.forEach(r=>r(e,n)),true}canTransition(e){let t=Er.find(n=>(n.from===this._state||n.from==="*")&&n.to===e);return !(!t||t.guard&&!t.guard())}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}reset(){this.clearStalledTimer(),this._state="idle";}isPlaying(){return this._state==="playing"}canPlay(){return ["ready","paused","ended"].includes(this._state)}isLoading(){return ["loading","buffering"].includes(this._state)}hasError(){return this._state==="error"}startStalledTimer(){this.clearStalledTimer(),this.stalledTimeout=setTimeout(()=>{this._state==="buffering"&&this.transition("stalled");},this.stalledThreshold);}clearStalledTimer(){this.stalledTimeout&&(clearTimeout(this.stalledTimeout),this.stalledTimeout=null);}};function kr(){return new Cr}function mn(){let e=react.useMemo(()=>kr(),[]),[t,n]=react.useState(e.state);react.useEffect(()=>e.subscribe(d=>{n(d);}),[e]);let r=react.useCallback(s=>e.transition(s),[e]),o=react.useCallback(()=>{e.reset(),n("idle");},[e]);return {state:t,isPlaying:t==="playing",isPaused:t==="paused",isLoading:t==="loading",isBuffering:t==="buffering",isStalled:t==="stalled",isEnded:t==="ended",hasError:t==="error",canPlay:e.canPlay(),transition:r,reset:o}}function gn(e){let{volume:t,isMuted:n,setVolume:r,toggleMute:o,setMuted:s}=_e();react.useEffect(()=>{let i=e.current;i&&(i.volume=t,i.muted=n);},[e,t,n]),react.useEffect(()=>{let i=e.current;if(!i)return;let a=()=>{i.volume!==t&&r(i.volume),i.muted!==n&&s(i.muted);};return i.addEventListener("volumechange",a),()=>i.removeEventListener("volumechange",a)},[e,t,n,r,s]);let d=react.useCallback(i=>{let a=Math.max(0,Math.min(1,i));r(a),e.current&&(e.current.volume=a),a>0&&n&&(s(false),e.current&&(e.current.muted=false));},[e,n,r,s]),u=react.useCallback(()=>{o(),e.current&&(e.current.muted=!n);},[e,n,o]),l=react.useCallback(()=>{n||(s(true),e.current&&(e.current.muted=true));},[e,n,s]),m=react.useCallback(()=>{n&&(s(false),e.current&&(e.current.muted=false));},[e,n,s]);return {volume:t,isMuted:n,setVolume:d,toggleMute:u,mute:l,unmute:m}}function yn(e,t={}){let{enableSmoothTracking:n=false}=t,[r,o]=react.useState(0),[s,d]=react.useState(0),[u,l]=react.useState(0),[m,i]=react.useState([]),a=react.useRef(null),p=react.useRef(false),c=s>0?r/s*100:0,g=react.useCallback(h=>{let y=[],P=h.buffered;for(let C=0;C<P.length;C++)y.push({start:P.start(C),end:P.end(C)});i(y);let O=0;for(let C of y)if(h.currentTime>=C.start&&h.currentTime<=C.end){O=C.end-h.currentTime;break}l(O);},[]),f=react.useCallback(()=>{a.current!==null&&(cancelAnimationFrame(a.current),a.current=null),p.current=false;},[]),S=react.useCallback(()=>{let h=e.current;if(!h||p.current)return;p.current=true;let y=()=>{if(!h||h.paused||h.ended){p.current=false,a.current=null;return}o(h.currentTime),a.current=requestAnimationFrame(y);};a.current=requestAnimationFrame(y);},[e]);react.useEffect(()=>{let h=e.current;if(!h)return;let y=()=>{o(h.currentTime);},P=()=>{d(h.duration||0);},O=()=>{d(h.duration||0);},C=()=>{g(h);},B=()=>{n&&S();},z=()=>{f();},H=()=>{f();},A=()=>{o(h.currentTime);},v=()=>{o(h.currentTime),g(h);};return h.addEventListener("timeupdate",y),h.addEventListener("loadedmetadata",P),h.addEventListener("durationchange",O),h.addEventListener("progress",C),h.addEventListener("play",B),h.addEventListener("pause",z),h.addEventListener("ended",H),h.addEventListener("seeking",A),h.addEventListener("seeked",v),h.readyState>=1&&(d(h.duration||0),o(h.currentTime)),h.readyState>=3&&g(h),!h.paused&&n&&S(),()=>{h.removeEventListener("timeupdate",y),h.removeEventListener("loadedmetadata",P),h.removeEventListener("durationchange",O),h.removeEventListener("progress",C),h.removeEventListener("play",B),h.removeEventListener("pause",z),h.removeEventListener("ended",H),h.removeEventListener("seeking",A),h.removeEventListener("seeked",v),f();}},[e,n,g,S,f]);let b=react.useCallback(h=>{let y=e.current;if(!y||!isFinite(y.duration))return;let P=Math.max(0,Math.min(h,y.duration));y.currentTime=P,o(P);},[e]),V=react.useCallback(h=>{let y=e.current;if(!y||!isFinite(y.duration))return;let O=Math.max(0,Math.min(100,h))/100*y.duration;y.currentTime=O,o(O);},[e]),L=s>0&&isFinite(s);return {currentTime:r,duration:s,buffered:u,progress:c,bufferedRanges:m,seek:b,seekToProgress:V,isSeekable:L,startSmoothTracking:S,stopSmoothTracking:f}}function vn(e){let{quality:t,setQuality:n}=_e(),[r,o]=react.useState(-1),[s,d]=react.useState([]);react.useEffect(()=>{if(!e)return;let i=e.getQualityLevels();d(i),o(e.getCurrentQuality());},[e]),react.useEffect(()=>{if(!(!e||s.length===0))if(t==="auto")e.setQuality(-1),o(-1);else {let i=parseInt(t.replace("p","")),a=s.findIndex(p=>p.height===i);a!==-1&&(e.setQuality(a),o(a));}},[e,t,s]);let u=r===-1,l=react.useCallback(i=>{if(e)if(typeof i=="number")if(e.setQuality(i),o(i),i===-1)n("auto");else {let a=s[i];a&&n(`${a.height}p`);}else n(i);},[e,s,n]),m=react.useCallback(()=>{l("auto");},[l]);return {quality:t,currentLevel:r,availableLevels:s,isAuto:u,setQuality:l,setAuto:m}}function Mt(e){return e<1e3?e.toString():e<1e4?`${(e/1e3).toFixed(1)}K`:e<1e6?`${Math.floor(e/1e3)}K`:`${(e/1e6).toFixed(1)}M`}var Mr={position:"absolute",right:designTokens.spacing[4],bottom:160,display:"flex",flexDirection:"column",alignItems:"center",gap:designTokens.components.actionBar.gap,zIndex:10},Vr={display:"flex",flexDirection:"column",alignItems:"center",gap:designTokens.components.actionBar.iconCountGap,background:"none",border:"none",padding:0,cursor:"pointer"},Ar={width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,display:"flex",alignItems:"center",justifyContent:"center"},Fr={fontSize:designTokens.fontSizes.xs,fontWeight:designTokens.fontWeights.normal,color:designTokens.colors.text,textShadow:designTokens.shadows.text,lineHeight:designTokens.components.actionBar.counterLineHeight,textAlign:"center"},Or={display:"flex",flexDirection:"column",alignItems:"center",position:"relative",width:designTokens.components.profileAction.avatarSize,height:55},bn={width:designTokens.components.profileAction.avatarSize,height:designTokens.components.profileAction.avatarSize,borderRadius:"50%",objectFit:"cover",cursor:"pointer",background:designTokens.colors.surface},Hr={position:"absolute",bottom:0,left:"50%",transform:"translateX(-50%)",width:designTokens.components.profileAction.followButtonSize,height:designTokens.components.profileAction.followButtonSize,borderRadius:"50%",backgroundColor:designTokens.colors.like,border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},Dr=({filled:e,color:t="white"})=>e?jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.74988 11.0538C1.74988 6.75595 4.69822 2.91699 9.20877 2.91699C11.4347 2.91699 12.9986 3.9593 13.9999 4.96978C15.0011 3.95929 16.565 2.91699 18.791 2.91699C23.3015 2.91699 26.2499 6.75595 26.2499 11.0538C26.2499 15.3962 23.6265 18.9036 20.8781 21.3587C18.1288 23.8145 15.1442 25.3171 14.1843 25.6371L13.9999 25.6985L13.8154 25.6371C12.8555 25.3171 9.87093 23.8145 7.12168 21.3587C4.37329 18.9036 1.74988 15.3962 1.74988 11.0538ZM17.7449 6.41699C17.2617 6.41699 16.8699 6.80874 16.8699 7.29199C16.8699 7.77524 17.2617 8.16699 17.7449 8.16699C19.6221 8.16699 20.9952 9.75855 20.9952 11.8241C20.9952 12.3073 21.387 12.6991 21.8702 12.6991C22.3535 12.6991 22.7452 12.3073 22.7452 11.8241C22.7452 9.02543 20.8066 6.41699 17.7449 6.41699Z",fill:t})}):jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx("path",{d:"M15.21 5.5C14.7957 5.5 14.46 5.83579 14.46 6.25C14.46 6.66421 14.7957 7 15.21 7C16.819 7 17.996 8.3642 17.996 10.1346C17.996 10.5488 18.3317 10.8846 18.746 10.8846C19.1602 10.8846 19.496 10.5488 19.496 10.1346C19.496 7.7358 17.8342 5.5 15.21 5.5Z",fill:t}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.89327 2.25C3.85788 2.25 1.24994 5.6858 1.24994 9.47438C1.24994 13.301 3.5604 16.37 5.9378 18.4936C8.31629 20.6183 10.9036 21.9251 11.7628 22.2115L11.9999 22.2906L12.2371 22.2115C13.0963 21.9251 15.6836 20.6183 18.0621 18.4936C20.4395 16.37 22.7499 13.301 22.7499 9.47438C22.7499 5.6858 20.142 2.25 16.1066 2.25C14.2397 2.25 12.8941 3.06969 11.9999 3.91063C11.1058 3.06969 9.76018 2.25 7.89327 2.25ZM2.74994 9.47438C2.74994 6.3142 4.8731 3.75 7.89327 3.75C9.60588 3.75 10.7397 4.66987 11.4269 5.48383L11.9999 6.16259L12.573 5.48383C13.2602 4.66987 14.394 3.75 16.1066 3.75C19.1268 3.75 21.2499 6.3142 21.2499 9.47438C21.2499 12.6733 19.3104 15.3672 17.0628 17.375C15.0361 19.1854 12.8741 20.3336 11.9999 20.6978C11.1257 20.3336 8.96379 19.1854 6.93708 17.375C4.68948 15.3672 2.74994 12.6733 2.74994 9.47438Z",fill:t})]}),Br=()=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsxRuntime.jsx("path",{d:"M14 1.45801C7.07347 1.45801 1.45837 7.0731 1.45837 13.9997C1.45837 16.3815 2.1232 18.6107 3.27778 20.5088L2.36541 23.0178C1.77294 24.6471 3.35258 26.2268 4.98188 25.6343L7.49089 24.7219C9.389 25.8765 11.6182 26.5413 14 26.5413C20.9266 26.5413 26.5417 20.9262 26.5417 13.9997C26.5417 7.0731 20.9266 1.45801 14 1.45801Z",fill:"white"})}),Nr=({filled:e})=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:designTokens.components.actionBar.iconSize,height:designTokens.components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsxRuntime.jsx("path",{d:"M16.6904 1.45801H11.2789C10.2487 1.458 9.4224 1.45799 8.75434 1.51253C8.06795 1.56857 7.47186 1.68652 6.92253 1.96632C6.90122 1.97718 6.88036 1.98891 6.86 2.00147C5.64436 2.75199 4.94533 3.52276 4.62739 4.64643C4.48015 5.1668 4.42512 5.72644 4.40084 6.3243C4.38332 6.75558 4.3811 7.24294 4.37866 7.77623C4.37775 7.97537 4.37678 8.18091 4.375 8.39232V24.8275C4.375 25.7739 5.14242 26.5413 6.08883 26.5413C6.51994 26.5413 6.93517 26.3792 7.25226 26.0859L13.3276 20.4783C13.3386 20.4682 13.3493 20.4578 13.3597 20.4471C13.5821 20.2197 13.743 20.0895 13.8601 20.0183C13.9156 19.9846 13.9524 19.9697 13.9731 19.9631C13.9833 19.9599 13.9898 19.9585 13.9933 19.958L13.9975 19.9575L13.9992 19.9574C13.9992 19.9574 14.0065 19.9571 14.0257 19.9632C14.0466 19.9698 14.0837 19.9849 14.1394 20.0187C14.2569 20.0901 14.4182 20.2206 14.641 20.4479C14.6512 20.4583 14.6616 20.4684 14.6724 20.4783L20.7477 26.0859C21.0648 26.3792 21.4801 26.5413 21.9112 26.5413C22.8576 26.5413 23.625 25.7739 23.625 24.8275V8.3619C23.625 7.33168 23.625 6.5054 23.5705 5.83735C23.5144 5.15096 23.3965 4.55487 23.1167 4.00554C23.1058 3.98416 23.094 3.96325 23.0814 3.94284C22.3309 2.72781 21.5599 2.0287 20.4364 1.71046C19.9159 1.56305 19.3562 1.50785 18.7583 1.48352C18.3245 1.46588 17.8344 1.46376 17.2978 1.46144C17.1014 1.46059 16.8988 1.45968 16.6904 1.45801Z",fill:e?designTokens.colors.warning:"white"})}),_r=()=>jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:28,height:28,viewBox:"0 0 28 28",fill:"none",children:[jsxRuntime.jsx("path",{d:"M20.6583 8.99195C21.1139 8.53634 21.1139 7.79765 20.6583 7.34203L14.8249 1.5087C14.6061 1.28991 14.3094 1.16699 14 1.16699C13.6905 1.16699 13.3938 1.28991 13.175 1.5087L7.34167 7.34204C6.88606 7.79765 6.88606 8.53634 7.34167 8.99195C7.79728 9.44756 8.53597 9.44756 8.99158 8.99195L12.8333 5.15024L12.8333 17.5003C12.8333 18.1447 13.3556 18.667 14 18.667C14.6443 18.667 15.1666 18.1447 15.1666 17.5003L15.1666 5.15024L19.0083 8.99195C19.4639 9.44756 20.2026 9.44756 20.6583 8.99195Z",fill:"white"}),jsxRuntime.jsx("path",{d:"M24.4562 22.2708C24.4991 21.7457 24.5 21.0663 24.5 20.067V16.3337C24.5 15.6893 25.0223 15.167 25.6666 15.167C26.311 15.167 26.8333 15.6893 26.8333 16.3337L26.8333 20.1152C26.8333 21.0543 26.8333 21.8294 26.7817 22.4608C26.7282 23.1166 26.6132 23.7194 26.3247 24.2856C25.8772 25.1637 25.1633 25.8776 24.2852 26.325C23.719 26.6135 23.1162 26.7285 22.4604 26.7821C21.829 26.8337 21.054 26.8337 20.1149 26.8337H7.88508C6.94599 26.8337 6.17087 26.8337 5.5395 26.7821C4.88372 26.7285 4.28089 26.6135 3.71467 26.325C2.83658 25.8776 2.12267 25.1637 1.67526 24.2856C1.38676 23.7194 1.27176 23.1166 1.21819 22.4608C1.1666 21.8294 1.16661 21.0543 1.16663 20.1152V16.3337C1.16663 15.6893 1.68896 15.167 2.33329 15.167C2.97762 15.167 3.49996 15.6893 3.49996 16.3337L3.49996 20.067C3.49996 21.0663 3.50087 21.7457 3.54377 22.2708C3.58556 22.7823 3.66131 23.0438 3.75428 23.2263C3.97798 23.6653 4.33494 24.0223 4.77398 24.246C4.95645 24.339 5.21802 24.4147 5.7295 24.4565C6.25461 24.4994 6.93395 24.5003 7.93329 24.5003H20.0666C21.066 24.5003 21.7453 24.4994 22.2704 24.4565C22.7819 24.4147 23.0435 24.339 23.2259 24.246C23.665 24.0223 24.0219 23.6653 24.2456 23.2263C24.3386 23.0438 24.4144 22.7823 24.4562 22.2708Z",fill:"white"})]}),Ur=()=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:12,height:12,viewBox:"0 0 12 12",fill:"white",children:jsxRuntime.jsx("path",{d:"M6 1V11M1 6H11",stroke:"white",strokeWidth:2,strokeLinecap:"round"})}),Qr=()=>jsxRuntime.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})});function zr({avatarUrl:e,isFollowed:t=false,onClick:n,onFollow:r}){return jsxRuntime.jsxs("div",{style:Or,children:[jsxRuntime.jsx(react$1.motion.button,{style:{background:"none",border:"none",padding:0,cursor:"pointer"},onClick:n,whileTap:{scale:.95},"aria-label":"View profile",children:e?jsxRuntime.jsx("img",{src:e,alt:"Profile",style:bn}):jsxRuntime.jsx("div",{style:bn})}),!t&&r&&jsxRuntime.jsx(react$1.motion.button,{style:Hr,onClick:o=>{o.stopPropagation(),r();},whileTap:{scale:.9},animate:t?{scale:[1,1.2,1]}:{scale:1},transition:{type:"spring",...designTokens.springs.bouncy},"aria-label":t?"Following":"Follow",children:t?jsxRuntime.jsx(Qr,{}):jsxRuntime.jsx(Ur,{})})]})}function it({icon:e,count:t,isActive:n=false,onClick:r,label:o}){return jsxRuntime.jsxs(react$1.motion.button,{style:Vr,onClick:r,"aria-label":o,whileTap:{scale:.9},transition:{type:"spring",...designTokens.springs.bouncy},children:[jsxRuntime.jsx(react$1.motion.div,{style:Ar,animate:n?{scale:[1,1.2,1]}:{scale:1},transition:n?{duration:.3,ease:[.32,.72,0,1]}:{type:"spring",...designTokens.springs.default},children:e}),t!==void 0&&jsxRuntime.jsx("span",{style:Fr,children:Mt(t)})]})}function st({likeCount:e,commentCount:t,shareCount:n,saveCount:r,isLiked:o=false,isSaved:s=false,onLike:d,onComment:u,onShare:l,onSave:m,avatarUrl:i,onProfileClick:a,onFollow:p,isFollowed:c=false,style:g,className:f=""}){return jsxRuntime.jsxs("div",{style:designTokens.mergeStyles(Mr,g),className:f,children:[i&&jsxRuntime.jsx(zr,{avatarUrl:i,isFollowed:c,onClick:a,onFollow:p}),jsxRuntime.jsx(it,{icon:jsxRuntime.jsx(Dr,{filled:o,color:o?designTokens.colors.like:"white"}),count:e,isActive:o,onClick:d,label:o?"Unlike":"Like"}),jsxRuntime.jsx(it,{icon:jsxRuntime.jsx(Br,{}),count:t,onClick:u,label:"Comments"}),jsxRuntime.jsx(it,{icon:jsxRuntime.jsx(Nr,{filled:s}),count:r,isActive:s,onClick:m,label:s?"Unsave":"Save"}),jsxRuntime.jsx(it,{icon:jsxRuntime.jsx(_r,{}),count:n,onClick:l,label:"Share"})]})}var Xr={display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",cursor:"pointer",borderRadius:designTokens.radii.full,transitionProperty:"background-color, transform, opacity",transitionDuration:designTokens.durations.fast,transitionTimingFunction:designTokens.easings.xhubReel,userSelect:"none"},Kr={sm:{width:32,height:32},md:{width:designTokens.components.tapArea,height:designTokens.components.tapArea},lg:{width:56,height:56}},jr={default:{backgroundColor:designTokens.colors.surface,color:designTokens.colors.text},ghost:{backgroundColor:"transparent",color:designTokens.colors.text},glass:{backgroundColor:"rgba(0, 0, 0, 0.2)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",color:designTokens.colors.text}},Zr={opacity:.5,cursor:"not-allowed",pointerEvents:"none"},At=react.forwardRef(({icon:e,size:t="md",variant:n="ghost",disabled:r,style:o,className:s="",...d},u)=>jsxRuntime.jsx("button",{ref:u,type:"button",disabled:r,style:designTokens.mergeStyles(Xr,Kr[t],jr[n],r&&Zr,o),className:s,...d,children:e}));At.displayName="IconButton";var si={position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:designTokens.zIndices.overlay},ai={display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",borderRadius:"50%",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",cursor:"pointer"},li=({size:e})=>jsxRuntime.jsx("svg",{width:e*.4,height:e*.4,viewBox:"0 0 24 24",fill:designTokens.colors.text,children:jsxRuntime.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),di=({size:e})=>jsxRuntime.jsxs("svg",{width:e*.35,height:e*.35,viewBox:"0 0 24 24",fill:designTokens.colors.text,children:[jsxRuntime.jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),jsxRuntime.jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]});function lt({isPlaying:e,show:t,onToggle:n,size:r=72,autoHideDelay:o=1e3,showOnStateChange:s=true,style:d,className:u=""}){let[l,m]=react.useState(false),[i,a]=react.useState(false),p=t!==void 0,c=p?t:l;react.useEffect(()=>{if(!(p||!s||!i)&&(m(true),o>0)){let b=setTimeout(()=>{m(false);},o);return ()=>clearTimeout(b)}},[e,p,s,o,i]);let g=react.useCallback(()=>{n&&(a(true),m(true),n());},[n]),f=!!n,S=f?"auto":"none";return jsxRuntime.jsx(react$1.AnimatePresence,{children:c&&jsxRuntime.jsx(react$1.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},style:designTokens.mergeStyles(si,{pointerEvents:S},d),className:u,onClick:g,children:jsxRuntime.jsx(react$1.motion.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{type:"spring",...designTokens.springs.default},whileTap:f?{scale:.9}:void 0,style:{...ai,width:r,height:r,cursor:f?"pointer":"default"},children:e?jsxRuntime.jsx(di,{size:r}):jsxRuntime.jsx(li,{size:r})})})})}var gi={position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",zIndex:designTokens.zIndices.modal},yi={position:"fixed",left:0,right:0,bottom:0,backgroundColor:designTokens.colors.overlay,backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)",borderTopLeftRadius:designTokens.radii.xl,borderTopRightRadius:designTokens.radii.xl,zIndex:designTokens.zIndices.modal+1,display:"flex",flexDirection:"column",maxHeight:"90vh"},vi={width:designTokens.components.bottomSheet.handleWidth,height:designTokens.components.bottomSheet.handleHeight,backgroundColor:"rgba(255, 255, 255, 0.3)",borderRadius:2,margin:"12px auto 0",flexShrink:0},bi={display:"flex",alignItems:"center",justifyContent:"space-between",padding:`${designTokens.spacing[4]}px ${designTokens.spacing[4]}px ${designTokens.spacing[3]}px`,flexShrink:0},Si={fontSize:18,fontWeight:600,color:designTokens.colors.text},wi={width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",color:designTokens.colors.textSecondary,borderRadius:"50%"},Pi={flex:1,overflow:"auto",WebkitOverflowScrolling:"touch"},Ei=()=>jsxRuntime.jsxs("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]});function xn({isOpen:e,onClose:t,title:n,children:r,height:o="60vh",maxHeight:s="90vh",showClose:d=true,showHandle:u=true,style:l,className:m=""}){let i=react.useCallback(a=>{a.key==="Escape"&&t();},[t]);return react.useEffect(()=>(e&&(document.addEventListener("keydown",i),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",i),document.body.style.overflow="";}),[e,i]),jsxRuntime.jsx(react$1.AnimatePresence,{children:e&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(react$1.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},style:gi,onClick:t}),jsxRuntime.jsxs(react$1.motion.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",...designTokens.springs.default},drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:{top:0,bottom:.5},onDragEnd:(a,p)=>{(p.offset.y>100||p.velocity.y>500)&&t();},style:designTokens.mergeStyles(yi,{height:o,maxHeight:s,touchAction:"none"},l),className:m,children:[u&&jsxRuntime.jsx("div",{style:vi}),(n||d)&&jsxRuntime.jsxs("div",{style:bi,children:[jsxRuntime.jsx("span",{style:Si,children:n}),d&&jsxRuntime.jsx("button",{style:wi,onClick:t,"aria-label":"Close",children:jsxRuntime.jsx(Ei,{})})]}),jsxRuntime.jsx("div",{style:Pi,children:r})]})]})})}function In({size:e=24,color:t=designTokens.colors.text,thickness:n=2,style:r,className:o=""}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{children:`
|
|
2
|
+
@keyframes xhub-reel-spin {
|
|
3
|
+
to { transform: rotate(360deg); }
|
|
4
|
+
}
|
|
5
|
+
`}),jsxRuntime.jsx("div",{role:"status","aria-label":"Loading",style:designTokens.mergeStyles({width:e,height:e,borderWidth:n,borderStyle:"solid",borderColor:`${t}30`,borderTopColor:t,borderRadius:"50%",animation:"xhub-reel-spin 1s linear infinite"},r),className:o})]})}var Oi={position:"fixed",left:designTokens.spacing[4],right:designTokens.spacing[4],zIndex:designTokens.zIndices.toast,display:"flex",justifyContent:"center",pointerEvents:"none"},Hi={display:"flex",alignItems:"center",gap:designTokens.spacing[3],padding:`${designTokens.spacing[3]}px ${designTokens.spacing[4]}px`,backgroundColor:designTokens.colors.surface,borderRadius:designTokens.radii.lg,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.5)",pointerEvents:"auto",maxWidth:400},Di={default:{},success:{borderLeft:`3px solid ${designTokens.colors.success}`},error:{borderLeft:`3px solid ${designTokens.colors.error}`},warning:{borderLeft:`3px solid ${designTokens.colors.warning}`}},Bi={flex:1,fontSize:designTokens.fontSizes.sm,color:designTokens.colors.text,lineHeight:1.4},Ni={padding:`${designTokens.spacing[1]}px ${designTokens.spacing[3]}px`,backgroundColor:"transparent",border:"none",color:designTokens.colors.accent,fontSize:designTokens.fontSizes.sm,fontWeight:600,cursor:"pointer",borderRadius:designTokens.radii.sm};function An({message:e,isVisible:t,onClose:n,duration:r=3e3,variant:o="default",action:s,position:d="bottom",style:u,className:l=""}){react.useEffect(()=>{if(t&&r>0){let i=setTimeout(n,r);return ()=>clearTimeout(i)}},[t,r,n]);let m=d==="top"?{top:designTokens.spacing[4]}:{bottom:designTokens.spacing[4]+80};return jsxRuntime.jsx(react$1.AnimatePresence,{children:t&&jsxRuntime.jsx("div",{style:{...Oi,...m},children:jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:d==="top"?-20:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:d==="top"?-20:20,scale:.95},transition:{type:"spring",...designTokens.springs.default},style:designTokens.mergeStyles(Hi,Di[o],u),className:l,children:[jsxRuntime.jsx("span",{style:Bi,children:e}),s&&jsxRuntime.jsx("button",{style:Ni,onClick:()=>{s.onClick(),n();},children:s.label})]})})})}var Wi={position:"absolute",pointerEvents:"none",zIndex:designTokens.zIndices.overlay},Gi={filter:"drop-shadow(0 4px 8px rgba(255, 45, 85, 0.5))"};function ct(){let[e,t]=react.useState(false),[n,r]=react.useState({x:0,y:0}),o=react.useCallback((d,u)=>{let l=d??(typeof window<"u"?window.innerWidth/2:200),m=u??(typeof window<"u"?window.innerHeight/2:400);r({x:l,y:m}),t(true),setTimeout(()=>{t(false);},800);},[]),s=react.useCallback(()=>{t(false);},[]);return {isShowing:e,position:n,showHeart:o,hideHeart:s}}var $i=({size:e,color:t})=>jsxRuntime.jsx("svg",{style:Gi,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 28 28",fill:t,children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.74988 11.0538C1.74988 6.75595 4.69822 2.91699 9.20877 2.91699C11.4347 2.91699 12.9986 3.9593 13.9999 4.96978C15.0011 3.95929 16.565 2.91699 18.791 2.91699C23.3015 2.91699 26.2499 6.75595 26.2499 11.0538C26.2499 15.3962 23.6265 18.9036 20.8781 21.3587C18.1288 23.8145 15.1442 25.3171 14.1843 25.6371L13.9999 25.6985L13.8154 25.6371C12.8555 25.3171 9.87093 23.8145 7.12168 21.3587C4.37329 18.9036 1.74988 15.3962 1.74988 11.0538ZM17.7449 6.41699C17.2617 6.41699 16.8699 6.80874 16.8699 7.29199C16.8699 7.77524 17.2617 8.16699 17.7449 8.16699C19.6221 8.16699 20.9952 9.75855 20.9952 11.8241C20.9952 12.3073 21.387 12.6991 21.8702 12.6991C22.3535 12.6991 22.7452 12.3073 22.7452 11.8241C22.7452 9.02543 20.8066 6.41699 17.7449 6.41699Z",fill:t})});function ht({show:e,position:t={x:0,y:0},size:n=100,color:r=designTokens.colors.like,showParticles:o=true,particleCount:s=8,onComplete:d,style:u,className:l=""}){return jsxRuntime.jsx(react$1.AnimatePresence,{onExitComplete:d,children:e&&jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,scale:0},animate:{opacity:[0,1,1,0],scale:[0,1.3,1,.8],y:[0,-20,-20,-40]},exit:{scale:0,opacity:0},transition:{duration:.8,times:[0,.2,.6,1],ease:"easeOut"},style:{...Wi,left:t.x-n/2,top:t.y-n/2,width:n,height:n,...u},className:l,children:[jsxRuntime.jsx($i,{size:n,color:r}),o&&[...Array(s)].map((m,i)=>jsxRuntime.jsx(react$1.motion.div,{style:{position:"absolute",width:12,height:12,borderRadius:"50%",backgroundColor:r,left:n/2-6,top:n/2-6},initial:{opacity:1,scale:1},animate:{opacity:0,scale:.5,x:Math.cos(i*Math.PI*2/s)*60,y:Math.sin(i*Math.PI*2/s)*60},transition:{duration:.5,delay:.1,ease:"easeOut"}},i))]})})}function Dn(e){let[t,n]=react.useState(false),r=typeof document<"u"&&!!(document.fullscreenEnabled||document.webkitFullscreenElement!==void 0||document.mozFullScreenElement!==void 0||document.msFullscreenElement!==void 0),o=()=>{let i=document;return i.fullscreenElement||i.webkitFullscreenElement||i.mozFullScreenElement||i.msFullscreenElement||null},s=async i=>{let a=i;a.requestFullscreen?await a.requestFullscreen():a.webkitRequestFullscreen?await a.webkitRequestFullscreen():a.mozRequestFullScreen?await a.mozRequestFullScreen():a.msRequestFullscreen&&await a.msRequestFullscreen();},d=async()=>{let i=document;i.exitFullscreen?await i.exitFullscreen():i.webkitExitFullscreen?await i.webkitExitFullscreen():i.mozCancelFullScreen?await i.mozCancelFullScreen():i.msExitFullscreen&&await i.msExitFullscreen();};react.useEffect(()=>{let i=()=>{let a=o();n(a===e.current);};return document.addEventListener("fullscreenchange",i),document.addEventListener("webkitfullscreenchange",i),document.addEventListener("mozfullscreenchange",i),document.addEventListener("MSFullscreenChange",i),()=>{document.removeEventListener("fullscreenchange",i),document.removeEventListener("webkitfullscreenchange",i),document.removeEventListener("mozfullscreenchange",i),document.removeEventListener("MSFullscreenChange",i);}},[e]);let u=react.useCallback(async()=>{let i=e.current;if(!(!i||!r))try{await s(i),n(!0);let a=screen.orientation;if(a?.lock)try{await a.lock("landscape");}catch{}}catch(a){console.error("[useFullscreen] Failed to enter fullscreen:",a);}},[e,r]),l=react.useCallback(async()=>{if(r)try{await d(),n(!1);let i=screen.orientation;i?.unlock&&i.unlock();}catch(i){console.error("[useFullscreen] Failed to exit fullscreen:",i);}},[r]),m=react.useCallback(async()=>{t?await l():await u();},[t,u,l]);return {isFullscreen:t,isSupported:r,toggleFullscreen:m,enterFullscreen:u,exitFullscreen:l}}var Zi={feed:{autoQualitySwitch:true,pauseOnOffline:false,resumeOnOnline:false,lowQualityOn:"2g"},watch:{autoQualitySwitch:true,pauseOnOffline:false,resumeOnOnline:false,lowQualityOn:"2g"},auto:{autoQualitySwitch:true,pauseOnOffline:true,resumeOnOnline:true,lowQualityOn:"2g"},manual:{autoQualitySwitch:false,pauseOnOffline:false,resumeOnOnline:false}},Ji={aggressive:{autoPauseOnLowBattery:true,pauseThreshold:.2},moderate:{autoPauseOnLowBattery:true,pauseThreshold:.15},conservative:{autoPauseOnLowBattery:true,pauseThreshold:.1},manual:{autoPauseOnLowBattery:false}};function $e(e,t,n={}){let r=react.useRef(null),o=react.useRef(null),s=t??o,[d,u]=react.useState(false),l=mn(),m=gn(e),i=yn(e),a=vn(r.current),p=Dn(s),c=react.useRef(n);c.current=n;let{networkBehavior:g,powerBehavior:f}=n,S=react.useMemo(()=>{if(g)return typeof g=="string"?Zi[g]:g},[g]),b=react.useMemo(()=>{if(f)return typeof f=="string"?Ji[f]:f},[f]),V=react.useMemo(()=>({onStateChange:v=>{l.transition(v),c.current.onStateChange?.(v),v==="ready"&&!d&&(u(true),c.current.onReady?.());},onError:(v,N)=>{c.current.onError?.(v,N);},onTimeUpdate:(v,N)=>{c.current.onTimeUpdate?.(v,N);},onQualityLevelsLoaded:v=>{c.current.onQualityLevelsLoaded?.(v);},onNetworkChange:v=>{S?.onNetworkChange?.(v),c.current.onNetworkChange?.(v);},onPowerChange:v=>{b?.onPowerChange?.(v),c.current.onPowerChange?.(v);},onAnalyticsUpdate:v=>{c.current.onAnalyticsUpdate?.(v);}}),[l,d,S,b]);react.useEffect(()=>{let v=e.current;if(!v)return;let N=()=>c.current.onPlay?.(),X=()=>c.current.onPause?.(),$=()=>c.current.onEnded?.();return v.addEventListener("play",N),v.addEventListener("pause",X),v.addEventListener("ended",$),()=>{v.removeEventListener("play",N),v.removeEventListener("pause",X),v.removeEventListener("ended",$);}},[e]);let L=react.useCallback((v,N)=>{let X=e.current;if(!X){console.error("[usePlayer] No video element");return}u(false),r.current&&r.current.destroy(),r.current=new fn({preferNative:c.current.preferNative,enableSmoothTimeUpdates:c.current.enableSmoothTimeUpdates,enableNetworkAdaptation:c.current.enableNetworkAdaptation,enablePowerAdaptation:c.current.enablePowerAdaptation,enableAnalytics:c.current.enableAnalytics,preloadConfig:c.current.preloadConfig,callbacks:V,autoQualityOnNetworkChange:S?.autoQualitySwitch,autoPauseOnOffline:S?.pauseOnOffline,autoResumeOnOnline:S?.resumeOnOnline,lowQualityThreshold:S?.lowQualityOn,autoPauseOnLowBattery:b?.autoPauseOnLowBattery,lowBatteryThreshold:b?.pauseThreshold}),r.current.attach(X,v,N);},[e,V,S,b]),h=react.useCallback(()=>{r.current&&(r.current.destroy(),r.current=null),l.reset(),u(false);},[l]),y=react.useCallback(async()=>{await r.current?.play();},[]),P=react.useCallback(()=>{r.current?.pause();},[]),O=react.useCallback(async()=>{await r.current?.togglePlay();},[]),C=react.useCallback(v=>{r.current?.seek(v);},[]),B=react.useCallback((v=10)=>{r.current?.seekForward(v);},[]),z=react.useCallback((v=10)=>{r.current?.seekBackward(v);},[]),H=react.useCallback(v=>{r.current?.setPlaybackRate(v);},[]),A=react.useCallback(()=>{let v=e.current;v&&(v.currentTime=0,v.play().catch(()=>{}));},[e]);return {playerCore:r.current,videoRef:e,containerRef:s,state:l,isReady:d,play:y,pause:P,togglePlay:O,seek:C,seekForward:B,seekBackward:z,setPlaybackSpeed:H,restart:A,volume:m,progress:i,quality:a,fullscreen:p,attach:L,destroy:h}}var no={position:"relative",width:"100%",height:"100%",backgroundColor:designTokens.colors.background},ro={width:"100%",height:"100%",objectFit:"contain"},_t=react.forwardRef(({video:e,autoPlay:t=true,muted:n=true,loop:r=true,poster:o,children:s,style:d,className:u="",onPlay:l,onPause:m,onEnded:i,onError:a,onStateChange:p,onTimeUpdate:c,onQualityLevelsLoaded:g,onReady:f},S)=>{let b=react.useRef(null),V=react.useRef(null),L=typeof e=="string"?e:e.url,h=o??(typeof e=="object"?e.thumbnail:void 0),y=$e(b,V,{onStateChange:p,onError:P=>a?.(P),onTimeUpdate:c,onQualityLevelsLoaded:g,onPlay:l,onPause:m,onEnded:i,onReady:f});return react.useEffect(()=>(L&&y.attach(L),()=>{y.destroy();}),[L]),react.useEffect(()=>{let P=b.current;P&&(P.muted=n,P.loop=r);},[n,r]),react.useEffect(()=>{let P=b.current;!P||!y.isReady||!t||P.play().catch(O=>{O.name==="NotAllowedError"&&(P.muted=true,P.play().catch(()=>{}));});},[t,y.isReady]),react.useImperativeHandle(S,()=>({play:y.play,pause:y.pause,togglePlay:y.togglePlay,seek:y.seek,seekForward:y.seekForward,seekBackward:y.seekBackward,restart:y.restart,setVolume:y.volume.setVolume,toggleMute:y.volume.toggleMute,setPlaybackSpeed:y.setPlaybackSpeed,setQuality:y.quality.setQuality,getQualityLevels:()=>y.quality.availableLevels,getVideoElement:()=>b.current,getCurrentTime:()=>y.progress.currentTime,getDuration:()=>y.progress.duration,isPaused:()=>b.current?.paused??true}),[y]),jsxRuntime.jsxs("div",{ref:V,style:Y(no,d),className:u,children:[jsxRuntime.jsx("video",{ref:b,poster:h,playsInline:true,preload:"auto",style:ro}),s]})});_t.displayName="VideoPlayer";var uo=30,co=1e3/uo,Z={container:{position:"absolute",bottom:0,left:0,right:0,zIndex:designTokens.zIndices.sticky,touchAction:"none",userSelect:"none",WebkitUserSelect:"none",transition:"all 0.125s ease-in-out"},collapsed:{height:Ne.HEIGHT_DEFAULT,paddingInline:designTokens.spacing[3],cursor:"pointer"},expanded:{padding:`${designTokens.spacing[2]}px ${designTokens.spacing[3]}px`,paddingBottom:`calc(${designTokens.spacing[1]}px + env(safe-area-inset-bottom, 0px))`,background:"linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%)"},timeContainer:{display:"flex",justifyContent:"center",alignItems:"center",marginBottom:designTokens.spacing[2]},timeText:{fontSize:designTokens.fontSizes.sm,fontWeight:designTokens.fontWeights.semibold,color:designTokens.colors.text,textShadow:designTokens.shadows.text,fontVariantNumeric:"tabular-nums",backgroundColor:"rgba(0, 0, 0, 0.6)",padding:`${designTokens.spacing[1]}px ${designTokens.spacing[3]}px`,borderRadius:designTokens.radii.md},track:{position:"relative",width:"100%",backgroundColor:"rgba(255, 255, 255, 0.2)",borderRadius:designTokens.radii.full,overflow:"hidden"},trackCollapsed:{height:Ne.HEIGHT_DEFAULT},trackExpanded:{height:Ne.HEIGHT_ACTIVE},buffer:{position:"absolute",top:0,left:0,height:"100%",backgroundColor:"rgba(255, 255, 255, 0.3)",borderRadius:designTokens.radii.full},progress:{position:"absolute",top:0,left:0,height:"100%",backgroundColor:designTokens.colors.text,borderRadius:designTokens.radii.full},scrubber:{position:"absolute",top:"50%",width:16,height:16,marginLeft:-8,marginTop:-8,backgroundColor:designTokens.colors.text,borderRadius:designTokens.radii.full,boxShadow:"0 2px 4px rgba(0,0,0,0.3)",transform:"scale(0)",transition:"transform 150ms ease"},scrubberVisible:{transform:"scale(1)"},touchArea:{position:"absolute",top:-12,left:0,right:0,bottom:-12,cursor:"pointer"}};function ye(e){if(!isFinite(e)||isNaN(e))return "0:00";let t=Math.floor(e/60),n=Math.floor(e%60);return `${t}:${n.toString().padStart(2,"0")}`}function ho(e){if(e.buffered.length===0)return 0;for(let t=0;t<e.buffered.length;t++)if(e.buffered.start(t)<=e.currentTime&&e.buffered.end(t)>=e.currentTime)return e.buffered.end(t);return e.buffered.end(e.buffered.length-1)}var pt=react.forwardRef(({videoRef:e,expanded:t=false,onSeekStart:n,onSeek:r,onSeekEnd:o,onExpandedChange:s,style:d,className:u=""},l)=>{let m=react.useRef(null),i=react.useRef(null),a=react.useRef(null),p=react.useRef(null),c=react.useRef(null),g=react.useRef(0),[f,S]=react.useState({currentTime:0,duration:0}),b=react.useRef(null),V=react.useRef(0),L=react.useRef(0),h=react.useRef(false),y=react.useRef(t);react.useEffect(()=>{y.current=t;},[t]);let P=react.useCallback(x=>{let w=e.current;if(!w||h.current)return;let k=w.duration||0,R=w.currentTime||0,D=ho(w),E=k>0?R/k*100:0,_=k>0?D/k*100:0;i.current&&(i.current.style.width=`${E}%`),a.current&&(a.current.style.width=`${_}%`),p.current&&y.current&&(p.current.style.left=`${E}%`),g.current=k,c.current&&(c.current.textContent=`${ye(R)} / ${ye(k)}`);let se=x??performance.now();se-L.current>=500&&(L.current=se,S(ge=>Math.abs(ge.currentTime-R)>=.5||ge.duration!==k?{currentTime:Math.floor(R),duration:Math.floor(k)}:ge));},[e]),O=react.useCallback(x=>{x-V.current>=co&&(V.current=x,P()),b.current=requestAnimationFrame(O);},[P]);react.useEffect(()=>(b.current=requestAnimationFrame(O),()=>{b.current&&cancelAnimationFrame(b.current);}),[O]);let C=react.useCallback(x=>{let w=m.current,k=e.current;if(!w||!k)return 0;let R=w.getBoundingClientRect(),D=x-R.left;return Math.max(0,Math.min(1,D/R.width))*(k.duration||0)},[e]),B=react.useCallback(x=>{h.current=true,n?.();let w=C(x);r?.(w);let k=e.current;if(k&&i.current){let R=k.duration||g.current||1,D=w/R*100;i.current.style.width=`${D}%`,p.current&&(p.current.style.left=`${D}%`),c.current&&(c.current.textContent=`${ye(w)} / ${ye(R)}`);}},[C,r,n,e]),z=react.useCallback(x=>{if(!h.current)return;let w=C(x);r?.(w);let k=e.current;if(k&&i.current){let R=k.duration||g.current||1,D=w/R*100;i.current.style.width=`${D}%`,p.current&&(p.current.style.left=`${D}%`),c.current&&(c.current.textContent=`${ye(w)} / ${ye(R)}`);}},[C,r,e]),H=react.useCallback(x=>{if(!h.current)return;h.current=false;let w=C(x);o?.(w);let k=e.current;k&&(k.currentTime=w);},[C,o,e]),A=react.useCallback(x=>{let w=x.touches[0];w&&B(w.clientX);},[B]),v=react.useCallback(x=>{let w=x.touches[0];w&&z(w.clientX);},[z]),N=react.useCallback(x=>{let w=x.changedTouches[0];w&&H(w.clientX);},[H]),X=react.useCallback(x=>{B(x.clientX);let w=R=>z(R.clientX),k=R=>{H(R.clientX),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",k);};document.addEventListener("mousemove",w),document.addEventListener("mouseup",k);},[B,z,H]),$=react.useCallback(()=>{t||s?.(true);},[t,s]),q=react.useCallback(x=>{let w=e.current;if(!w)return;let k=w.duration||0,R=w.currentTime||0,D=R;switch(x.key){case "ArrowLeft":D=Math.max(0,R-5);break;case "ArrowRight":D=Math.min(k,R+5);break;case "ArrowUp":D=Math.min(k,R+10);break;case "ArrowDown":D=Math.max(0,R-10);break;case "Home":D=0;break;case "End":D=k;break;default:return}x.preventDefault(),w.currentTime=D,r?.(D),P();},[e,r,P]);react.useImperativeHandle(l,()=>({update:P,setExpanded:x=>{s?.(x);}}));let K={...Z.container,...t?Z.expanded:Z.collapsed,...d},oe={...Z.track,...t?Z.trackExpanded:Z.trackCollapsed},J={...Z.scrubber,...t?Z.scrubberVisible:{}};return jsxRuntime.jsxs("div",{ref:m,style:K,className:u,onClick:t?void 0:$,onTouchStart:A,onTouchMove:v,onTouchEnd:N,onTouchCancel:N,onMouseDown:X,onKeyDown:q,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":f.duration,"aria-valuenow":f.currentTime,"aria-valuetext":`${ye(f.currentTime)} of ${ye(f.duration)}`,tabIndex:0,children:[t&&jsxRuntime.jsx("div",{style:Z.timeContainer,children:jsxRuntime.jsx("span",{ref:c,style:Z.timeText,children:"0:00 / 0:00"})}),jsxRuntime.jsxs("div",{style:oe,"aria-hidden":"true",children:[jsxRuntime.jsx("div",{style:Z.touchArea}),jsxRuntime.jsx("div",{ref:a,style:Z.buffer}),jsxRuntime.jsx("div",{ref:i,style:Z.progress}),t&&jsxRuntime.jsx("div",{ref:p,style:J})]})]})});pt.displayName="Timeline";var po={DOUBLE_TAP_DELAY:200},fo={THRESHOLD:500},qe={VERTICAL_THRESHOLD:.3,HORIZONTAL_THRESHOLD:.4,MIN_VELOCITY:.5},ft={THRESHOLD:10};var ve={TAP_DELAY:po.DOUBLE_TAP_DELAY,LONG_PRESS_THRESHOLD:fo.THRESHOLD,SWIPE_VERTICAL_THRESHOLD:qe.VERTICAL_THRESHOLD,SWIPE_HORIZONTAL_THRESHOLD:qe.HORIZONTAL_THRESHOLD,DRAG_THRESHOLD:ft.THRESHOLD};function Un(){return typeof navigator<"u"&&"vibrate"in navigator}function mt(){Un()&&navigator.vibrate(10);}function Qn(){Un()&&navigator.vibrate(20);}function zn(e,t){let n=e.currentTarget||e.target;if(!n||typeof n.getBoundingClientRect!="function")return "center";let r=n.getBoundingClientRect(),o=e.clientX-r.left,s=r.width;if(s===0)return "center";let d=s*.33,u=s*.67;return o<d?"left":o>u?"right":"center"}function gt(e){let t=react.useRef(0),n=react.useRef("center"),r=react.useRef(null),o=react.useRef(null),s=react.useRef(false),d=react.useRef(false),u=react.useRef({x:0,y:0}),l=react.useCallback(i=>{if(d.current){d.current=false;return}let a=zn(i),p=Date.now(),c=p-t.current,g={x:i.clientX,y:i.clientY};c<ve.TAP_DELAY&&n.current===a?(r.current&&(clearTimeout(r.current),r.current=null),mt(),e.onDoubleTap?.(a,g)):r.current=setTimeout(()=>{e.onSingleTap?.(a),r.current=null;},ve.TAP_DELAY),t.current=p,n.current=a;},[e]);return react$2.useGesture({onPointerDown:({event:i})=>{let a=i;u.current={x:a.clientX,y:a.clientY},d.current=false;let p=setTimeout(()=>{s.current=true,e.onHoldStart?.();},150);o.current=setTimeout(()=>{d.current=true,Qn();let g=a.target.getBoundingClientRect();e.onLongPress?.({x:a.clientX-g.left,y:a.clientY-g.top});},ve.LONG_PRESS_THRESHOLD),i.target.dataset.holdTimeout=String(p);},onPointerUp:({event:i})=>{let a=i.target.dataset.holdTimeout;a&&clearTimeout(Number(a)),o.current&&(clearTimeout(o.current),o.current=null),s.current&&(s.current=false,e.onHoldEnd?.());},onPointerMove:({event:i})=>{let a=i,p=Math.abs(a.clientX-u.current.x),c=Math.abs(a.clientY-u.current.y);(p>10||c>10)&&o.current&&(clearTimeout(o.current),o.current=null);},onClick:({event:i})=>{l(i);},onDrag:({movement:[i,a],direction:[p,c],velocity:[g,f],last:S,event:b})=>{if(b.preventDefault(),!S)return;let V=window.innerWidth,L=window.innerHeight;if(Math.abs(a)>L*ve.SWIPE_VERTICAL_THRESHOLD){c>0?e.onSwipeDown?.():e.onSwipeUp?.();return}if(Math.abs(i)>V*ve.SWIPE_HORIZONTAL_THRESHOLD){p>0?e.onSwipeRight?.():e.onSwipeLeft?.();return}Math.abs(i)>ve.DRAG_THRESHOLD&&Math.abs(g)>Math.abs(f)&&e.onSeekDrag?.(i);}},{drag:{threshold:ve.DRAG_THRESHOLD,filterTaps:true},eventOptions:{passive:false}})}var So=800,wo=.05,Po=.95;function Ut({onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r,threshold:o=qe.VERTICAL_THRESHOLD,velocityThreshold:s=qe.MIN_VELOCITY,hapticEnabled:d=true,disabled:u=false,enableProgressState:l=false}={}){let m=Math.max(wo,Math.min(Po,o)),[i,a]=react.useState({progress:0,direction:null,isSwiping:false}),p=react.useRef({onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r}),c=react.useRef(typeof window<"u"?window.innerHeight:So);return p.current={onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r},react.useEffect(()=>{let f=()=>{c.current=window.innerHeight;},S=()=>{setTimeout(()=>{c.current=window.innerHeight;},100);};return window.addEventListener("resize",f,{passive:true}),window.addEventListener("orientationchange",S,{passive:true}),()=>{window.removeEventListener("resize",f),window.removeEventListener("orientationchange",S);}},[]),{bind:react$2.useDrag(({movement:[,f],velocity:[,S],active:b,cancel:V})=>{if(u){V?.();return}let h=c.current*m,y=Math.min(1,Math.abs(f)/h),P=f<0?"up":"down";if(b)p.current.onSwipeProgress?.(y,P,f),l&&a({progress:y,direction:P,isSwiping:true});else {let O=Math.abs(f)>=h,C=Math.abs(S)>=s;O||C?(d&&mt(),P==="up"?p.current.onSwipeUp?.():p.current.onSwipeDown?.()):p.current.onSwipeCancel?.(),a({progress:0,direction:null,isSwiping:false});}},{axis:"y",threshold:ft.THRESHOLD,filterTaps:true,pointer:{touch:true},eventOptions:{passive:true}}),...i}}var Oe={container:{position:"relative",width:"100%",height:"100%",backgroundColor:designTokens.colors.background},video:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain"},placeholder:{position:"absolute",inset:0,backgroundSize:"cover",backgroundPosition:"center"},tapArea:{zIndex:designTokens.zIndices.base},pauseOverlay:{zIndex:designTokens.zIndices.overlay},pauseIconWrapper:{borderRadius:designTokens.radii.full,transition:`opacity ${designTokens.durations.normal}ms ${designTokens.easings.xhubReel}, transform ${designTokens.durations.normal}ms ${designTokens.easings.xhubReel}`}};var Qt=react.createContext(null);function pe(){let e=react.useContext(Qt);if(!e)throw new Error("VideoFeedItem compound components must be used within a VideoFeedItem");return e}function Gn({elementRef:e,activateThreshold:t=Je.ACTIVATION_THRESHOLD,deactivateThreshold:n=Je.DEACTIVATION_THRESHOLD,rootMargin:r="0px",onVisibilityChange:o}){let[s,d]=react.useState(false),[u,l]=react.useState(false),[m,i]=react.useState(0),a=react.useRef(null);return react.useEffect(()=>{let p=e.current;if(!p)return;a.current&&a.current.disconnect();let c=[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1];return a.current=new IntersectionObserver(g=>{g.forEach(f=>{let S=f.intersectionRatio;i(S),d(S>0),S>=t?l(true):S<n&&l(false),o?.(S>0,S);});},{threshold:c,rootMargin:r}),a.current.observe(p),()=>{a.current?.disconnect();}},[e,t,n,r,o]),{isVisible:s,isActive:u,visibilityRatio:m}}function qn({containerRef:e,videoRef:t,isCurrentVideo:n=false,onActivate:r,onDeactivate:o,autoActivate:s=true,trackVisibility:d=false,onVisibilityChange:u}){let l=react.useRef(false),{isVisible:m,isActive:i,visibilityRatio:a}=Gn({elementRef:e??{current:null},onVisibilityChange:d?u:void 0}),p=d?i:n;react.useEffect(()=>{s&&(p&&!l.current?(l.current=true,r?.()):!p&&l.current&&(l.current=false,o?.()));},[p,r,o,s]);let c=react.useCallback(()=>{let f=t.current;f&&f.play().catch(()=>{f.muted=true,f.play().catch(()=>{});}),r?.();},[t,r]),g=react.useCallback(()=>{let f=t.current;f&&(f.pause(),f.currentTime=0),o?.();},[t,o]);return {isActive:p,isVisible:d?m:n,visibilityRatio:d?a:n?1:0,activate:c,deactivate:g}}var Wt=class{entries=new Map;listeners=new Set;memoryWarningThreshold;constructor(){this.memoryWarningThreshold=Re.MAX_TOTAL_MEMORY/(1024*1024),this.setupMemoryPressureListener();}register(t,n=10){this.entries.set(t,{videoId:t,inDom:false,hasDecodedFrames:false,estimatedSizeMB:n,lastAccessed:Date.now()}),this.notifyListeners();}unregister(t){this.entries.delete(t),this.notifyListeners();}setInDom(t,n){let r=this.entries.get(t);r&&(r.inDom=n,r.lastAccessed=Date.now(),this.notifyListeners());}setHasDecodedFrames(t,n){let r=this.entries.get(t);r&&(r.hasDecodedFrames=n,r.lastAccessed=Date.now(),this.notifyListeners());}getState(){let t=0,n=0,r=0;return this.entries.forEach(o=>{o.inDom&&t++,o.hasDecodedFrames&&n++,r+=o.estimatedSizeMB;}),{videosInDom:t,decodedVideos:n,estimatedMemoryMB:r,isLowMemory:r>this.memoryWarningThreshold}}getVideosToDispose(){let t=this.getState(),n=[],r=Re?.MAX_VIDEOS_IN_DOM,o=Re?.MAX_DECODED_FRAMES,s=Array.from(this.entries.values()).sort((d,u)=>d.lastAccessed-u.lastAccessed);if(t.videosInDom>r){let d=t.videosInDom-r,u=0;for(let l of s){if(u>=d)break;l.inDom&&(n.push(l.videoId),u++);}}if(t.decodedVideos>o){let d=t.decodedVideos-o,u=0;for(let l of s){if(u>=d)break;l.hasDecodedFrames&&!n.includes(l.videoId)&&(n.push(l.videoId),u++);}}return n}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}forceCleanup(){let t=this.getVideosToDispose();return t.forEach(n=>this.unregister(n)),t}notifyListeners(){let t=this.getState();this.listeners.forEach(n=>n(t));}setupMemoryPressureListener(){typeof window>"u"||"memory"in performance&&setInterval(()=>{this.getState().isLowMemory&&(console.warn("[MemoryManager] Low memory warning, forcing cleanup"),this.forceCleanup());},5e3);}},be=new Wt;function jn({videoId:e,estimatedSizeMB:t=10,onShouldDispose:n}){let[r,o]=react.useState(()=>be.getState()),[s,d]=react.useState(false);react.useEffect(()=>(be.register(e,t),()=>{be.unregister(e);}),[e,t]),react.useEffect(()=>be.subscribe(i=>{o(i);let p=be.getVideosToDispose().includes(e);p&&!s?(d(true),n?.()):!p&&s&&d(false);}),[e,s,n]);let u=react.useCallback(m=>{be.setInDom(e,m);},[e]),l=react.useCallback(m=>{be.setHasDecodedFrames(e,m);},[e]);return {memoryState:r,setInDom:u,setHasDecodedFrames:l,shouldDispose:s}}function Jn({video:e,isActive:t,priority:n,onLike:r,onComment:o,onShare:s,onAuthorClick:d}){let u=react.useRef(null),l=react.useRef(null),m=react.useRef(false),[i,a]=react.useState(false),[p,c]=react.useState(false),[g,f]=react.useState(false),{isShowing:S,position:b,showHeart:V}=ct(),L=react.useMemo(()=>({maxConcurrent:2,maxBufferSize:10*1024*1024,priorityLevels:10}),[]),h=react.useCallback(E=>{},[]),y=react.useCallback(E=>{},[]),P=react.useCallback(E=>{E.startupTime&&E.startupTime>1e3&&console.warn("[VideoFeedItem] Slow startup:",E.startupTime,"ms",e.id);},[e.id]),{state:O}=$e(l,u,{preferNative:true,enableSmoothTimeUpdates:true,networkBehavior:"feed",powerBehavior:"moderate",preloadConfig:L,enableAnalytics:true,onPlay:()=>{a(false),c(false);},onPause:()=>{l.current?.seeking||(a(true),c(true));},onNetworkChange:h,onPowerChange:y,onAnalyticsUpdate:P}),C=react.useCallback(async()=>{let E=l.current;if(E){E.muted=true;try{await E.play();}catch(_){console.warn("[VideoFeedItem] Play failed:",_.message);}}},[]),B=react.useCallback(()=>{let E=l.current;E&&E.pause();},[]),z=react.useCallback(E=>{let _=l.current;_&&(_.currentTime=E);},[]),[H,A]=react.useState(false);react.useEffect(()=>{let E=l.current;if(!E)return;let _=()=>A(true),se=()=>A(false),ge=()=>A(false);return E.addEventListener("play",_),E.addEventListener("pause",se),E.addEventListener("ended",ge),A(!E.paused),()=>{E.removeEventListener("play",_),E.removeEventListener("pause",se),E.removeEventListener("ended",ge);}},[e.id]);let v=H||O.state==="playing",{setInDom:N,setHasDecodedFrames:X,shouldDispose:$}=jn({videoId:e.id,onShouldDispose:()=>{B(),l.current&&(l.current.src="",l.current.load());}}),q=!$&&n!=="none",K=react.useRef(false);qn({videoRef:l,isCurrentVideo:t,onActivate:()=>{console.log("[VideoFeedItem] onActivate called, videoRef:",l.current?.src),X(true),l.current?C():(console.log("[VideoFeedItem] Video element not ready, marking pending play"),K.current=true);},onDeactivate:()=>{console.log("[VideoFeedItem] onDeactivate called"),K.current=false,X(false),B(),z(0);},autoActivate:true}),react.useEffect(()=>{l.current&&K.current&&t&&(console.log("[VideoFeedItem] Video element now available, executing pending play"),K.current=false,C());}),react.useEffect(()=>(N(true),()=>N(false)),[N]),react.useEffect(()=>{let E=l.current;if(!E)return;f(false);let _=()=>{console.log("[VideoFeedItem] Video loadeddata:",e.id,{isActive:t,priority:n}),n==="high"&&!t?requestAnimationFrame(()=>{E.readyState>=2&&(E.currentTime=.01,f(true),console.log("[VideoFeedItem] First frame decoded (preloaded):",e.id));}):t&&f(true);},se=()=>{n==="high"&&!g&&f(true);};return E.addEventListener("loadeddata",_),E.addEventListener("canplay",se),E.readyState>=2&&_(),()=>{E.removeEventListener("loadeddata",_),E.removeEventListener("canplay",se);}},[e.id,t,n,g]),react.useEffect(()=>{console.log("[VideoFeedItem] State:",{videoId:e.id,isActive:t,priority:n,shouldRenderVideo:q,hasVideoElement:!!l.current,videoSrc:l.current?.src});},[e.id,t,n,q]);let oe=react.useMemo(()=>{switch(n){case "high":return "auto";case "medium":return "metadata";case "low":case "metadata":return "none";default:return "none"}},[n]),J=react.useCallback(()=>{m.current=v,c(true),a(false),B();},[v,B]),x=react.useCallback(E=>{z(E),m.current?(C(),c(false)):a(true);},[z,C]),w=react.useCallback(()=>{v?B():C();},[v,C,B]),k=react.useCallback((E,_)=>{V(_.x,_.y),r?.();},[V,r]),R=react.useCallback(()=>{},[]),D=gt({onSingleTap:w,onDoubleTap:k,onLongPress:R});return {video:e,isActive:t,shouldRenderVideo:q,preload:oe,isPreloaded:g,containerRef:u,videoRef:l,isPlaying:v,showPauseOverlay:i,timelineExpanded:p,play:C,pause:B,seek:z,setShowPauseOverlay:a,setTimelineExpanded:c,gestureBindings:D,showHeart:S,heartPosition:b,triggerHeart:V,onLike:r,onComment:o,onShare:s,onAuthorClick:d,handleSeekStart:J,handleSeekEnd:x}}var bt=react.forwardRef(({placeholder:e,...t},n)=>{let{video:r,videoRef:o,shouldRenderVideo:s,preload:d,isPreloaded:u}=pe();if(!s)return e??jsxRuntime.jsx("div",{...t,style:{...Oe.placeholder,backgroundImage:`url(${r.thumbnail})`,...t.style}});let l=!u;return jsxRuntime.jsx("video",{ref:m=>{typeof n=="function"?n(m):n&&(n.current=m),o.current=m;},src:r.url,poster:l?r.thumbnail:void 0,preload:d,loop:true,playsInline:true,muted:true,style:Oe.video})});bt.displayName="VideoFeedItemPlayer";var St=react.forwardRef(({onLike:e,onComment:t,onShare:n,...r},o)=>{let{video:s,onLike:d,onComment:u,onShare:l}=pe();return jsxRuntime.jsx("div",{ref:o,...r,children:jsxRuntime.jsx(st,{avatarUrl:s.author.avatar,likeCount:s.stats.likes,commentCount:s.stats.comments,shareCount:s.stats.shares,isLiked:s.isLiked,onLike:e??d,onComment:t??u,onShare:n??l})})});St.displayName="VideoFeedItemActions";var wt=react.forwardRef(({expanded:e,...t},n)=>{let{videoRef:r,shouldRenderVideo:o,timelineExpanded:s,setTimelineExpanded:d,handleSeekStart:u,handleSeekEnd:l}=pe();return o?jsxRuntime.jsx("div",{ref:n,...t,children:jsxRuntime.jsx(pt,{videoRef:r,expanded:e??s,onSeekStart:u,onSeekEnd:l,onExpandedChange:d})}):null});wt.displayName="VideoFeedItemTimeline";var He={container:{position:"absolute",bottom:0,left:0,right:64,padding:designTokens.spacing[4],paddingBottom:"env(safe-area-inset-bottom, 16px)",zIndex:designTokens.zIndices.base},containerWithTimeline:{paddingBottom:"calc(env(safe-area-inset-bottom, 16px) + 48px)"},authorButton:{gap:designTokens.spacing[2],marginBottom:designTokens.spacing[3]},avatar:{borderRadius:designTokens.radii.full,border:`2px solid ${designTokens.colors.text}`},username:{color:designTokens.colors.text,fontWeight:designTokens.fontWeights.semibold,fontSize:designTokens.fontSizes.sm,textShadow:designTokens.shadows.text},caption:{color:designTokens.colors.text,fontSize:designTokens.fontSizes.sm,lineHeight:1.4,textShadow:designTokens.shadows.text,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",paddingBottom:designTokens.spacing[1]},author:{color:designTokens.colors.text,fontSize:designTokens.fontSizes.sm,fontWeight:designTokens.fontWeights.semibold,textShadow:designTokens.shadows.text,display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",paddingBottom:designTokens.spacing[1]},hashtags:{display:"flex",flexWrap:"wrap",gap:designTokens.spacing[1],marginTop:designTokens.spacing[2],paddingBottom:designTokens.spacing[1]},hashtag:{color:designTokens.colors.accent,fontSize:designTokens.fontSizes.sm,fontWeight:designTokens.fontWeights.medium,textShadow:designTokens.shadows.text}};function ir({video:e,timelineExpanded:t=false,style:n,className:r=""}){let o=Y(He.container,t&&He.containerWithTimeline,n);return jsxRuntime.jsxs("div",{style:o,className:r,children:[e.author&&jsxRuntime.jsx("p",{style:He.author,children:e.author.displayName}),e.caption&&jsxRuntime.jsx("p",{style:He.caption,children:e.caption}),e.hashtags&&e.hashtags.length>0&&jsxRuntime.jsx("div",{style:He.hashtags,children:e.hashtags.slice(0,3).map((s,d)=>jsxRuntime.jsxs("span",{style:He.hashtag,children:["#",s]},d))})]})}var Pt=react.forwardRef(({showPlayPause:e=true,showDoubleTapHeart:t=true,showVideoInfo:n=true,...r},o)=>{let{video:s,isPlaying:d,showPauseOverlay:u,timelineExpanded:l,showHeart:m,heartPosition:i,onAuthorClick:a}=pe();return jsxRuntime.jsxs("div",{ref:o,...r,children:[e&&jsxRuntime.jsx(lt,{isPlaying:d,show:u,size:64,autoHideDelay:800,showOnStateChange:false}),t&&jsxRuntime.jsx(ht,{show:m,position:i,size:100,showParticles:true,particleCount:8}),n&&jsxRuntime.jsx(ir,{video:s,onAuthorClick:a,timelineExpanded:l})]})});Pt.displayName="VideoFeedItemOverlay";var Be=react.forwardRef(({video:e,isActive:t=false,priority:n="none",showTimeline:r=true,onLike:o,onComment:s,onShare:d,onAuthorClick:u,style:l,className:m="",children:i},a)=>{let p=Jn({video:e,isActive:t,priority:n,onLike:o,onComment:s,onShare:d,onAuthorClick:u}),c=i??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(bt,{}),jsxRuntime.jsx(Pt,{}),jsxRuntime.jsx(St,{}),r&&jsxRuntime.jsx(wt,{})]});return jsxRuntime.jsx(Qt.Provider,{value:p,children:jsxRuntime.jsx("div",{ref:g=>{typeof a=="function"?a(g):a&&(a.current=g),p.containerRef.current=g;},style:Y(Oe.container,l),className:m,...p.gestureBindings(),children:c})})});Be.displayName="VideoFeedItem";function or(e,t){let n=e-t;return n===0||n===-1||n===1?"high":n===2?"medium":n===3?"low":Math.abs(n)<=5?"metadata":"none"}var Do="cubic-bezier(0.32, 0.72, 0, 1)",Bo=300,No=800,_o=50;function ar({trackRef:e,transitionDuration:t=Bo,easing:n=Do,onTransitionEnd:r}){let o=react.useRef(typeof window<"u"?window.innerHeight:No),s=react.useRef(0),d=react.useRef(null),u=react.useRef(false),l=react.useRef(true);react.useEffect(()=>{let c=()=>{o.current=window.innerHeight;},g=()=>{setTimeout(()=>{o.current=window.innerHeight;},100);};return window.addEventListener("resize",c,{passive:true}),window.addEventListener("orientationchange",g,{passive:true}),()=>{window.removeEventListener("resize",c),window.removeEventListener("orientationchange",g);}},[]);let m=react.useCallback(c=>{s.current=c,d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{let g=e.current;g&&(g.style.transition="none",g.style.transform=`translateY(${c}px)`),d.current=null;});},[e]),i=react.useCallback(c=>new Promise(g=>{let f=e.current;if(!f||!l.current){g();return}if(u.current){g();return}u.current=true,s.current=c;let S=null,b=null,V=L=>{L.propertyName==="transform"&&(S?.(),l.current&&(u.current=false,r?.()),g());};S=()=>{f.removeEventListener("transitionend",V),b&&(clearTimeout(b),b=null);},f.addEventListener("transitionend",V),b=setTimeout(()=>{S?.(),l.current&&u.current&&(u.current=false,r?.()),g();},t+_o),f.offsetHeight,f.style.transition=`transform ${t}ms ${n}`,f.style.transform=`translateY(${c}px)`;}),[e,t,n,r]),a=react.useCallback(()=>i(0),[i]),p=react.useCallback(()=>s.current,[]);return react.useEffect(()=>(l.current=true,()=>{l.current=false,d.current!==null&&(cancelAnimationFrame(d.current),d.current=null);}),[]),{setTranslateY:m,animateTo:i,snapBack:a,getCurrentY:p,viewportHeight:o.current,isAnimating:u.current}}var zo=300,Wo=50,Go=.3,$o="cubic-bezier(0.32, 0.72, 0, 1)",Se={container:{position:"fixed",inset:0,overflow:"hidden",backgroundColor:designTokens.colors.background,touchAction:"none",userSelect:"none",WebkitUserSelect:"none"},track:{position:"relative",width:"100%",height:"100%",willChange:"transform"},slide:{position:"absolute",left:0,width:"100%",height:"100%",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},loadingIndicator:{position:"absolute",bottom:80,left:0,right:0,display:"flex",justifyContent:"center",zIndex:designTokens.zIndices.base,pointerEvents:"none"},spinner:{width:24,height:24,borderWidth:2,borderStyle:"solid",borderColor:"rgba(255, 255, 255, 0.3)",borderTopColor:designTokens.colors.text,borderRadius:designTokens.radii.full,animation:"xhub-reel-spin 1s linear infinite"}},Ke=react.forwardRef(({videos:e,initialIndex:t=0,onLoadMore:n,onVideoChange:r,onLike:o,onComment:s,onShare:d,onAuthorClick:u,isLoading:l=false,hasMore:m=false,loadMoreThreshold:i=3,transitionDuration:a=zo,swipeThreshold:p=Wo,velocityThreshold:c=Go,gesturesDisabled:g=false,hapticEnabled:f=true,style:S,className:b=""},V)=>{let[L,h]=react.useState(()=>Math.min(Math.max(0,t),Math.max(0,e.length-1))),[y,P]=react.useState(false),[O,C]=react.useState(false),B=react.useRef(null),z=react.useRef(null),H=react.useRef(e),A=react.useRef(L),v=react.useRef(l),N=react.useRef(m),X=react.useRef(y),{setCurrentIndex:$}=Lt(),{setTranslateY:q,animateTo:K,snapBack:oe,viewportHeight:J}=ar({trackRef:z,transitionDuration:a,easing:$o});react.useEffect(()=>{H.current=e;},[e]),react.useEffect(()=>{A.current=L;},[L]),react.useEffect(()=>{v.current=l;},[l]),react.useEffect(()=>{N.current=m;},[m]),react.useEffect(()=>{X.current=y;},[y]),react.useEffect(()=>{if(e.length===0){h(0);return}if(L>=e.length){let I=e.length-1,U=e[I];h(I),$(I),U&&r?.(U,I);}},[e.length,L,$,r,e]);let x=react.useCallback(I=>or(I,L),[L]),w=react.useCallback(I=>{let U=H.current;N.current&&!v.current&&U.length-I<=i&&n?.();},[i,n]),k=react.useCallback(async(I,U=true)=>{if(X.current)return;let F=H.current,M=Math.max(0,Math.min(I,F.length-1)),ae=A.current;if(M===ae){q(0);return}let xe=M>ae?-1:1;if(U){P(true),C(true),await K(xe*J),h(M),$(M),q(0);let we=F[M];we&&r?.(we,M),w(M),C(false),P(false);}else {h(M),$(M),q(0);let we=F[M];we&&(r?.(we,M),w(M));}},[J,K,q,$,r,w]),R=react.useCallback((I=true)=>{let U=H.current,F=A.current;F<U.length-1&&k(F+1,I);},[k]),D=react.useCallback((I=true)=>{let U=A.current;U>0&&k(U-1,I);},[k]),E=react.useCallback((I,U,F)=>{let M=H.current,ae=A.current,xe=ae>0,we=ae<M.length-1,Xt=F;(U==="down"&&!xe||U==="up"&&!we)&&(Xt*=.3),q(Xt);},[q]),_=react.useCallback(async()=>{let I=H.current;if(!(A.current<I.length-1)){await oe();return}P(true),C(true),await K(-J);let M=A.current+1,ae=H.current;if(M<ae.length){h(M),$(M);let xe=ae[M];xe&&r?.(xe,M),w(M);}q(0),C(false),P(false);},[J,K,oe,q,$,r,w]),se=react.useCallback(async()=>{if(!(A.current>0)){await oe();return}P(true),C(true),await K(J);let F=A.current-1;if(F>=0){h(F),$(F);let M=H.current[F];M&&r?.(M,F);}q(0),C(false),P(false);},[J,K,oe,q,$,r]),ge=react.useCallback(async()=>{await oe();},[oe]),{bind:ur}=Ut({onSwipeUp:_,onSwipeDown:se,onSwipeProgress:E,onSwipeCancel:ge,threshold:p/J,velocityThreshold:c,hapticEnabled:f,disabled:g||y,enableProgressState:false});react.useImperativeHandle(V,()=>({slideTo:k,slideNext:R,slidePrev:D,get activeIndex(){return A.current},get totalSlides(){return H.current.length},get isBeginning(){return A.current===0},get isEnd(){return A.current===H.current.length-1}})),react.useEffect(()=>{let I=e[L];I&&r?.(I,L);},[]);let Ze=[];if(L>0&&Ze.push({index:L-1,position:-1}),Ze.push({index:L,position:0}),L<e.length-1&&Ze.push({index:L+1,position:1}),e.length===0)return jsxRuntime.jsx("div",{ref:B,style:Y(Se.container,S),className:b,"data-xhub-reel-feed":true,children:l&&jsxRuntime.jsx("div",{style:{...Se.loadingIndicator,top:"50%",bottom:"auto"},children:jsxRuntime.jsx("div",{style:Se.spinner})})});let cr={...Se.track};return jsxRuntime.jsxs("div",{ref:B,...ur(),style:Y(Se.container,S),className:b,"data-xhub-reel-feed":true,children:[jsxRuntime.jsx("style",{children:`
|
|
6
|
+
@keyframes xhub-reel-spin {
|
|
7
|
+
to { transform: rotate(360deg); }
|
|
8
|
+
}
|
|
9
|
+
`}),jsxRuntime.jsx("div",{ref:z,style:cr,children:Ze.map(({index:I,position:U})=>{let F=e[I];if(!F)return null;let M=x(I),ae=I===L&&!O;return jsxRuntime.jsx("div",{"data-index":I,style:{...Se.slide,top:U*J},children:jsxRuntime.jsx(Be,{video:F,isActive:ae,priority:M,onLike:()=>o?.(F),onComment:()=>s?.(F),onShare:()=>d?.(F),onAuthorClick:()=>u?.(F)})},F.id)})}),l&&jsxRuntime.jsx("div",{style:Se.loadingIndicator,children:jsxRuntime.jsx("div",{style:Se.spinner})})]})});Ke.displayName="VideoFeed";function Yt({videos:e,initialIndex:t=0,onLoadMore:n,hasMore:r=true,isLoading:o=false,onLike:s,onComment:d,onShare:u,onAuthorClick:l,onVideoChange:m,className:i=""}){let a=react.useRef(null),p=react.useCallback((b,V)=>{m?.(b,V);},[m]),c=react.useCallback(b=>{s?.(b);},[s]),g=react.useCallback(b=>{d?.(b);},[d]),f=react.useCallback(b=>{u?.(b);},[u]),S=react.useCallback(b=>{l?.(b);},[l]);return jsxRuntime.jsx("div",{className:`h-screen w-full overflow-hidden bg-black ${i}`,children:jsxRuntime.jsx(Ke,{ref:a,videos:e,initialIndex:t,onLoadMore:n,hasMore:r,isLoading:o,onVideoChange:p,onLike:c,onComment:g,onShare:f,onAuthorClick:S})})}function dr(e){let{container:t,...n}=e,r=typeof t=="string"?document.querySelector(t):t;if(!r||!(r instanceof HTMLElement))throw new Error("[XHubReelEmbed] Invalid container element");let o=client.createRoot(r),s=n,d=u=>{s=u,o.render(react.createElement(Yt,u));};return d(n),{updateVideos:u=>{d({...s,videos:u});},destroy:()=>{o.unmount();}}}typeof window<"u"&&(window.XHubReel=dr);exports.ActionBar=st;exports.BottomSheet=xn;exports.IconButton=At;exports.PlayPauseOverlay=lt;exports.Spinner=In;exports.Toast=An;exports.VideoFeed=Ke;exports.VideoFeedItem=Be;exports.VideoPlayer=_t;exports.XHubReelEmbed=Yt;exports.createXHubReelEmbed=dr;exports.useVideoGestures=gt;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ln,{Events,ErrorTypes}from'hls.js';import {create}from'zustand';import {persist}from'zustand/middleware';import {shadows,colors,fontWeights,fontSizes,radii,spacing,easings,durations,components,mergeStyles,zIndices,springs}from'@xhub-reel/design-tokens';import {forwardRef,useRef,useEffect,useImperativeHandle,useState,useCallback,createContext,useMemo,useContext,createElement}from'react';import {AnimatePresence,motion}from'motion/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useDrag,useGesture}from'@use-gesture/react';import {createRoot}from'react-dom/client';var Ct={maxBufferLength:30,maxMaxBufferLength:60,maxBufferSize:3e7,maxBufferHole:.5,abrEwmaDefaultEstimate:5e5,abrBandWidthUpFactor:.7,abrBandWidthFactor:.9,startLevel:-1,autoStartLoad:true,startPosition:-1,fragLoadingMaxRetry:3,manifestLoadingMaxRetry:3,levelLoadingMaxRetry:3,fragLoadingTimeOut:2e4,manifestLoadingTimeOut:1e4,levelLoadingTimeOut:1e4,lowLatencyMode:false,liveSyncDuration:3};var Je={ACTIVATION_THRESHOLD:.5,DEACTIVATION_THRESHOLD:.3},Re={MAX_VIDEOS_IN_DOM:5,MAX_DECODED_FRAMES:3,MAX_TOTAL_MEMORY:150*1024*1024},Ne={HEIGHT_DEFAULT:2,HEIGHT_ACTIVE:4};var kt={PLAYER_PREFERENCES:"xhub-reel-player"};var Kt={isMuted:true,volume:1,playbackSpeed:1,quality:"auto"},_e=create()(persist(e=>({...Kt,toggleMute:()=>e(t=>({isMuted:!t.isMuted})),setMuted:t=>e({isMuted:t}),setVolume:t=>e({volume:Math.max(0,Math.min(1,t)),isMuted:t===0}),setPlaybackSpeed:t=>e({playbackSpeed:t}),setQuality:t=>e({quality:t}),resetPreferences:()=>e(Kt)}),{name:kt.PLAYER_PREFERENCES}));var jt={videos:[],currentIndex:0,isLoading:false,hasMore:true,error:null},Lt=create(e=>({...jt,setVideos:t=>e({videos:t,currentIndex:0}),appendVideos:t=>e(n=>({videos:[...n.videos,...t]})),setCurrentIndex:t=>e({currentIndex:t}),goToNext:()=>e(t=>({currentIndex:Math.min(t.currentIndex+1,t.videos.length-1)})),goToPrevious:()=>e(t=>({currentIndex:Math.max(t.currentIndex-1,0)})),removeVideo:t=>e(n=>{let r=n.videos.filter(s=>s.id!==t),o=Math.min(n.currentIndex,r.length-1);return {videos:r,currentIndex:Math.max(0,o)}}),setLoading:t=>e({isLoading:t}),setHasMore:t=>e({hasMore:t}),setError:t=>e({error:t}),reset:()=>e(jt)}));function Y(...e){return Object.assign({},...e.filter(Boolean))}var Ue={flex:(e={})=>({display:"flex",flexDirection:e.direction,alignItems:e.align,justifyContent:e.justify,gap:typeof e.gap=="number"?e.gap:spacing[e.gap||0],flexWrap:e.wrap}),flexCenter:{display:"flex",alignItems:"center",justifyContent:"center"},flexBetween:{display:"flex",alignItems:"center",justifyContent:"space-between"},flexColumn:{display:"flex",flexDirection:"column"},grid:(e={})=>({display:"grid",gridTemplateColumns:typeof e.columns=="number"?`repeat(${e.columns}, 1fr)`:e.columns,gridTemplateRows:typeof e.rows=="number"?`repeat(${e.rows}, 1fr)`:e.rows,gap:typeof e.gap=="number"?e.gap:spacing[e.gap||0]}),absolute:(e={})=>({position:"absolute",...e.inset!==void 0&&{inset:e.inset},...e.top!==void 0&&{top:e.top},...e.right!==void 0&&{right:e.right},...e.bottom!==void 0&&{bottom:e.bottom},...e.left!==void 0&&{left:e.left}}),fixed:(e={})=>({position:"fixed",...e.inset!==void 0&&{inset:e.inset},...e.top!==void 0&&{top:e.top},...e.right!==void 0&&{right:e.right},...e.bottom!==void 0&&{bottom:e.bottom},...e.left!==void 0&&{left:e.left}}),fullScreen:{position:"fixed",inset:0,width:"100%",height:"100%"},fullSize:{width:"100%",height:"100%"},centerAbsolute:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}};({heading:{fontSize:fontSizes.xl,fontWeight:fontWeights.bold,color:colors.text},body:{fontSize:fontSizes.md,fontWeight:fontWeights.normal,color:colors.text},caption:{fontSize:fontSizes.xs,fontWeight:fontWeights.normal,color:colors.textSecondary},videoText:{color:colors.text,textShadow:shadows.text}});var Ie={bg:e=>({backgroundColor:e in colors?colors[e]:e}),rounded:(e="md")=>({borderRadius:radii[e]}),border:(e={})=>({borderWidth:e.width||1,borderStyle:e.style||"solid",borderColor:e.color?e.color in colors?colors[e.color]:e.color:colors.border}),shadow:(e="md")=>({boxShadow:shadows[e]}),opacity:e=>({opacity:e}),glass:(e=20)=>({backgroundColor:colors.overlay,backdropFilter:`blur(${e}px)`,WebkitBackdropFilter:`blur(${e}px)`}),glassLight:(e=10)=>({backgroundColor:colors.overlayLight,backdropFilter:`blur(${e}px)`,WebkitBackdropFilter:`blur(${e}px)`})},en={clickable:{cursor:"pointer",userSelect:"none"}},tn={transition:(e="all",t="normal",n="xhubReel")=>({transitionProperty:Array.isArray(e)?e.join(", "):e,transitionDuration:durations[t],transitionTimingFunction:easings[n]}),noTransition:{transition:"none"}},Qe={scrollY:{overflowY:"auto",overflowX:"hidden",WebkitOverflowScrolling:"touch"},hideScrollbar:{scrollbarWidth:"none",msOverflowStyle:"none"},snapY:{scrollSnapType:"y mandatory",overscrollBehaviorY:"contain"},snapStart:{scrollSnapAlign:"start",scrollSnapStop:"always"}};var nn={square:e=>({width:e,height:e}),width:e=>({width:e}),height:e=>({height:e}),minHeight:e=>({minHeight:e}),maxWidth:e=>({maxWidth:e})};({feedContainer:Y(Ue.fixed({inset:0}),Qe.scrollY,Qe.snapY,Qe.hideScrollbar,Ie.bg("background"),{touchAction:"pan-y"}),feedItem:Y(Ue.fullSize,Qe.snapStart,Ie.bg("background"),{position:"relative"}),actionButton:Y(Ue.flexCenter,nn.square(48),Ie.rounded("full"),en.clickable,tn.transition(["transform","background-color"])),bottomSheet:Y(Ue.fixed({left:0,right:0,bottom:0}),Ie.glass(),Ie.rounded("xl"),{borderBottomLeftRadius:0,borderBottomRightRadius:0})});var rn=class{callbacks={};currentInfo;constructor(){this.currentInfo=this.detectNetwork(),this.setupListeners();}detectNetwork(){let e=navigator.connection;return {online:navigator.onLine,effectiveType:e?.effectiveType??"unknown",downlink:e?.downlink??null,rtt:e?.rtt??null,saveData:e?.saveData??false,type:e?.type??"unknown"}}setupListeners(){window.addEventListener("online",this.handleOnline),window.addEventListener("offline",this.handleOffline);let e=navigator.connection;e&&e.addEventListener("change",this.handleConnectionChange);}handleOnline=()=>{this.currentInfo={...this.currentInfo,online:true},this.callbacks.onOnline?.(),this.callbacks.onNetworkChange?.(this.currentInfo);};handleOffline=()=>{this.currentInfo={...this.currentInfo,online:false},this.callbacks.onOffline?.(),this.callbacks.onNetworkChange?.(this.currentInfo);};handleConnectionChange=()=>{this.currentInfo=this.detectNetwork(),this.callbacks.onNetworkChange?.(this.currentInfo);};subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getInfo(){return this.currentInfo}isSlowNetwork(){let{effectiveType:e}=this.currentInfo;return e==="slow-2g"||e==="2g"}getRecommendedConfig(){let{effectiveType:e,saveData:t}=this.currentInfo;return t||e==="slow-2g"||e==="2g"?{maxBufferLength:10,maxMaxBufferLength:20,startLevel:0}:e==="3g"?{maxBufferLength:20,maxMaxBufferLength:40,startLevel:1}:{}}estimateDownloadTime(e){let{downlink:t}=this.currentInfo;if(!t||t===0)return 1/0;let n=t*1e6/8;return e/n}destroy(){window.removeEventListener("online",this.handleOnline),window.removeEventListener("offline",this.handleOffline);let e=navigator.connection;e&&e.removeEventListener("change",this.handleConnectionChange);}};var on=class{callbacks={};currentInfo={batteryLevel:null,isCharging:false,isLowPowerMode:false};battery=null;constructor(){this.initBattery();}async initBattery(){try{let e=navigator;e.getBattery&&(this.battery=await e.getBattery(),this.updateInfo(),this.setupListeners());}catch{}}updateInfo(){this.battery&&(this.currentInfo={batteryLevel:this.battery.level,isCharging:this.battery.charging,isLowPowerMode:this.battery.level<.2},this.callbacks.onPowerChange?.(this.currentInfo),this.currentInfo.batteryLevel!==null&&this.currentInfo.batteryLevel<.15&&this.callbacks.onLowBattery?.());}setupListeners(){this.battery&&(this.battery.addEventListener("levelchange",()=>this.updateInfo()),this.battery.addEventListener("chargingchange",()=>this.updateInfo()));}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getInfo(){return this.currentInfo}isPowerSaving(){return this.currentInfo.isLowPowerMode&&!this.currentInfo.isCharging}getRecommendedConfig(){return this.isPowerSaving()?{maxBufferLength:15,capLevelToPlayerSize:true}:{}}destroy(){this.callbacks={};}};var sn=class{queue=[];preloaded=new Set;loading=new Set;callbacks={};options;paused=false;velocityThreshold=2e3;constructor(e={}){this.options={maxConcurrent:e.maxConcurrent??2,maxQueue:e.maxQueue??5};}enqueue(e){let t=e.id??e.url;if(!(this.preloaded.has(e.url)||this.queue.some(n=>n.url===e.url))){if(this.queue.length>=this.options.maxQueue){let n=this.queue.shift();n&&this.callbacks.onPreloadCancel?.(n);}this.queue.push({...e,id:t,status:"pending"}),this.queue.sort((n,r)=>r.priority-n.priority),this.processQueue();}}enqueueMany(e){e.forEach(t=>this.enqueue(t));}cancel(e){let t=this.queue.find(n=>n.url===e);t&&(this.queue=this.queue.filter(n=>n.url!==e),this.loading.delete(t.id),this.callbacks.onPreloadCancel?.(t));}cancelAll(){this.queue.forEach(e=>{this.callbacks.onPreloadCancel?.(e);}),this.queue=[],this.loading.clear();}add(e,t,n=0){this.enqueue({id:e,url:t,priority:n});}remove(e){this.queue=this.queue.filter(t=>t.id!==e),this.loading.delete(e);}clear(){this.cancelAll(),this.preloaded.clear();}setPaused(e){this.paused=e,e||this.processQueue();}handleScrollVelocity(e){Math.abs(e)>this.velocityThreshold?this.setPaused(true):this.setPaused(false);}isPreloaded(e){return this.preloaded.has(e)}getStatus(e){let t=this.queue.find(n=>n.url===e);return t?t.status:this.preloaded.has(e)?"loaded":null}getAllStatuses(){return this.queue.map(e=>e.status)}getPreloadedUrls(){return Array.from(this.preloaded)}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}processQueue(){if(!this.paused)for(;this.loading.size<this.options.maxConcurrent&&this.queue.some(e=>e.status==="pending");){let e=this.queue.find(t=>t.status==="pending");e&&this.preloadItem(e);}}async preloadItem(e){e.status="loading",this.loading.add(e.id),this.callbacks.onPreloadStart?.(e);try{let t=document.createElement("link");t.rel="preload",t.as="fetch",t.href=e.url,t.crossOrigin="anonymous",document.head.appendChild(t),await new Promise((n,r)=>{t.onload=()=>n(),t.onerror=()=>r(new Error("Preload failed"));}),e.status="loaded",this.preloaded.add(e.url),this.callbacks.onPreloadComplete?.(e);}catch(t){e.status="error",this.callbacks.onPreloadError?.(e,t);}finally{this.loading.delete(e.id),this.processQueue();}}destroy(){this.clear(),this.callbacks={};}};var an=class{metrics=this.createEmptyMetrics();callbacks={};bufferingStartTime=null;playStartTime=null;isPlaying=false;createEmptyMetrics(){return {videoId:null,sessionStartTime:null,playbackStartTime:null,totalPlayTime:0,totalBufferingTime:0,bufferingCount:0,qualitySwitches:[],errors:[],seeks:[],avgBitrate:0,startupTime:null}}startSession(e,t){this.metrics={...this.createEmptyMetrics(),videoId:e,sessionStartTime:Date.now()},this.notifyUpdate();}endSession(){this.isPlaying&&this.playStartTime&&(this.metrics.totalPlayTime+=Date.now()-this.playStartTime),this.isPlaying=false,this.playStartTime=null;let e={...this.metrics};return this.callbacks.onSessionEnd?.(e),e}trackFirstFrame(){this.metrics.sessionStartTime&&!this.metrics.playbackStartTime&&(this.metrics.playbackStartTime=Date.now(),this.metrics.startupTime=this.metrics.playbackStartTime-this.metrics.sessionStartTime,this.isPlaying=true,this.playStartTime=Date.now(),this.notifyUpdate());}trackBuffering(e){let t=Date.now();e&&!this.bufferingStartTime?(this.bufferingStartTime=t,this.metrics.bufferingCount++):!e&&this.bufferingStartTime&&(this.metrics.totalBufferingTime+=t-this.bufferingStartTime,this.bufferingStartTime=null),this.notifyUpdate();}trackQualitySwitch(e,t,n){this.metrics.qualitySwitches.push({timestamp:Date.now(),fromLevel:e,toLevel:t,automatic:n}),this.notifyUpdate();}trackError(e,t,n){let r=typeof e=="string"?e:e.message;this.metrics.errors.push({timestamp:Date.now(),message:r,recoverable:t}),this.notifyUpdate();}trackBitrate(e){this.metrics.avgBitrate=e,this.notifyUpdate();}trackReplay(){this.playStartTime=Date.now(),this.isPlaying=true,this.notifyUpdate();}trackSeek(e,t,n){this.metrics.seeks.push({timestamp:Date.now(),from:e,to:t,latency:n}),this.notifyUpdate();}subscribe(e){return this.callbacks={...this.callbacks,...e},()=>{this.callbacks={};}}getMetrics(){return {...this.metrics}}notifyUpdate(){this.callbacks.onMetricsUpdate?.(this.getMetrics());}destroy(){this.endSession(),this.callbacks={};}};var Rt=class hn{hls=null;video=null;options;retryCount=0;maxRetries=3;constructor(t={}){this.options=t;}static isSupported(){return ln.isSupported()}attach(t,n){if(this.destroy(),this.video=t,this.retryCount=0,!hn.isSupported()){this.options.callbacks?.onError?.(new Error("HLS.js is not supported in this browser"),false);return}this.options.callbacks?.onStateChange?.("loading"),this.hls=new ln({...Ct,...this.options.config}),this.setupHLSListeners(),this.setupVideoListeners(),this.hls.attachMedia(t),this.hls.loadSource(n);}loadSource(t){if(!this.hls||!this.video)throw new Error("HLS engine not attached to video element");this.retryCount=0,this.options.callbacks?.onStateChange?.("loading"),this.hls.loadSource(t);}destroy(){this.video&&(this.removeVideoListeners(),this.video=null),this.hls&&(this.hls.destroy(),this.hls=null);}getQualityLevels(){return this.hls?this.hls.levels.map(t=>({label:`${t.height}p`,height:t.height,bitrate:t.bitrate})):[]}setQuality(t){this.hls&&(this.hls.currentLevel=t);}getCurrentQuality(){return this.hls?.currentLevel??-1}getBandwidth(){return this.hls?.bandwidthEstimate??0}isAutoQuality(){return this.hls?.autoLevelEnabled??true}startLoad(t){this.hls?.startLoad(t);}stopLoad(){this.hls?.stopLoad();}setupHLSListeners(){this.hls&&(this.hls.on(Events.MANIFEST_PARSED,(t,n)=>{let r=this.getQualityLevels();this.options.callbacks?.onQualityLevelsLoaded?.(r),this.options.callbacks?.onStateChange?.("ready"),this.video?.autoplay&&this.video.play().catch(()=>{});}),this.hls.on(Events.LEVEL_SWITCHED,(t,n)=>{this.options.callbacks?.onQualityChange?.(n.level,this.isAutoQuality());}),this.hls.on(Events.FRAG_LOADED,()=>{this.options.callbacks?.onBandwidthUpdate?.(this.getBandwidth());}),this.hls.on(Events.ERROR,(t,n)=>{this.handleError(n);}));}setupVideoListeners(){this.video&&(this.video.addEventListener("playing",this.handlePlaying),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("canplay",this.handleCanPlay),this.video.addEventListener("error",this.handleVideoError));}removeVideoListeners(){this.video&&(this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("canplay",this.handleCanPlay),this.video.removeEventListener("error",this.handleVideoError));}handlePlaying=()=>{this.options.callbacks?.onStateChange?.("playing");};handlePause=()=>{this.options.callbacks?.onStateChange?.("paused");};handleWaiting=()=>{this.options.callbacks?.onStateChange?.("buffering");};handleEnded=()=>{this.options.callbacks?.onStateChange?.("ended");};handleCanPlay=()=>{this.video?.paused&&this.options.callbacks?.onStateChange?.("ready");};handleVideoError=()=>{let t=this.video?.error;this.options.callbacks?.onError?.(new Error(t?.message??"Video playback error"),false),this.options.callbacks?.onStateChange?.("error");};handleError(t){if(t.fatal){let n=false;switch(t.type){case ErrorTypes.NETWORK_ERROR:this.retryCount<this.maxRetries&&(this.retryCount++,console.warn(`[HLSEngine] Network error, retry ${this.retryCount}/${this.maxRetries}`),this.hls?.startLoad(),n=true);break;case ErrorTypes.MEDIA_ERROR:console.warn("[HLSEngine] Media error, attempting recovery"),this.hls?.recoverMediaError(),n=true;break}n?this.options.callbacks?.onError?.(new Error(`HLS error (recovering): ${t.details}`),true):(this.options.callbacks?.onError?.(new Error(`HLS fatal error: ${t.details}`),false),this.options.callbacks?.onStateChange?.("error"),this.destroy());}else console.warn("[HLSEngine] Non-fatal error:",t.details);}};async function pn(e,t={}){try{return await e.play(),{success:!0}}catch(n){let r=n;if(r.name==="NotAllowedError"){e.muted=true;try{return await e.play(),{success:!0,mutedAutoplay:!0}}catch{return t.onNeedsUserGesture?.(),{success:false,reason:"user_gesture_required"}}}return {success:false,reason:"unknown",error:r}}}var cn=[.5,1,1.5,2],rt=class It{video=null;options;lastQuality=null;bandwidthSamples=[];constructor(t={}){this.options=t;}static isSupported(){return typeof document>"u"?false:document.createElement("video").canPlayType("application/vnd.apple.mpegurl")!==""}static isIOS(){return typeof navigator>"u"?false:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}attach(t,n){this.destroy(),this.video=t,this.options.callbacks?.onStateChange?.("loading"),this.setupVideoListeners(),t.src=n,t.load();}loadSource(t){if(!this.video)throw new Error("Native HLS not attached to video element");this.options.callbacks?.onStateChange?.("loading"),this.video.src=t,this.video.load();}async play(){return this.video?pn(this.video,{onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture}):{success:false,reason:"unknown"}}destroy(){this.video&&(this.removeVideoListeners(),this.video.removeAttribute("src"),this.video.load(),this.video=null),this.bandwidthSamples=[],this.lastQuality=null;}getQualityLevels(){let t=this.estimateCurrentQuality(),n=[{label:"Auto",height:0,bitrate:0}];return t&&n.push(t),n}setQuality(t){console.warn("[NativeHLS] Quality selection not supported, using auto");}getCurrentQuality(){return -1}estimateCurrentQuality(){if(!this.video||this.video.videoHeight===0)return null;let t=this.video.videoHeight,n=this.estimateBitrate();return {label:`${t}p`,height:t,bitrate:n}}estimateBitrate(){if(this.bandwidthSamples.length>0){let n=this.bandwidthSamples.reduce((r,o)=>r+o,0);return Math.round(n/this.bandwidthSamples.length)}if(!this.video)return 0;let t=this.video.videoHeight;return t>=1080?5e6:t>=720?25e5:t>=480?1e6:t>=360?5e5:25e4}getBandwidth(){return this.estimateBitrate()}isAutoQuality(){return true}startLoad(){this.video?.load();}stopLoad(){this.video&&(this.video.preload="none");}async enterFullscreen(){let t=this.video;if(t){if(t.requestFullscreen){await t.requestFullscreen();return}t.webkitEnterFullscreen&&await t.webkitEnterFullscreen();}}async exitFullscreen(){let t=this.video;if(t){if(document.exitFullscreen){await document.exitFullscreen();return}t.webkitExitFullscreen&&await t.webkitExitFullscreen();}}isFullscreen(){let t=this.video;return t?document.fullscreenElement?document.fullscreenElement===t:t.webkitDisplayingFullscreen??false:false}isFullscreenSupported(){let t=this.video;return t?!!(t.requestFullscreen||t.webkitSupportsFullscreen):false}isPlaybackRateSupported(t){return It.isIOS()?cn.includes(t):t>=.5&&t<=2}getSupportedPlaybackRates(){return It.isIOS()?[...cn]:[.5,.75,1,1.25,1.5,2]}setupVideoListeners(){this.video&&(this.video.addEventListener("loadedmetadata",this.handleLoadedMetadata),this.video.addEventListener("playing",this.handlePlaying),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("canplay",this.handleCanPlay),this.video.addEventListener("error",this.handleError),this.video.addEventListener("resize",this.handleResize),this.video.addEventListener("progress",this.handleProgress));}removeVideoListeners(){this.video&&(this.video.removeEventListener("loadedmetadata",this.handleLoadedMetadata),this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("canplay",this.handleCanPlay),this.video.removeEventListener("error",this.handleError),this.video.removeEventListener("resize",this.handleResize),this.video.removeEventListener("progress",this.handleProgress));}handleLoadedMetadata=()=>{let t=this.getQualityLevels();this.options.callbacks?.onQualityLevelsLoaded?.(t),this.options.callbacks?.onStateChange?.("ready"),this.checkQualityChange();};handlePlaying=()=>{this.options.callbacks?.onStateChange?.("playing");};handlePause=()=>{this.options.callbacks?.onStateChange?.("paused");};handleWaiting=()=>{this.options.callbacks?.onStateChange?.("buffering");};handleEnded=()=>{this.options.callbacks?.onStateChange?.("ended");};handleCanPlay=()=>{this.video?.paused&&this.options.callbacks?.onStateChange?.("ready");};handleError=()=>{let t=this.video?.error,n=t?.message??"Video playback error",r=t?.code!==MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED;this.options.callbacks?.onError?.(new Error(n),r),this.options.callbacks?.onStateChange?.("error");};handleResize=()=>{this.checkQualityChange();};handleProgress=()=>{this.updateBandwidthEstimate();};checkQualityChange(){let t=this.estimateCurrentQuality();t&&(!this.lastQuality||this.lastQuality.height!==t.height)&&(this.lastQuality=t,this.options.callbacks?.onQualityChange?.(t));}updateBandwidthEstimate(){if(this.video&&typeof performance<"u"&&performance.getEntriesByType){let n=performance.getEntriesByType("resource").filter(r=>r.initiatorType==="video"||r.name.includes(".ts")||r.name.includes(".m3u8"));if(n.length>0){let o=n.slice(-5).filter(s=>s.transferSize>0&&s.duration>0).map(s=>s.transferSize*8/(s.duration/1e3));if(o.length>0){let s=o.reduce((d,u)=>d+u,0)/o.length;this.bandwidthSamples.push(s),this.bandwidthSamples.length>10&&this.bandwidthSamples.shift(),this.options.callbacks?.onBandwidthUpdate?.(s);}}}}},fn=class{engine=null;video=null;options;isNative=false;animationFrameId=null;isTracking=false;networkDetector=null;powerManager=null;preloadManager=null;analytics=null;cleanupFunctions=[];wasPlayingBeforeOffline=false;wasPlayingBeforeLowBattery=false;constructor(e={}){this.options={enableNetworkAdaptation:true,enablePowerAdaptation:true,enableAnalytics:false,...e},this.isNative=this.shouldUseNative(),this.initializeServices();}static isSupported(){return Rt.isSupported()||rt.isSupported()}attach(e,t,n){this.video=e,this.destroyEngine(),this.setupVideoListeners(),this.analytics&&n&&this.analytics.startSession(n,e);let r=this.getAdaptedConfig();this.isNative?this.engine=new rt({callbacks:{onStateChange:this.options.callbacks?.onStateChange,onError:this.options.callbacks?.onError,onQualityLevelsLoaded:this.options.callbacks?.onQualityLevelsLoaded,onBandwidthUpdate:this.options.callbacks?.onBandwidthUpdate,onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture,onQualityChange:o=>{this.options.callbacks?.onQualityChange?.(-1,o);}}}):this.engine=new Rt({config:r,callbacks:{onStateChange:this.options.callbacks?.onStateChange,onError:this.options.callbacks?.onError,onQualityLevelsLoaded:this.options.callbacks?.onQualityLevelsLoaded,onBandwidthUpdate:this.options.callbacks?.onBandwidthUpdate,onQualityChange:(o,s)=>{let d=this.engine?.getQualityLevels()??[],u=o>=0&&o<d.length?d[o]:void 0;this.options.callbacks?.onQualityChange?.(s?-1:o,u);}}}),this.engine.attach(e,t);}loadSource(e,t){if(!this.engine||!this.video)throw new Error("Player not attached to video element");this.analytics&&(this.analytics.endSession(),t&&this.analytics.startSession(t,this.video)),this.engine.loadSource(e);}destroy(){this.destroyEngine(),this.destroyServices();}async play(){return this.video?this.isNative&&this.engine instanceof rt?this.engine.play():pn(this.video,{onNeedsUserGesture:this.options.callbacks?.onNeedsUserGesture}):{success:false,reason:"unknown"}}pause(){this.video?.pause();}async togglePlay(){return this.video?.paused?this.play():(this.pause(),{success:true})}seek(e){if(this.video){let t=this.video.currentTime;this.video.currentTime=Math.max(0,Math.min(e,this.video.duration||0)),this.analytics?.trackSeek(t,e,0);}}seekForward(e=10){this.video&&this.seek(this.video.currentTime+e);}seekBackward(e=10){this.video&&this.seek(this.video.currentTime-e);}getCurrentTime(){return this.video?.currentTime??0}getDuration(){return this.video?.duration??0}setVolume(e){this.video&&(this.video.volume=Math.max(0,Math.min(1,e)));}getVolume(){return this.video?.volume??1}setMuted(e){this.video&&(this.video.muted=e);}isMuted(){return this.video?.muted??true}toggleMute(){this.setMuted(!this.isMuted());}setPlaybackRate(e){this.video&&(this.video.playbackRate=e);}getPlaybackRate(){return this.video?.playbackRate??1}getQualityLevels(){return this.engine?.getQualityLevels()??[]}setQuality(e){let t=this.getCurrentQuality();this.engine?.setQuality(e),t!==e&&this.analytics?.trackQualitySwitch(t,e,e===-1);}getCurrentQuality(){return this.engine?.getCurrentQuality()??-1}isUsingNative(){return this.isNative}getVideoElement(){return this.video}getBuffered(){if(!this.video)return 0;let e=this.video.buffered,t=this.video.currentTime;for(let n=0;n<e.length;n++)if(t>=e.start(n)&&t<=e.end(n))return e.end(n)-t;return 0}getNetworkInfo(){return this.networkDetector?.getInfo()??null}getPowerInfo(){return this.powerManager?.getInfo()??null}getPreloadManager(){return this.preloadManager}getAnalytics(){return this.analytics?.getMetrics()??null}isSlowNetwork(){return this.networkDetector?.isSlowNetwork()??false}isPowerSaving(){return this.powerManager?.isPowerSaving()??false}shouldUseNative(){return this.options.preferNative!==false&&rt.isSupported()?true:!Rt.isSupported()}initializeServices(){if(this.options.enableNetworkAdaptation){this.networkDetector=new rn;let e=this.networkDetector.subscribe({onNetworkChange:this.handleNetworkChange,onOffline:()=>this.options.callbacks?.onError?.(new Error("Network offline"),true)});this.cleanupFunctions.push(e);}if(this.options.enablePowerAdaptation){this.powerManager=new on;let e=this.powerManager.subscribe({onPowerChange:this.handlePowerChange});this.cleanupFunctions.push(e),this.cleanupFunctions.push(()=>this.powerManager?.destroy());}if(this.options.preloadConfig&&(this.preloadManager=new sn(this.options.preloadConfig),this.cleanupFunctions.push(()=>this.preloadManager?.destroy())),this.options.enableAnalytics){this.analytics=new an;let e=this.analytics.subscribe({onMetricsUpdate:t=>this.options.callbacks?.onAnalyticsUpdate?.(t)});this.cleanupFunctions.push(e),this.cleanupFunctions.push(()=>this.analytics?.destroy());}}destroyServices(){this.cleanupFunctions.forEach(e=>e()),this.cleanupFunctions=[],this.networkDetector=null,this.powerManager=null,this.preloadManager=null,this.analytics=null;}destroyEngine(){this.stopProgressTracking(),this.removeVideoListeners(),this.engine&&(this.engine.destroy(),this.engine=null);}getAdaptedConfig(){let e={};return this.networkDetector&&(e={...e,...this.networkDetector.getRecommendedConfig()}),this.powerManager&&(e={...e,...this.powerManager.getRecommendedConfig()}),e}isNetworkBelowThreshold(e,t){let n=["slow-2g","2g","3g","4g","5g","unknown"],r=n.indexOf(e),o=n.indexOf(t);return e==="unknown"?false:r>=0&&r<=o}handleNetworkChange=e=>{this.options.callbacks?.onNetworkChange?.(e);let t=this.options.lowQualityThreshold??"2g",n=this.isNetworkBelowThreshold(e.effectiveType,t);this.options.autoQualityOnNetworkChange&&this.engine&&(n?this.setQuality(0):(e.effectiveType==="4g"||e.effectiveType==="5g")&&this.setQuality(-1)),this.options.autoPauseOnOffline&&!e.online&&(this.wasPlayingBeforeOffline=this.video?!this.video.paused:false,this.pause()),this.options.autoResumeOnOnline&&e.online&&this.wasPlayingBeforeOffline&&(this.play(),this.wasPlayingBeforeOffline=false),this.preloadManager&&this.preloadManager.setPaused(e.effectiveType==="2g"||!e.online);};handlePowerChange=e=>{this.options.callbacks?.onPowerChange?.(e);let t=this.options.lowBatteryThreshold??.15,n=e.batteryLevel!==null&&e.batteryLevel<t;this.options.autoPauseOnLowBattery&&n&&!e.isCharging&&(this.wasPlayingBeforeLowBattery=this.video?!this.video.paused:false,this.pause()),this.wasPlayingBeforeLowBattery&&(e.isCharging||e.batteryLevel!==null&&e.batteryLevel>=t+.05)&&(this.play(),this.wasPlayingBeforeLowBattery=false),this.preloadManager&&e.isLowPowerMode&&this.preloadManager.setPaused(true);};setupVideoListeners(){this.video&&(this.video.addEventListener("timeupdate",this.handleTimeUpdate),this.video.addEventListener("progress",this.handleProgress),this.video.addEventListener("volumechange",this.handleVolumeChange),this.video.addEventListener("ratechange",this.handleRateChange),this.video.addEventListener("play",this.handlePlay),this.video.addEventListener("pause",this.handlePause),this.video.addEventListener("ended",this.handleEnded),this.video.addEventListener("waiting",this.handleWaiting),this.video.addEventListener("playing",this.handlePlaying));}removeVideoListeners(){this.video&&(this.video.removeEventListener("timeupdate",this.handleTimeUpdate),this.video.removeEventListener("progress",this.handleProgress),this.video.removeEventListener("volumechange",this.handleVolumeChange),this.video.removeEventListener("ratechange",this.handleRateChange),this.video.removeEventListener("play",this.handlePlay),this.video.removeEventListener("pause",this.handlePause),this.video.removeEventListener("ended",this.handleEnded),this.video.removeEventListener("waiting",this.handleWaiting),this.video.removeEventListener("playing",this.handlePlaying));}handleTimeUpdate=()=>{this.video&&this.options.callbacks?.onTimeUpdate?.(this.video.currentTime,this.video.duration||0);};handleProgress=()=>{this.options.callbacks?.onProgress?.(this.getBuffered());};handleVolumeChange=()=>{this.video&&this.options.callbacks?.onVolumeChange?.(this.video.volume,this.video.muted);};handleRateChange=()=>{this.video&&this.options.callbacks?.onRateChange?.(this.video.playbackRate);};handlePlay=()=>{this.options.enableSmoothTimeUpdates&&this.startProgressTracking();};handlePause=()=>{this.stopProgressTracking();};handleEnded=()=>{this.stopProgressTracking(),this.analytics&&this.analytics.endSession();};handleWaiting=()=>{this.analytics?.trackBuffering(true);};handlePlaying=()=>{this.analytics?.trackBuffering(false),this.analytics?.trackFirstFrame();};startProgressTracking(){if(this.isTracking||!this.video)return;this.isTracking=true;let e=()=>{if(!this.video||this.video.paused||this.video.ended){this.isTracking=false,this.animationFrameId=null;return}this.options.callbacks?.onTimeUpdate?.(this.video.currentTime,this.video.duration||0),this.animationFrameId=requestAnimationFrame(e);};this.animationFrameId=requestAnimationFrame(e);}stopProgressTracking(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.isTracking=false;}},Er=[{from:"idle",to:"loading"},{from:"loading",to:"ready"},{from:"loading",to:"error"},{from:"ready",to:"playing"},{from:"ready",to:"loading"},{from:"ready",to:"error"},{from:"playing",to:"paused"},{from:"playing",to:"buffering"},{from:"playing",to:"ended"},{from:"playing",to:"error"},{from:"playing",to:"loading"},{from:"paused",to:"playing"},{from:"paused",to:"buffering"},{from:"paused",to:"loading"},{from:"paused",to:"error"},{from:"buffering",to:"playing"},{from:"buffering",to:"paused"},{from:"buffering",to:"stalled"},{from:"buffering",to:"error"},{from:"stalled",to:"playing"},{from:"stalled",to:"buffering"},{from:"stalled",to:"error"},{from:"stalled",to:"loading"},{from:"ended",to:"playing"},{from:"ended",to:"loading"},{from:"ended",to:"idle"},{from:"error",to:"loading"},{from:"error",to:"idle"},{from:"*",to:"idle"}],Cr=class{_state="idle";listeners=new Set;stalledTimeout=null;stalledThreshold=3e3;get state(){return this._state}transition(e){if(!this.canTransition(e))return console.warn(`[PlayerStateMachine] Invalid transition: ${this._state} -> ${e}`),false;let n=this._state;return this._state=e,e==="buffering"?this.startStalledTimer():this.clearStalledTimer(),this.listeners.forEach(r=>r(e,n)),true}canTransition(e){let t=Er.find(n=>(n.from===this._state||n.from==="*")&&n.to===e);return !(!t||t.guard&&!t.guard())}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}reset(){this.clearStalledTimer(),this._state="idle";}isPlaying(){return this._state==="playing"}canPlay(){return ["ready","paused","ended"].includes(this._state)}isLoading(){return ["loading","buffering"].includes(this._state)}hasError(){return this._state==="error"}startStalledTimer(){this.clearStalledTimer(),this.stalledTimeout=setTimeout(()=>{this._state==="buffering"&&this.transition("stalled");},this.stalledThreshold);}clearStalledTimer(){this.stalledTimeout&&(clearTimeout(this.stalledTimeout),this.stalledTimeout=null);}};function kr(){return new Cr}function mn(){let e=useMemo(()=>kr(),[]),[t,n]=useState(e.state);useEffect(()=>e.subscribe(d=>{n(d);}),[e]);let r=useCallback(s=>e.transition(s),[e]),o=useCallback(()=>{e.reset(),n("idle");},[e]);return {state:t,isPlaying:t==="playing",isPaused:t==="paused",isLoading:t==="loading",isBuffering:t==="buffering",isStalled:t==="stalled",isEnded:t==="ended",hasError:t==="error",canPlay:e.canPlay(),transition:r,reset:o}}function gn(e){let{volume:t,isMuted:n,setVolume:r,toggleMute:o,setMuted:s}=_e();useEffect(()=>{let i=e.current;i&&(i.volume=t,i.muted=n);},[e,t,n]),useEffect(()=>{let i=e.current;if(!i)return;let a=()=>{i.volume!==t&&r(i.volume),i.muted!==n&&s(i.muted);};return i.addEventListener("volumechange",a),()=>i.removeEventListener("volumechange",a)},[e,t,n,r,s]);let d=useCallback(i=>{let a=Math.max(0,Math.min(1,i));r(a),e.current&&(e.current.volume=a),a>0&&n&&(s(false),e.current&&(e.current.muted=false));},[e,n,r,s]),u=useCallback(()=>{o(),e.current&&(e.current.muted=!n);},[e,n,o]),l=useCallback(()=>{n||(s(true),e.current&&(e.current.muted=true));},[e,n,s]),m=useCallback(()=>{n&&(s(false),e.current&&(e.current.muted=false));},[e,n,s]);return {volume:t,isMuted:n,setVolume:d,toggleMute:u,mute:l,unmute:m}}function yn(e,t={}){let{enableSmoothTracking:n=false}=t,[r,o]=useState(0),[s,d]=useState(0),[u,l]=useState(0),[m,i]=useState([]),a=useRef(null),p=useRef(false),c=s>0?r/s*100:0,g=useCallback(h=>{let y=[],P=h.buffered;for(let C=0;C<P.length;C++)y.push({start:P.start(C),end:P.end(C)});i(y);let O=0;for(let C of y)if(h.currentTime>=C.start&&h.currentTime<=C.end){O=C.end-h.currentTime;break}l(O);},[]),f=useCallback(()=>{a.current!==null&&(cancelAnimationFrame(a.current),a.current=null),p.current=false;},[]),S=useCallback(()=>{let h=e.current;if(!h||p.current)return;p.current=true;let y=()=>{if(!h||h.paused||h.ended){p.current=false,a.current=null;return}o(h.currentTime),a.current=requestAnimationFrame(y);};a.current=requestAnimationFrame(y);},[e]);useEffect(()=>{let h=e.current;if(!h)return;let y=()=>{o(h.currentTime);},P=()=>{d(h.duration||0);},O=()=>{d(h.duration||0);},C=()=>{g(h);},B=()=>{n&&S();},z=()=>{f();},H=()=>{f();},A=()=>{o(h.currentTime);},v=()=>{o(h.currentTime),g(h);};return h.addEventListener("timeupdate",y),h.addEventListener("loadedmetadata",P),h.addEventListener("durationchange",O),h.addEventListener("progress",C),h.addEventListener("play",B),h.addEventListener("pause",z),h.addEventListener("ended",H),h.addEventListener("seeking",A),h.addEventListener("seeked",v),h.readyState>=1&&(d(h.duration||0),o(h.currentTime)),h.readyState>=3&&g(h),!h.paused&&n&&S(),()=>{h.removeEventListener("timeupdate",y),h.removeEventListener("loadedmetadata",P),h.removeEventListener("durationchange",O),h.removeEventListener("progress",C),h.removeEventListener("play",B),h.removeEventListener("pause",z),h.removeEventListener("ended",H),h.removeEventListener("seeking",A),h.removeEventListener("seeked",v),f();}},[e,n,g,S,f]);let b=useCallback(h=>{let y=e.current;if(!y||!isFinite(y.duration))return;let P=Math.max(0,Math.min(h,y.duration));y.currentTime=P,o(P);},[e]),V=useCallback(h=>{let y=e.current;if(!y||!isFinite(y.duration))return;let O=Math.max(0,Math.min(100,h))/100*y.duration;y.currentTime=O,o(O);},[e]),L=s>0&&isFinite(s);return {currentTime:r,duration:s,buffered:u,progress:c,bufferedRanges:m,seek:b,seekToProgress:V,isSeekable:L,startSmoothTracking:S,stopSmoothTracking:f}}function vn(e){let{quality:t,setQuality:n}=_e(),[r,o]=useState(-1),[s,d]=useState([]);useEffect(()=>{if(!e)return;let i=e.getQualityLevels();d(i),o(e.getCurrentQuality());},[e]),useEffect(()=>{if(!(!e||s.length===0))if(t==="auto")e.setQuality(-1),o(-1);else {let i=parseInt(t.replace("p","")),a=s.findIndex(p=>p.height===i);a!==-1&&(e.setQuality(a),o(a));}},[e,t,s]);let u=r===-1,l=useCallback(i=>{if(e)if(typeof i=="number")if(e.setQuality(i),o(i),i===-1)n("auto");else {let a=s[i];a&&n(`${a.height}p`);}else n(i);},[e,s,n]),m=useCallback(()=>{l("auto");},[l]);return {quality:t,currentLevel:r,availableLevels:s,isAuto:u,setQuality:l,setAuto:m}}function Mt(e){return e<1e3?e.toString():e<1e4?`${(e/1e3).toFixed(1)}K`:e<1e6?`${Math.floor(e/1e3)}K`:`${(e/1e6).toFixed(1)}M`}var Mr={position:"absolute",right:spacing[4],bottom:160,display:"flex",flexDirection:"column",alignItems:"center",gap:components.actionBar.gap,zIndex:10},Vr={display:"flex",flexDirection:"column",alignItems:"center",gap:components.actionBar.iconCountGap,background:"none",border:"none",padding:0,cursor:"pointer"},Ar={width:components.actionBar.iconSize,height:components.actionBar.iconSize,display:"flex",alignItems:"center",justifyContent:"center"},Fr={fontSize:fontSizes.xs,fontWeight:fontWeights.normal,color:colors.text,textShadow:shadows.text,lineHeight:components.actionBar.counterLineHeight,textAlign:"center"},Or={display:"flex",flexDirection:"column",alignItems:"center",position:"relative",width:components.profileAction.avatarSize,height:55},bn={width:components.profileAction.avatarSize,height:components.profileAction.avatarSize,borderRadius:"50%",objectFit:"cover",cursor:"pointer",background:colors.surface},Hr={position:"absolute",bottom:0,left:"50%",transform:"translateX(-50%)",width:components.profileAction.followButtonSize,height:components.profileAction.followButtonSize,borderRadius:"50%",backgroundColor:colors.like,border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},Dr=({filled:e,color:t="white"})=>e?jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:components.actionBar.iconSize,height:components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.74988 11.0538C1.74988 6.75595 4.69822 2.91699 9.20877 2.91699C11.4347 2.91699 12.9986 3.9593 13.9999 4.96978C15.0011 3.95929 16.565 2.91699 18.791 2.91699C23.3015 2.91699 26.2499 6.75595 26.2499 11.0538C26.2499 15.3962 23.6265 18.9036 20.8781 21.3587C18.1288 23.8145 15.1442 25.3171 14.1843 25.6371L13.9999 25.6985L13.8154 25.6371C12.8555 25.3171 9.87093 23.8145 7.12168 21.3587C4.37329 18.9036 1.74988 15.3962 1.74988 11.0538ZM17.7449 6.41699C17.2617 6.41699 16.8699 6.80874 16.8699 7.29199C16.8699 7.77524 17.2617 8.16699 17.7449 8.16699C19.6221 8.16699 20.9952 9.75855 20.9952 11.8241C20.9952 12.3073 21.387 12.6991 21.8702 12.6991C22.3535 12.6991 22.7452 12.3073 22.7452 11.8241C22.7452 9.02543 20.8066 6.41699 17.7449 6.41699Z",fill:t})}):jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:components.actionBar.iconSize,height:components.actionBar.iconSize,viewBox:"0 0 24 24",fill:"none",children:[jsx("path",{d:"M15.21 5.5C14.7957 5.5 14.46 5.83579 14.46 6.25C14.46 6.66421 14.7957 7 15.21 7C16.819 7 17.996 8.3642 17.996 10.1346C17.996 10.5488 18.3317 10.8846 18.746 10.8846C19.1602 10.8846 19.496 10.5488 19.496 10.1346C19.496 7.7358 17.8342 5.5 15.21 5.5Z",fill:t}),jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.89327 2.25C3.85788 2.25 1.24994 5.6858 1.24994 9.47438C1.24994 13.301 3.5604 16.37 5.9378 18.4936C8.31629 20.6183 10.9036 21.9251 11.7628 22.2115L11.9999 22.2906L12.2371 22.2115C13.0963 21.9251 15.6836 20.6183 18.0621 18.4936C20.4395 16.37 22.7499 13.301 22.7499 9.47438C22.7499 5.6858 20.142 2.25 16.1066 2.25C14.2397 2.25 12.8941 3.06969 11.9999 3.91063C11.1058 3.06969 9.76018 2.25 7.89327 2.25ZM2.74994 9.47438C2.74994 6.3142 4.8731 3.75 7.89327 3.75C9.60588 3.75 10.7397 4.66987 11.4269 5.48383L11.9999 6.16259L12.573 5.48383C13.2602 4.66987 14.394 3.75 16.1066 3.75C19.1268 3.75 21.2499 6.3142 21.2499 9.47438C21.2499 12.6733 19.3104 15.3672 17.0628 17.375C15.0361 19.1854 12.8741 20.3336 11.9999 20.6978C11.1257 20.3336 8.96379 19.1854 6.93708 17.375C4.68948 15.3672 2.74994 12.6733 2.74994 9.47438Z",fill:t})]}),Br=()=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:components.actionBar.iconSize,height:components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsx("path",{d:"M14 1.45801C7.07347 1.45801 1.45837 7.0731 1.45837 13.9997C1.45837 16.3815 2.1232 18.6107 3.27778 20.5088L2.36541 23.0178C1.77294 24.6471 3.35258 26.2268 4.98188 25.6343L7.49089 24.7219C9.389 25.8765 11.6182 26.5413 14 26.5413C20.9266 26.5413 26.5417 20.9262 26.5417 13.9997C26.5417 7.0731 20.9266 1.45801 14 1.45801Z",fill:"white"})}),Nr=({filled:e})=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:components.actionBar.iconSize,height:components.actionBar.iconSize,viewBox:"0 0 28 28",fill:"none",children:jsx("path",{d:"M16.6904 1.45801H11.2789C10.2487 1.458 9.4224 1.45799 8.75434 1.51253C8.06795 1.56857 7.47186 1.68652 6.92253 1.96632C6.90122 1.97718 6.88036 1.98891 6.86 2.00147C5.64436 2.75199 4.94533 3.52276 4.62739 4.64643C4.48015 5.1668 4.42512 5.72644 4.40084 6.3243C4.38332 6.75558 4.3811 7.24294 4.37866 7.77623C4.37775 7.97537 4.37678 8.18091 4.375 8.39232V24.8275C4.375 25.7739 5.14242 26.5413 6.08883 26.5413C6.51994 26.5413 6.93517 26.3792 7.25226 26.0859L13.3276 20.4783C13.3386 20.4682 13.3493 20.4578 13.3597 20.4471C13.5821 20.2197 13.743 20.0895 13.8601 20.0183C13.9156 19.9846 13.9524 19.9697 13.9731 19.9631C13.9833 19.9599 13.9898 19.9585 13.9933 19.958L13.9975 19.9575L13.9992 19.9574C13.9992 19.9574 14.0065 19.9571 14.0257 19.9632C14.0466 19.9698 14.0837 19.9849 14.1394 20.0187C14.2569 20.0901 14.4182 20.2206 14.641 20.4479C14.6512 20.4583 14.6616 20.4684 14.6724 20.4783L20.7477 26.0859C21.0648 26.3792 21.4801 26.5413 21.9112 26.5413C22.8576 26.5413 23.625 25.7739 23.625 24.8275V8.3619C23.625 7.33168 23.625 6.5054 23.5705 5.83735C23.5144 5.15096 23.3965 4.55487 23.1167 4.00554C23.1058 3.98416 23.094 3.96325 23.0814 3.94284C22.3309 2.72781 21.5599 2.0287 20.4364 1.71046C19.9159 1.56305 19.3562 1.50785 18.7583 1.48352C18.3245 1.46588 17.8344 1.46376 17.2978 1.46144C17.1014 1.46059 16.8988 1.45968 16.6904 1.45801Z",fill:e?colors.warning:"white"})}),_r=()=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:28,height:28,viewBox:"0 0 28 28",fill:"none",children:[jsx("path",{d:"M20.6583 8.99195C21.1139 8.53634 21.1139 7.79765 20.6583 7.34203L14.8249 1.5087C14.6061 1.28991 14.3094 1.16699 14 1.16699C13.6905 1.16699 13.3938 1.28991 13.175 1.5087L7.34167 7.34204C6.88606 7.79765 6.88606 8.53634 7.34167 8.99195C7.79728 9.44756 8.53597 9.44756 8.99158 8.99195L12.8333 5.15024L12.8333 17.5003C12.8333 18.1447 13.3556 18.667 14 18.667C14.6443 18.667 15.1666 18.1447 15.1666 17.5003L15.1666 5.15024L19.0083 8.99195C19.4639 9.44756 20.2026 9.44756 20.6583 8.99195Z",fill:"white"}),jsx("path",{d:"M24.4562 22.2708C24.4991 21.7457 24.5 21.0663 24.5 20.067V16.3337C24.5 15.6893 25.0223 15.167 25.6666 15.167C26.311 15.167 26.8333 15.6893 26.8333 16.3337L26.8333 20.1152C26.8333 21.0543 26.8333 21.8294 26.7817 22.4608C26.7282 23.1166 26.6132 23.7194 26.3247 24.2856C25.8772 25.1637 25.1633 25.8776 24.2852 26.325C23.719 26.6135 23.1162 26.7285 22.4604 26.7821C21.829 26.8337 21.054 26.8337 20.1149 26.8337H7.88508C6.94599 26.8337 6.17087 26.8337 5.5395 26.7821C4.88372 26.7285 4.28089 26.6135 3.71467 26.325C2.83658 25.8776 2.12267 25.1637 1.67526 24.2856C1.38676 23.7194 1.27176 23.1166 1.21819 22.4608C1.1666 21.8294 1.16661 21.0543 1.16663 20.1152V16.3337C1.16663 15.6893 1.68896 15.167 2.33329 15.167C2.97762 15.167 3.49996 15.6893 3.49996 16.3337L3.49996 20.067C3.49996 21.0663 3.50087 21.7457 3.54377 22.2708C3.58556 22.7823 3.66131 23.0438 3.75428 23.2263C3.97798 23.6653 4.33494 24.0223 4.77398 24.246C4.95645 24.339 5.21802 24.4147 5.7295 24.4565C6.25461 24.4994 6.93395 24.5003 7.93329 24.5003H20.0666C21.066 24.5003 21.7453 24.4994 22.2704 24.4565C22.7819 24.4147 23.0435 24.339 23.2259 24.246C23.665 24.0223 24.0219 23.6653 24.2456 23.2263C24.3386 23.0438 24.4144 22.7823 24.4562 22.2708Z",fill:"white"})]}),Ur=()=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:12,height:12,viewBox:"0 0 12 12",fill:"white",children:jsx("path",{d:"M6 1V11M1 6H11",stroke:"white",strokeWidth:2,strokeLinecap:"round"})}),Qr=()=>jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",children:jsx("path",{d:"M2 6L5 9L10 3",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})});function zr({avatarUrl:e,isFollowed:t=false,onClick:n,onFollow:r}){return jsxs("div",{style:Or,children:[jsx(motion.button,{style:{background:"none",border:"none",padding:0,cursor:"pointer"},onClick:n,whileTap:{scale:.95},"aria-label":"View profile",children:e?jsx("img",{src:e,alt:"Profile",style:bn}):jsx("div",{style:bn})}),!t&&r&&jsx(motion.button,{style:Hr,onClick:o=>{o.stopPropagation(),r();},whileTap:{scale:.9},animate:t?{scale:[1,1.2,1]}:{scale:1},transition:{type:"spring",...springs.bouncy},"aria-label":t?"Following":"Follow",children:t?jsx(Qr,{}):jsx(Ur,{})})]})}function it({icon:e,count:t,isActive:n=false,onClick:r,label:o}){return jsxs(motion.button,{style:Vr,onClick:r,"aria-label":o,whileTap:{scale:.9},transition:{type:"spring",...springs.bouncy},children:[jsx(motion.div,{style:Ar,animate:n?{scale:[1,1.2,1]}:{scale:1},transition:n?{duration:.3,ease:[.32,.72,0,1]}:{type:"spring",...springs.default},children:e}),t!==void 0&&jsx("span",{style:Fr,children:Mt(t)})]})}function st({likeCount:e,commentCount:t,shareCount:n,saveCount:r,isLiked:o=false,isSaved:s=false,onLike:d,onComment:u,onShare:l,onSave:m,avatarUrl:i,onProfileClick:a,onFollow:p,isFollowed:c=false,style:g,className:f=""}){return jsxs("div",{style:mergeStyles(Mr,g),className:f,children:[i&&jsx(zr,{avatarUrl:i,isFollowed:c,onClick:a,onFollow:p}),jsx(it,{icon:jsx(Dr,{filled:o,color:o?colors.like:"white"}),count:e,isActive:o,onClick:d,label:o?"Unlike":"Like"}),jsx(it,{icon:jsx(Br,{}),count:t,onClick:u,label:"Comments"}),jsx(it,{icon:jsx(Nr,{filled:s}),count:r,isActive:s,onClick:m,label:s?"Unsave":"Save"}),jsx(it,{icon:jsx(_r,{}),count:n,onClick:l,label:"Share"})]})}var Xr={display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",cursor:"pointer",borderRadius:radii.full,transitionProperty:"background-color, transform, opacity",transitionDuration:durations.fast,transitionTimingFunction:easings.xhubReel,userSelect:"none"},Kr={sm:{width:32,height:32},md:{width:components.tapArea,height:components.tapArea},lg:{width:56,height:56}},jr={default:{backgroundColor:colors.surface,color:colors.text},ghost:{backgroundColor:"transparent",color:colors.text},glass:{backgroundColor:"rgba(0, 0, 0, 0.2)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",color:colors.text}},Zr={opacity:.5,cursor:"not-allowed",pointerEvents:"none"},At=forwardRef(({icon:e,size:t="md",variant:n="ghost",disabled:r,style:o,className:s="",...d},u)=>jsx("button",{ref:u,type:"button",disabled:r,style:mergeStyles(Xr,Kr[t],jr[n],r&&Zr,o),className:s,...d,children:e}));At.displayName="IconButton";var si={position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:zIndices.overlay},ai={display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",borderRadius:"50%",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",cursor:"pointer"},li=({size:e})=>jsx("svg",{width:e*.4,height:e*.4,viewBox:"0 0 24 24",fill:colors.text,children:jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),di=({size:e})=>jsxs("svg",{width:e*.35,height:e*.35,viewBox:"0 0 24 24",fill:colors.text,children:[jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]});function lt({isPlaying:e,show:t,onToggle:n,size:r=72,autoHideDelay:o=1e3,showOnStateChange:s=true,style:d,className:u=""}){let[l,m]=useState(false),[i,a]=useState(false),p=t!==void 0,c=p?t:l;useEffect(()=>{if(!(p||!s||!i)&&(m(true),o>0)){let b=setTimeout(()=>{m(false);},o);return ()=>clearTimeout(b)}},[e,p,s,o,i]);let g=useCallback(()=>{n&&(a(true),m(true),n());},[n]),f=!!n,S=f?"auto":"none";return jsx(AnimatePresence,{children:c&&jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},style:mergeStyles(si,{pointerEvents:S},d),className:u,onClick:g,children:jsx(motion.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{type:"spring",...springs.default},whileTap:f?{scale:.9}:void 0,style:{...ai,width:r,height:r,cursor:f?"pointer":"default"},children:e?jsx(di,{size:r}):jsx(li,{size:r})})})})}var gi={position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",zIndex:zIndices.modal},yi={position:"fixed",left:0,right:0,bottom:0,backgroundColor:colors.overlay,backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)",borderTopLeftRadius:radii.xl,borderTopRightRadius:radii.xl,zIndex:zIndices.modal+1,display:"flex",flexDirection:"column",maxHeight:"90vh"},vi={width:components.bottomSheet.handleWidth,height:components.bottomSheet.handleHeight,backgroundColor:"rgba(255, 255, 255, 0.3)",borderRadius:2,margin:"12px auto 0",flexShrink:0},bi={display:"flex",alignItems:"center",justifyContent:"space-between",padding:`${spacing[4]}px ${spacing[4]}px ${spacing[3]}px`,flexShrink:0},Si={fontSize:18,fontWeight:600,color:colors.text},wi={width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",color:colors.textSecondary,borderRadius:"50%"},Pi={flex:1,overflow:"auto",WebkitOverflowScrolling:"touch"},Ei=()=>jsxs("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]});function xn({isOpen:e,onClose:t,title:n,children:r,height:o="60vh",maxHeight:s="90vh",showClose:d=true,showHandle:u=true,style:l,className:m=""}){let i=useCallback(a=>{a.key==="Escape"&&t();},[t]);return useEffect(()=>(e&&(document.addEventListener("keydown",i),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",i),document.body.style.overflow="";}),[e,i]),jsx(AnimatePresence,{children:e&&jsxs(Fragment,{children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},style:gi,onClick:t}),jsxs(motion.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",...springs.default},drag:"y",dragConstraints:{top:0,bottom:0},dragElastic:{top:0,bottom:.5},onDragEnd:(a,p)=>{(p.offset.y>100||p.velocity.y>500)&&t();},style:mergeStyles(yi,{height:o,maxHeight:s,touchAction:"none"},l),className:m,children:[u&&jsx("div",{style:vi}),(n||d)&&jsxs("div",{style:bi,children:[jsx("span",{style:Si,children:n}),d&&jsx("button",{style:wi,onClick:t,"aria-label":"Close",children:jsx(Ei,{})})]}),jsx("div",{style:Pi,children:r})]})]})})}function In({size:e=24,color:t=colors.text,thickness:n=2,style:r,className:o=""}){return jsxs(Fragment,{children:[jsx("style",{children:`
|
|
2
|
+
@keyframes xhub-reel-spin {
|
|
3
|
+
to { transform: rotate(360deg); }
|
|
4
|
+
}
|
|
5
|
+
`}),jsx("div",{role:"status","aria-label":"Loading",style:mergeStyles({width:e,height:e,borderWidth:n,borderStyle:"solid",borderColor:`${t}30`,borderTopColor:t,borderRadius:"50%",animation:"xhub-reel-spin 1s linear infinite"},r),className:o})]})}var Oi={position:"fixed",left:spacing[4],right:spacing[4],zIndex:zIndices.toast,display:"flex",justifyContent:"center",pointerEvents:"none"},Hi={display:"flex",alignItems:"center",gap:spacing[3],padding:`${spacing[3]}px ${spacing[4]}px`,backgroundColor:colors.surface,borderRadius:radii.lg,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.5)",pointerEvents:"auto",maxWidth:400},Di={default:{},success:{borderLeft:`3px solid ${colors.success}`},error:{borderLeft:`3px solid ${colors.error}`},warning:{borderLeft:`3px solid ${colors.warning}`}},Bi={flex:1,fontSize:fontSizes.sm,color:colors.text,lineHeight:1.4},Ni={padding:`${spacing[1]}px ${spacing[3]}px`,backgroundColor:"transparent",border:"none",color:colors.accent,fontSize:fontSizes.sm,fontWeight:600,cursor:"pointer",borderRadius:radii.sm};function An({message:e,isVisible:t,onClose:n,duration:r=3e3,variant:o="default",action:s,position:d="bottom",style:u,className:l=""}){useEffect(()=>{if(t&&r>0){let i=setTimeout(n,r);return ()=>clearTimeout(i)}},[t,r,n]);let m=d==="top"?{top:spacing[4]}:{bottom:spacing[4]+80};return jsx(AnimatePresence,{children:t&&jsx("div",{style:{...Oi,...m},children:jsxs(motion.div,{initial:{opacity:0,y:d==="top"?-20:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:d==="top"?-20:20,scale:.95},transition:{type:"spring",...springs.default},style:mergeStyles(Hi,Di[o],u),className:l,children:[jsx("span",{style:Bi,children:e}),s&&jsx("button",{style:Ni,onClick:()=>{s.onClick(),n();},children:s.label})]})})})}var Wi={position:"absolute",pointerEvents:"none",zIndex:zIndices.overlay},Gi={filter:"drop-shadow(0 4px 8px rgba(255, 45, 85, 0.5))"};function ct(){let[e,t]=useState(false),[n,r]=useState({x:0,y:0}),o=useCallback((d,u)=>{let l=d??(typeof window<"u"?window.innerWidth/2:200),m=u??(typeof window<"u"?window.innerHeight/2:400);r({x:l,y:m}),t(true),setTimeout(()=>{t(false);},800);},[]),s=useCallback(()=>{t(false);},[]);return {isShowing:e,position:n,showHeart:o,hideHeart:s}}var $i=({size:e,color:t})=>jsx("svg",{style:Gi,xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 28 28",fill:t,children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.74988 11.0538C1.74988 6.75595 4.69822 2.91699 9.20877 2.91699C11.4347 2.91699 12.9986 3.9593 13.9999 4.96978C15.0011 3.95929 16.565 2.91699 18.791 2.91699C23.3015 2.91699 26.2499 6.75595 26.2499 11.0538C26.2499 15.3962 23.6265 18.9036 20.8781 21.3587C18.1288 23.8145 15.1442 25.3171 14.1843 25.6371L13.9999 25.6985L13.8154 25.6371C12.8555 25.3171 9.87093 23.8145 7.12168 21.3587C4.37329 18.9036 1.74988 15.3962 1.74988 11.0538ZM17.7449 6.41699C17.2617 6.41699 16.8699 6.80874 16.8699 7.29199C16.8699 7.77524 17.2617 8.16699 17.7449 8.16699C19.6221 8.16699 20.9952 9.75855 20.9952 11.8241C20.9952 12.3073 21.387 12.6991 21.8702 12.6991C22.3535 12.6991 22.7452 12.3073 22.7452 11.8241C22.7452 9.02543 20.8066 6.41699 17.7449 6.41699Z",fill:t})});function ht({show:e,position:t={x:0,y:0},size:n=100,color:r=colors.like,showParticles:o=true,particleCount:s=8,onComplete:d,style:u,className:l=""}){return jsx(AnimatePresence,{onExitComplete:d,children:e&&jsxs(motion.div,{initial:{opacity:0,scale:0},animate:{opacity:[0,1,1,0],scale:[0,1.3,1,.8],y:[0,-20,-20,-40]},exit:{scale:0,opacity:0},transition:{duration:.8,times:[0,.2,.6,1],ease:"easeOut"},style:{...Wi,left:t.x-n/2,top:t.y-n/2,width:n,height:n,...u},className:l,children:[jsx($i,{size:n,color:r}),o&&[...Array(s)].map((m,i)=>jsx(motion.div,{style:{position:"absolute",width:12,height:12,borderRadius:"50%",backgroundColor:r,left:n/2-6,top:n/2-6},initial:{opacity:1,scale:1},animate:{opacity:0,scale:.5,x:Math.cos(i*Math.PI*2/s)*60,y:Math.sin(i*Math.PI*2/s)*60},transition:{duration:.5,delay:.1,ease:"easeOut"}},i))]})})}function Dn(e){let[t,n]=useState(false),r=typeof document<"u"&&!!(document.fullscreenEnabled||document.webkitFullscreenElement!==void 0||document.mozFullScreenElement!==void 0||document.msFullscreenElement!==void 0),o=()=>{let i=document;return i.fullscreenElement||i.webkitFullscreenElement||i.mozFullScreenElement||i.msFullscreenElement||null},s=async i=>{let a=i;a.requestFullscreen?await a.requestFullscreen():a.webkitRequestFullscreen?await a.webkitRequestFullscreen():a.mozRequestFullScreen?await a.mozRequestFullScreen():a.msRequestFullscreen&&await a.msRequestFullscreen();},d=async()=>{let i=document;i.exitFullscreen?await i.exitFullscreen():i.webkitExitFullscreen?await i.webkitExitFullscreen():i.mozCancelFullScreen?await i.mozCancelFullScreen():i.msExitFullscreen&&await i.msExitFullscreen();};useEffect(()=>{let i=()=>{let a=o();n(a===e.current);};return document.addEventListener("fullscreenchange",i),document.addEventListener("webkitfullscreenchange",i),document.addEventListener("mozfullscreenchange",i),document.addEventListener("MSFullscreenChange",i),()=>{document.removeEventListener("fullscreenchange",i),document.removeEventListener("webkitfullscreenchange",i),document.removeEventListener("mozfullscreenchange",i),document.removeEventListener("MSFullscreenChange",i);}},[e]);let u=useCallback(async()=>{let i=e.current;if(!(!i||!r))try{await s(i),n(!0);let a=screen.orientation;if(a?.lock)try{await a.lock("landscape");}catch{}}catch(a){console.error("[useFullscreen] Failed to enter fullscreen:",a);}},[e,r]),l=useCallback(async()=>{if(r)try{await d(),n(!1);let i=screen.orientation;i?.unlock&&i.unlock();}catch(i){console.error("[useFullscreen] Failed to exit fullscreen:",i);}},[r]),m=useCallback(async()=>{t?await l():await u();},[t,u,l]);return {isFullscreen:t,isSupported:r,toggleFullscreen:m,enterFullscreen:u,exitFullscreen:l}}var Zi={feed:{autoQualitySwitch:true,pauseOnOffline:false,resumeOnOnline:false,lowQualityOn:"2g"},watch:{autoQualitySwitch:true,pauseOnOffline:false,resumeOnOnline:false,lowQualityOn:"2g"},auto:{autoQualitySwitch:true,pauseOnOffline:true,resumeOnOnline:true,lowQualityOn:"2g"},manual:{autoQualitySwitch:false,pauseOnOffline:false,resumeOnOnline:false}},Ji={aggressive:{autoPauseOnLowBattery:true,pauseThreshold:.2},moderate:{autoPauseOnLowBattery:true,pauseThreshold:.15},conservative:{autoPauseOnLowBattery:true,pauseThreshold:.1},manual:{autoPauseOnLowBattery:false}};function $e(e,t,n={}){let r=useRef(null),o=useRef(null),s=t??o,[d,u]=useState(false),l=mn(),m=gn(e),i=yn(e),a=vn(r.current),p=Dn(s),c=useRef(n);c.current=n;let{networkBehavior:g,powerBehavior:f}=n,S=useMemo(()=>{if(g)return typeof g=="string"?Zi[g]:g},[g]),b=useMemo(()=>{if(f)return typeof f=="string"?Ji[f]:f},[f]),V=useMemo(()=>({onStateChange:v=>{l.transition(v),c.current.onStateChange?.(v),v==="ready"&&!d&&(u(true),c.current.onReady?.());},onError:(v,N)=>{c.current.onError?.(v,N);},onTimeUpdate:(v,N)=>{c.current.onTimeUpdate?.(v,N);},onQualityLevelsLoaded:v=>{c.current.onQualityLevelsLoaded?.(v);},onNetworkChange:v=>{S?.onNetworkChange?.(v),c.current.onNetworkChange?.(v);},onPowerChange:v=>{b?.onPowerChange?.(v),c.current.onPowerChange?.(v);},onAnalyticsUpdate:v=>{c.current.onAnalyticsUpdate?.(v);}}),[l,d,S,b]);useEffect(()=>{let v=e.current;if(!v)return;let N=()=>c.current.onPlay?.(),X=()=>c.current.onPause?.(),$=()=>c.current.onEnded?.();return v.addEventListener("play",N),v.addEventListener("pause",X),v.addEventListener("ended",$),()=>{v.removeEventListener("play",N),v.removeEventListener("pause",X),v.removeEventListener("ended",$);}},[e]);let L=useCallback((v,N)=>{let X=e.current;if(!X){console.error("[usePlayer] No video element");return}u(false),r.current&&r.current.destroy(),r.current=new fn({preferNative:c.current.preferNative,enableSmoothTimeUpdates:c.current.enableSmoothTimeUpdates,enableNetworkAdaptation:c.current.enableNetworkAdaptation,enablePowerAdaptation:c.current.enablePowerAdaptation,enableAnalytics:c.current.enableAnalytics,preloadConfig:c.current.preloadConfig,callbacks:V,autoQualityOnNetworkChange:S?.autoQualitySwitch,autoPauseOnOffline:S?.pauseOnOffline,autoResumeOnOnline:S?.resumeOnOnline,lowQualityThreshold:S?.lowQualityOn,autoPauseOnLowBattery:b?.autoPauseOnLowBattery,lowBatteryThreshold:b?.pauseThreshold}),r.current.attach(X,v,N);},[e,V,S,b]),h=useCallback(()=>{r.current&&(r.current.destroy(),r.current=null),l.reset(),u(false);},[l]),y=useCallback(async()=>{await r.current?.play();},[]),P=useCallback(()=>{r.current?.pause();},[]),O=useCallback(async()=>{await r.current?.togglePlay();},[]),C=useCallback(v=>{r.current?.seek(v);},[]),B=useCallback((v=10)=>{r.current?.seekForward(v);},[]),z=useCallback((v=10)=>{r.current?.seekBackward(v);},[]),H=useCallback(v=>{r.current?.setPlaybackRate(v);},[]),A=useCallback(()=>{let v=e.current;v&&(v.currentTime=0,v.play().catch(()=>{}));},[e]);return {playerCore:r.current,videoRef:e,containerRef:s,state:l,isReady:d,play:y,pause:P,togglePlay:O,seek:C,seekForward:B,seekBackward:z,setPlaybackSpeed:H,restart:A,volume:m,progress:i,quality:a,fullscreen:p,attach:L,destroy:h}}var no={position:"relative",width:"100%",height:"100%",backgroundColor:colors.background},ro={width:"100%",height:"100%",objectFit:"contain"},_t=forwardRef(({video:e,autoPlay:t=true,muted:n=true,loop:r=true,poster:o,children:s,style:d,className:u="",onPlay:l,onPause:m,onEnded:i,onError:a,onStateChange:p,onTimeUpdate:c,onQualityLevelsLoaded:g,onReady:f},S)=>{let b=useRef(null),V=useRef(null),L=typeof e=="string"?e:e.url,h=o??(typeof e=="object"?e.thumbnail:void 0),y=$e(b,V,{onStateChange:p,onError:P=>a?.(P),onTimeUpdate:c,onQualityLevelsLoaded:g,onPlay:l,onPause:m,onEnded:i,onReady:f});return useEffect(()=>(L&&y.attach(L),()=>{y.destroy();}),[L]),useEffect(()=>{let P=b.current;P&&(P.muted=n,P.loop=r);},[n,r]),useEffect(()=>{let P=b.current;!P||!y.isReady||!t||P.play().catch(O=>{O.name==="NotAllowedError"&&(P.muted=true,P.play().catch(()=>{}));});},[t,y.isReady]),useImperativeHandle(S,()=>({play:y.play,pause:y.pause,togglePlay:y.togglePlay,seek:y.seek,seekForward:y.seekForward,seekBackward:y.seekBackward,restart:y.restart,setVolume:y.volume.setVolume,toggleMute:y.volume.toggleMute,setPlaybackSpeed:y.setPlaybackSpeed,setQuality:y.quality.setQuality,getQualityLevels:()=>y.quality.availableLevels,getVideoElement:()=>b.current,getCurrentTime:()=>y.progress.currentTime,getDuration:()=>y.progress.duration,isPaused:()=>b.current?.paused??true}),[y]),jsxs("div",{ref:V,style:Y(no,d),className:u,children:[jsx("video",{ref:b,poster:h,playsInline:true,preload:"auto",style:ro}),s]})});_t.displayName="VideoPlayer";var uo=30,co=1e3/uo,Z={container:{position:"absolute",bottom:0,left:0,right:0,zIndex:zIndices.sticky,touchAction:"none",userSelect:"none",WebkitUserSelect:"none",transition:"all 0.125s ease-in-out"},collapsed:{height:Ne.HEIGHT_DEFAULT,paddingInline:spacing[3],cursor:"pointer"},expanded:{padding:`${spacing[2]}px ${spacing[3]}px`,paddingBottom:`calc(${spacing[1]}px + env(safe-area-inset-bottom, 0px))`,background:"linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%)"},timeContainer:{display:"flex",justifyContent:"center",alignItems:"center",marginBottom:spacing[2]},timeText:{fontSize:fontSizes.sm,fontWeight:fontWeights.semibold,color:colors.text,textShadow:shadows.text,fontVariantNumeric:"tabular-nums",backgroundColor:"rgba(0, 0, 0, 0.6)",padding:`${spacing[1]}px ${spacing[3]}px`,borderRadius:radii.md},track:{position:"relative",width:"100%",backgroundColor:"rgba(255, 255, 255, 0.2)",borderRadius:radii.full,overflow:"hidden"},trackCollapsed:{height:Ne.HEIGHT_DEFAULT},trackExpanded:{height:Ne.HEIGHT_ACTIVE},buffer:{position:"absolute",top:0,left:0,height:"100%",backgroundColor:"rgba(255, 255, 255, 0.3)",borderRadius:radii.full},progress:{position:"absolute",top:0,left:0,height:"100%",backgroundColor:colors.text,borderRadius:radii.full},scrubber:{position:"absolute",top:"50%",width:16,height:16,marginLeft:-8,marginTop:-8,backgroundColor:colors.text,borderRadius:radii.full,boxShadow:"0 2px 4px rgba(0,0,0,0.3)",transform:"scale(0)",transition:"transform 150ms ease"},scrubberVisible:{transform:"scale(1)"},touchArea:{position:"absolute",top:-12,left:0,right:0,bottom:-12,cursor:"pointer"}};function ye(e){if(!isFinite(e)||isNaN(e))return "0:00";let t=Math.floor(e/60),n=Math.floor(e%60);return `${t}:${n.toString().padStart(2,"0")}`}function ho(e){if(e.buffered.length===0)return 0;for(let t=0;t<e.buffered.length;t++)if(e.buffered.start(t)<=e.currentTime&&e.buffered.end(t)>=e.currentTime)return e.buffered.end(t);return e.buffered.end(e.buffered.length-1)}var pt=forwardRef(({videoRef:e,expanded:t=false,onSeekStart:n,onSeek:r,onSeekEnd:o,onExpandedChange:s,style:d,className:u=""},l)=>{let m=useRef(null),i=useRef(null),a=useRef(null),p=useRef(null),c=useRef(null),g=useRef(0),[f,S]=useState({currentTime:0,duration:0}),b=useRef(null),V=useRef(0),L=useRef(0),h=useRef(false),y=useRef(t);useEffect(()=>{y.current=t;},[t]);let P=useCallback(x=>{let w=e.current;if(!w||h.current)return;let k=w.duration||0,R=w.currentTime||0,D=ho(w),E=k>0?R/k*100:0,_=k>0?D/k*100:0;i.current&&(i.current.style.width=`${E}%`),a.current&&(a.current.style.width=`${_}%`),p.current&&y.current&&(p.current.style.left=`${E}%`),g.current=k,c.current&&(c.current.textContent=`${ye(R)} / ${ye(k)}`);let se=x??performance.now();se-L.current>=500&&(L.current=se,S(ge=>Math.abs(ge.currentTime-R)>=.5||ge.duration!==k?{currentTime:Math.floor(R),duration:Math.floor(k)}:ge));},[e]),O=useCallback(x=>{x-V.current>=co&&(V.current=x,P()),b.current=requestAnimationFrame(O);},[P]);useEffect(()=>(b.current=requestAnimationFrame(O),()=>{b.current&&cancelAnimationFrame(b.current);}),[O]);let C=useCallback(x=>{let w=m.current,k=e.current;if(!w||!k)return 0;let R=w.getBoundingClientRect(),D=x-R.left;return Math.max(0,Math.min(1,D/R.width))*(k.duration||0)},[e]),B=useCallback(x=>{h.current=true,n?.();let w=C(x);r?.(w);let k=e.current;if(k&&i.current){let R=k.duration||g.current||1,D=w/R*100;i.current.style.width=`${D}%`,p.current&&(p.current.style.left=`${D}%`),c.current&&(c.current.textContent=`${ye(w)} / ${ye(R)}`);}},[C,r,n,e]),z=useCallback(x=>{if(!h.current)return;let w=C(x);r?.(w);let k=e.current;if(k&&i.current){let R=k.duration||g.current||1,D=w/R*100;i.current.style.width=`${D}%`,p.current&&(p.current.style.left=`${D}%`),c.current&&(c.current.textContent=`${ye(w)} / ${ye(R)}`);}},[C,r,e]),H=useCallback(x=>{if(!h.current)return;h.current=false;let w=C(x);o?.(w);let k=e.current;k&&(k.currentTime=w);},[C,o,e]),A=useCallback(x=>{let w=x.touches[0];w&&B(w.clientX);},[B]),v=useCallback(x=>{let w=x.touches[0];w&&z(w.clientX);},[z]),N=useCallback(x=>{let w=x.changedTouches[0];w&&H(w.clientX);},[H]),X=useCallback(x=>{B(x.clientX);let w=R=>z(R.clientX),k=R=>{H(R.clientX),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",k);};document.addEventListener("mousemove",w),document.addEventListener("mouseup",k);},[B,z,H]),$=useCallback(()=>{t||s?.(true);},[t,s]),q=useCallback(x=>{let w=e.current;if(!w)return;let k=w.duration||0,R=w.currentTime||0,D=R;switch(x.key){case "ArrowLeft":D=Math.max(0,R-5);break;case "ArrowRight":D=Math.min(k,R+5);break;case "ArrowUp":D=Math.min(k,R+10);break;case "ArrowDown":D=Math.max(0,R-10);break;case "Home":D=0;break;case "End":D=k;break;default:return}x.preventDefault(),w.currentTime=D,r?.(D),P();},[e,r,P]);useImperativeHandle(l,()=>({update:P,setExpanded:x=>{s?.(x);}}));let K={...Z.container,...t?Z.expanded:Z.collapsed,...d},oe={...Z.track,...t?Z.trackExpanded:Z.trackCollapsed},J={...Z.scrubber,...t?Z.scrubberVisible:{}};return jsxs("div",{ref:m,style:K,className:u,onClick:t?void 0:$,onTouchStart:A,onTouchMove:v,onTouchEnd:N,onTouchCancel:N,onMouseDown:X,onKeyDown:q,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":f.duration,"aria-valuenow":f.currentTime,"aria-valuetext":`${ye(f.currentTime)} of ${ye(f.duration)}`,tabIndex:0,children:[t&&jsx("div",{style:Z.timeContainer,children:jsx("span",{ref:c,style:Z.timeText,children:"0:00 / 0:00"})}),jsxs("div",{style:oe,"aria-hidden":"true",children:[jsx("div",{style:Z.touchArea}),jsx("div",{ref:a,style:Z.buffer}),jsx("div",{ref:i,style:Z.progress}),t&&jsx("div",{ref:p,style:J})]})]})});pt.displayName="Timeline";var po={DOUBLE_TAP_DELAY:200},fo={THRESHOLD:500},qe={VERTICAL_THRESHOLD:.3,HORIZONTAL_THRESHOLD:.4,MIN_VELOCITY:.5},ft={THRESHOLD:10};var ve={TAP_DELAY:po.DOUBLE_TAP_DELAY,LONG_PRESS_THRESHOLD:fo.THRESHOLD,SWIPE_VERTICAL_THRESHOLD:qe.VERTICAL_THRESHOLD,SWIPE_HORIZONTAL_THRESHOLD:qe.HORIZONTAL_THRESHOLD,DRAG_THRESHOLD:ft.THRESHOLD};function Un(){return typeof navigator<"u"&&"vibrate"in navigator}function mt(){Un()&&navigator.vibrate(10);}function Qn(){Un()&&navigator.vibrate(20);}function zn(e,t){let n=e.currentTarget||e.target;if(!n||typeof n.getBoundingClientRect!="function")return "center";let r=n.getBoundingClientRect(),o=e.clientX-r.left,s=r.width;if(s===0)return "center";let d=s*.33,u=s*.67;return o<d?"left":o>u?"right":"center"}function gt(e){let t=useRef(0),n=useRef("center"),r=useRef(null),o=useRef(null),s=useRef(false),d=useRef(false),u=useRef({x:0,y:0}),l=useCallback(i=>{if(d.current){d.current=false;return}let a=zn(i),p=Date.now(),c=p-t.current,g={x:i.clientX,y:i.clientY};c<ve.TAP_DELAY&&n.current===a?(r.current&&(clearTimeout(r.current),r.current=null),mt(),e.onDoubleTap?.(a,g)):r.current=setTimeout(()=>{e.onSingleTap?.(a),r.current=null;},ve.TAP_DELAY),t.current=p,n.current=a;},[e]);return useGesture({onPointerDown:({event:i})=>{let a=i;u.current={x:a.clientX,y:a.clientY},d.current=false;let p=setTimeout(()=>{s.current=true,e.onHoldStart?.();},150);o.current=setTimeout(()=>{d.current=true,Qn();let g=a.target.getBoundingClientRect();e.onLongPress?.({x:a.clientX-g.left,y:a.clientY-g.top});},ve.LONG_PRESS_THRESHOLD),i.target.dataset.holdTimeout=String(p);},onPointerUp:({event:i})=>{let a=i.target.dataset.holdTimeout;a&&clearTimeout(Number(a)),o.current&&(clearTimeout(o.current),o.current=null),s.current&&(s.current=false,e.onHoldEnd?.());},onPointerMove:({event:i})=>{let a=i,p=Math.abs(a.clientX-u.current.x),c=Math.abs(a.clientY-u.current.y);(p>10||c>10)&&o.current&&(clearTimeout(o.current),o.current=null);},onClick:({event:i})=>{l(i);},onDrag:({movement:[i,a],direction:[p,c],velocity:[g,f],last:S,event:b})=>{if(b.preventDefault(),!S)return;let V=window.innerWidth,L=window.innerHeight;if(Math.abs(a)>L*ve.SWIPE_VERTICAL_THRESHOLD){c>0?e.onSwipeDown?.():e.onSwipeUp?.();return}if(Math.abs(i)>V*ve.SWIPE_HORIZONTAL_THRESHOLD){p>0?e.onSwipeRight?.():e.onSwipeLeft?.();return}Math.abs(i)>ve.DRAG_THRESHOLD&&Math.abs(g)>Math.abs(f)&&e.onSeekDrag?.(i);}},{drag:{threshold:ve.DRAG_THRESHOLD,filterTaps:true},eventOptions:{passive:false}})}var So=800,wo=.05,Po=.95;function Ut({onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r,threshold:o=qe.VERTICAL_THRESHOLD,velocityThreshold:s=qe.MIN_VELOCITY,hapticEnabled:d=true,disabled:u=false,enableProgressState:l=false}={}){let m=Math.max(wo,Math.min(Po,o)),[i,a]=useState({progress:0,direction:null,isSwiping:false}),p=useRef({onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r}),c=useRef(typeof window<"u"?window.innerHeight:So);return p.current={onSwipeUp:e,onSwipeDown:t,onSwipeProgress:n,onSwipeCancel:r},useEffect(()=>{let f=()=>{c.current=window.innerHeight;},S=()=>{setTimeout(()=>{c.current=window.innerHeight;},100);};return window.addEventListener("resize",f,{passive:true}),window.addEventListener("orientationchange",S,{passive:true}),()=>{window.removeEventListener("resize",f),window.removeEventListener("orientationchange",S);}},[]),{bind:useDrag(({movement:[,f],velocity:[,S],active:b,cancel:V})=>{if(u){V?.();return}let h=c.current*m,y=Math.min(1,Math.abs(f)/h),P=f<0?"up":"down";if(b)p.current.onSwipeProgress?.(y,P,f),l&&a({progress:y,direction:P,isSwiping:true});else {let O=Math.abs(f)>=h,C=Math.abs(S)>=s;O||C?(d&&mt(),P==="up"?p.current.onSwipeUp?.():p.current.onSwipeDown?.()):p.current.onSwipeCancel?.(),a({progress:0,direction:null,isSwiping:false});}},{axis:"y",threshold:ft.THRESHOLD,filterTaps:true,pointer:{touch:true},eventOptions:{passive:true}}),...i}}var Oe={container:{position:"relative",width:"100%",height:"100%",backgroundColor:colors.background},video:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain"},placeholder:{position:"absolute",inset:0,backgroundSize:"cover",backgroundPosition:"center"},tapArea:{zIndex:zIndices.base},pauseOverlay:{zIndex:zIndices.overlay},pauseIconWrapper:{borderRadius:radii.full,transition:`opacity ${durations.normal}ms ${easings.xhubReel}, transform ${durations.normal}ms ${easings.xhubReel}`}};var Qt=createContext(null);function pe(){let e=useContext(Qt);if(!e)throw new Error("VideoFeedItem compound components must be used within a VideoFeedItem");return e}function Gn({elementRef:e,activateThreshold:t=Je.ACTIVATION_THRESHOLD,deactivateThreshold:n=Je.DEACTIVATION_THRESHOLD,rootMargin:r="0px",onVisibilityChange:o}){let[s,d]=useState(false),[u,l]=useState(false),[m,i]=useState(0),a=useRef(null);return useEffect(()=>{let p=e.current;if(!p)return;a.current&&a.current.disconnect();let c=[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1];return a.current=new IntersectionObserver(g=>{g.forEach(f=>{let S=f.intersectionRatio;i(S),d(S>0),S>=t?l(true):S<n&&l(false),o?.(S>0,S);});},{threshold:c,rootMargin:r}),a.current.observe(p),()=>{a.current?.disconnect();}},[e,t,n,r,o]),{isVisible:s,isActive:u,visibilityRatio:m}}function qn({containerRef:e,videoRef:t,isCurrentVideo:n=false,onActivate:r,onDeactivate:o,autoActivate:s=true,trackVisibility:d=false,onVisibilityChange:u}){let l=useRef(false),{isVisible:m,isActive:i,visibilityRatio:a}=Gn({elementRef:e??{current:null},onVisibilityChange:d?u:void 0}),p=d?i:n;useEffect(()=>{s&&(p&&!l.current?(l.current=true,r?.()):!p&&l.current&&(l.current=false,o?.()));},[p,r,o,s]);let c=useCallback(()=>{let f=t.current;f&&f.play().catch(()=>{f.muted=true,f.play().catch(()=>{});}),r?.();},[t,r]),g=useCallback(()=>{let f=t.current;f&&(f.pause(),f.currentTime=0),o?.();},[t,o]);return {isActive:p,isVisible:d?m:n,visibilityRatio:d?a:n?1:0,activate:c,deactivate:g}}var Wt=class{entries=new Map;listeners=new Set;memoryWarningThreshold;constructor(){this.memoryWarningThreshold=Re.MAX_TOTAL_MEMORY/(1024*1024),this.setupMemoryPressureListener();}register(t,n=10){this.entries.set(t,{videoId:t,inDom:false,hasDecodedFrames:false,estimatedSizeMB:n,lastAccessed:Date.now()}),this.notifyListeners();}unregister(t){this.entries.delete(t),this.notifyListeners();}setInDom(t,n){let r=this.entries.get(t);r&&(r.inDom=n,r.lastAccessed=Date.now(),this.notifyListeners());}setHasDecodedFrames(t,n){let r=this.entries.get(t);r&&(r.hasDecodedFrames=n,r.lastAccessed=Date.now(),this.notifyListeners());}getState(){let t=0,n=0,r=0;return this.entries.forEach(o=>{o.inDom&&t++,o.hasDecodedFrames&&n++,r+=o.estimatedSizeMB;}),{videosInDom:t,decodedVideos:n,estimatedMemoryMB:r,isLowMemory:r>this.memoryWarningThreshold}}getVideosToDispose(){let t=this.getState(),n=[],r=Re?.MAX_VIDEOS_IN_DOM,o=Re?.MAX_DECODED_FRAMES,s=Array.from(this.entries.values()).sort((d,u)=>d.lastAccessed-u.lastAccessed);if(t.videosInDom>r){let d=t.videosInDom-r,u=0;for(let l of s){if(u>=d)break;l.inDom&&(n.push(l.videoId),u++);}}if(t.decodedVideos>o){let d=t.decodedVideos-o,u=0;for(let l of s){if(u>=d)break;l.hasDecodedFrames&&!n.includes(l.videoId)&&(n.push(l.videoId),u++);}}return n}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}forceCleanup(){let t=this.getVideosToDispose();return t.forEach(n=>this.unregister(n)),t}notifyListeners(){let t=this.getState();this.listeners.forEach(n=>n(t));}setupMemoryPressureListener(){typeof window>"u"||"memory"in performance&&setInterval(()=>{this.getState().isLowMemory&&(console.warn("[MemoryManager] Low memory warning, forcing cleanup"),this.forceCleanup());},5e3);}},be=new Wt;function jn({videoId:e,estimatedSizeMB:t=10,onShouldDispose:n}){let[r,o]=useState(()=>be.getState()),[s,d]=useState(false);useEffect(()=>(be.register(e,t),()=>{be.unregister(e);}),[e,t]),useEffect(()=>be.subscribe(i=>{o(i);let p=be.getVideosToDispose().includes(e);p&&!s?(d(true),n?.()):!p&&s&&d(false);}),[e,s,n]);let u=useCallback(m=>{be.setInDom(e,m);},[e]),l=useCallback(m=>{be.setHasDecodedFrames(e,m);},[e]);return {memoryState:r,setInDom:u,setHasDecodedFrames:l,shouldDispose:s}}function Jn({video:e,isActive:t,priority:n,onLike:r,onComment:o,onShare:s,onAuthorClick:d}){let u=useRef(null),l=useRef(null),m=useRef(false),[i,a]=useState(false),[p,c]=useState(false),[g,f]=useState(false),{isShowing:S,position:b,showHeart:V}=ct(),L=useMemo(()=>({maxConcurrent:2,maxBufferSize:10*1024*1024,priorityLevels:10}),[]),h=useCallback(E=>{},[]),y=useCallback(E=>{},[]),P=useCallback(E=>{E.startupTime&&E.startupTime>1e3&&console.warn("[VideoFeedItem] Slow startup:",E.startupTime,"ms",e.id);},[e.id]),{state:O}=$e(l,u,{preferNative:true,enableSmoothTimeUpdates:true,networkBehavior:"feed",powerBehavior:"moderate",preloadConfig:L,enableAnalytics:true,onPlay:()=>{a(false),c(false);},onPause:()=>{l.current?.seeking||(a(true),c(true));},onNetworkChange:h,onPowerChange:y,onAnalyticsUpdate:P}),C=useCallback(async()=>{let E=l.current;if(E){E.muted=true;try{await E.play();}catch(_){console.warn("[VideoFeedItem] Play failed:",_.message);}}},[]),B=useCallback(()=>{let E=l.current;E&&E.pause();},[]),z=useCallback(E=>{let _=l.current;_&&(_.currentTime=E);},[]),[H,A]=useState(false);useEffect(()=>{let E=l.current;if(!E)return;let _=()=>A(true),se=()=>A(false),ge=()=>A(false);return E.addEventListener("play",_),E.addEventListener("pause",se),E.addEventListener("ended",ge),A(!E.paused),()=>{E.removeEventListener("play",_),E.removeEventListener("pause",se),E.removeEventListener("ended",ge);}},[e.id]);let v=H||O.state==="playing",{setInDom:N,setHasDecodedFrames:X,shouldDispose:$}=jn({videoId:e.id,onShouldDispose:()=>{B(),l.current&&(l.current.src="",l.current.load());}}),q=!$&&n!=="none",K=useRef(false);qn({videoRef:l,isCurrentVideo:t,onActivate:()=>{console.log("[VideoFeedItem] onActivate called, videoRef:",l.current?.src),X(true),l.current?C():(console.log("[VideoFeedItem] Video element not ready, marking pending play"),K.current=true);},onDeactivate:()=>{console.log("[VideoFeedItem] onDeactivate called"),K.current=false,X(false),B(),z(0);},autoActivate:true}),useEffect(()=>{l.current&&K.current&&t&&(console.log("[VideoFeedItem] Video element now available, executing pending play"),K.current=false,C());}),useEffect(()=>(N(true),()=>N(false)),[N]),useEffect(()=>{let E=l.current;if(!E)return;f(false);let _=()=>{console.log("[VideoFeedItem] Video loadeddata:",e.id,{isActive:t,priority:n}),n==="high"&&!t?requestAnimationFrame(()=>{E.readyState>=2&&(E.currentTime=.01,f(true),console.log("[VideoFeedItem] First frame decoded (preloaded):",e.id));}):t&&f(true);},se=()=>{n==="high"&&!g&&f(true);};return E.addEventListener("loadeddata",_),E.addEventListener("canplay",se),E.readyState>=2&&_(),()=>{E.removeEventListener("loadeddata",_),E.removeEventListener("canplay",se);}},[e.id,t,n,g]),useEffect(()=>{console.log("[VideoFeedItem] State:",{videoId:e.id,isActive:t,priority:n,shouldRenderVideo:q,hasVideoElement:!!l.current,videoSrc:l.current?.src});},[e.id,t,n,q]);let oe=useMemo(()=>{switch(n){case "high":return "auto";case "medium":return "metadata";case "low":case "metadata":return "none";default:return "none"}},[n]),J=useCallback(()=>{m.current=v,c(true),a(false),B();},[v,B]),x=useCallback(E=>{z(E),m.current?(C(),c(false)):a(true);},[z,C]),w=useCallback(()=>{v?B():C();},[v,C,B]),k=useCallback((E,_)=>{V(_.x,_.y),r?.();},[V,r]),R=useCallback(()=>{},[]),D=gt({onSingleTap:w,onDoubleTap:k,onLongPress:R});return {video:e,isActive:t,shouldRenderVideo:q,preload:oe,isPreloaded:g,containerRef:u,videoRef:l,isPlaying:v,showPauseOverlay:i,timelineExpanded:p,play:C,pause:B,seek:z,setShowPauseOverlay:a,setTimelineExpanded:c,gestureBindings:D,showHeart:S,heartPosition:b,triggerHeart:V,onLike:r,onComment:o,onShare:s,onAuthorClick:d,handleSeekStart:J,handleSeekEnd:x}}var bt=forwardRef(({placeholder:e,...t},n)=>{let{video:r,videoRef:o,shouldRenderVideo:s,preload:d,isPreloaded:u}=pe();if(!s)return e??jsx("div",{...t,style:{...Oe.placeholder,backgroundImage:`url(${r.thumbnail})`,...t.style}});let l=!u;return jsx("video",{ref:m=>{typeof n=="function"?n(m):n&&(n.current=m),o.current=m;},src:r.url,poster:l?r.thumbnail:void 0,preload:d,loop:true,playsInline:true,muted:true,style:Oe.video})});bt.displayName="VideoFeedItemPlayer";var St=forwardRef(({onLike:e,onComment:t,onShare:n,...r},o)=>{let{video:s,onLike:d,onComment:u,onShare:l}=pe();return jsx("div",{ref:o,...r,children:jsx(st,{avatarUrl:s.author.avatar,likeCount:s.stats.likes,commentCount:s.stats.comments,shareCount:s.stats.shares,isLiked:s.isLiked,onLike:e??d,onComment:t??u,onShare:n??l})})});St.displayName="VideoFeedItemActions";var wt=forwardRef(({expanded:e,...t},n)=>{let{videoRef:r,shouldRenderVideo:o,timelineExpanded:s,setTimelineExpanded:d,handleSeekStart:u,handleSeekEnd:l}=pe();return o?jsx("div",{ref:n,...t,children:jsx(pt,{videoRef:r,expanded:e??s,onSeekStart:u,onSeekEnd:l,onExpandedChange:d})}):null});wt.displayName="VideoFeedItemTimeline";var He={container:{position:"absolute",bottom:0,left:0,right:64,padding:spacing[4],paddingBottom:"env(safe-area-inset-bottom, 16px)",zIndex:zIndices.base},containerWithTimeline:{paddingBottom:"calc(env(safe-area-inset-bottom, 16px) + 48px)"},authorButton:{gap:spacing[2],marginBottom:spacing[3]},avatar:{borderRadius:radii.full,border:`2px solid ${colors.text}`},username:{color:colors.text,fontWeight:fontWeights.semibold,fontSize:fontSizes.sm,textShadow:shadows.text},caption:{color:colors.text,fontSize:fontSizes.sm,lineHeight:1.4,textShadow:shadows.text,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",paddingBottom:spacing[1]},author:{color:colors.text,fontSize:fontSizes.sm,fontWeight:fontWeights.semibold,textShadow:shadows.text,display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",paddingBottom:spacing[1]},hashtags:{display:"flex",flexWrap:"wrap",gap:spacing[1],marginTop:spacing[2],paddingBottom:spacing[1]},hashtag:{color:colors.accent,fontSize:fontSizes.sm,fontWeight:fontWeights.medium,textShadow:shadows.text}};function ir({video:e,timelineExpanded:t=false,style:n,className:r=""}){let o=Y(He.container,t&&He.containerWithTimeline,n);return jsxs("div",{style:o,className:r,children:[e.author&&jsx("p",{style:He.author,children:e.author.displayName}),e.caption&&jsx("p",{style:He.caption,children:e.caption}),e.hashtags&&e.hashtags.length>0&&jsx("div",{style:He.hashtags,children:e.hashtags.slice(0,3).map((s,d)=>jsxs("span",{style:He.hashtag,children:["#",s]},d))})]})}var Pt=forwardRef(({showPlayPause:e=true,showDoubleTapHeart:t=true,showVideoInfo:n=true,...r},o)=>{let{video:s,isPlaying:d,showPauseOverlay:u,timelineExpanded:l,showHeart:m,heartPosition:i,onAuthorClick:a}=pe();return jsxs("div",{ref:o,...r,children:[e&&jsx(lt,{isPlaying:d,show:u,size:64,autoHideDelay:800,showOnStateChange:false}),t&&jsx(ht,{show:m,position:i,size:100,showParticles:true,particleCount:8}),n&&jsx(ir,{video:s,onAuthorClick:a,timelineExpanded:l})]})});Pt.displayName="VideoFeedItemOverlay";var Be=forwardRef(({video:e,isActive:t=false,priority:n="none",showTimeline:r=true,onLike:o,onComment:s,onShare:d,onAuthorClick:u,style:l,className:m="",children:i},a)=>{let p=Jn({video:e,isActive:t,priority:n,onLike:o,onComment:s,onShare:d,onAuthorClick:u}),c=i??jsxs(Fragment,{children:[jsx(bt,{}),jsx(Pt,{}),jsx(St,{}),r&&jsx(wt,{})]});return jsx(Qt.Provider,{value:p,children:jsx("div",{ref:g=>{typeof a=="function"?a(g):a&&(a.current=g),p.containerRef.current=g;},style:Y(Oe.container,l),className:m,...p.gestureBindings(),children:c})})});Be.displayName="VideoFeedItem";function or(e,t){let n=e-t;return n===0||n===-1||n===1?"high":n===2?"medium":n===3?"low":Math.abs(n)<=5?"metadata":"none"}var Do="cubic-bezier(0.32, 0.72, 0, 1)",Bo=300,No=800,_o=50;function ar({trackRef:e,transitionDuration:t=Bo,easing:n=Do,onTransitionEnd:r}){let o=useRef(typeof window<"u"?window.innerHeight:No),s=useRef(0),d=useRef(null),u=useRef(false),l=useRef(true);useEffect(()=>{let c=()=>{o.current=window.innerHeight;},g=()=>{setTimeout(()=>{o.current=window.innerHeight;},100);};return window.addEventListener("resize",c,{passive:true}),window.addEventListener("orientationchange",g,{passive:true}),()=>{window.removeEventListener("resize",c),window.removeEventListener("orientationchange",g);}},[]);let m=useCallback(c=>{s.current=c,d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{let g=e.current;g&&(g.style.transition="none",g.style.transform=`translateY(${c}px)`),d.current=null;});},[e]),i=useCallback(c=>new Promise(g=>{let f=e.current;if(!f||!l.current){g();return}if(u.current){g();return}u.current=true,s.current=c;let S=null,b=null,V=L=>{L.propertyName==="transform"&&(S?.(),l.current&&(u.current=false,r?.()),g());};S=()=>{f.removeEventListener("transitionend",V),b&&(clearTimeout(b),b=null);},f.addEventListener("transitionend",V),b=setTimeout(()=>{S?.(),l.current&&u.current&&(u.current=false,r?.()),g();},t+_o),f.offsetHeight,f.style.transition=`transform ${t}ms ${n}`,f.style.transform=`translateY(${c}px)`;}),[e,t,n,r]),a=useCallback(()=>i(0),[i]),p=useCallback(()=>s.current,[]);return useEffect(()=>(l.current=true,()=>{l.current=false,d.current!==null&&(cancelAnimationFrame(d.current),d.current=null);}),[]),{setTranslateY:m,animateTo:i,snapBack:a,getCurrentY:p,viewportHeight:o.current,isAnimating:u.current}}var zo=300,Wo=50,Go=.3,$o="cubic-bezier(0.32, 0.72, 0, 1)",Se={container:{position:"fixed",inset:0,overflow:"hidden",backgroundColor:colors.background,touchAction:"none",userSelect:"none",WebkitUserSelect:"none"},track:{position:"relative",width:"100%",height:"100%",willChange:"transform"},slide:{position:"absolute",left:0,width:"100%",height:"100%",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},loadingIndicator:{position:"absolute",bottom:80,left:0,right:0,display:"flex",justifyContent:"center",zIndex:zIndices.base,pointerEvents:"none"},spinner:{width:24,height:24,borderWidth:2,borderStyle:"solid",borderColor:"rgba(255, 255, 255, 0.3)",borderTopColor:colors.text,borderRadius:radii.full,animation:"xhub-reel-spin 1s linear infinite"}},Ke=forwardRef(({videos:e,initialIndex:t=0,onLoadMore:n,onVideoChange:r,onLike:o,onComment:s,onShare:d,onAuthorClick:u,isLoading:l=false,hasMore:m=false,loadMoreThreshold:i=3,transitionDuration:a=zo,swipeThreshold:p=Wo,velocityThreshold:c=Go,gesturesDisabled:g=false,hapticEnabled:f=true,style:S,className:b=""},V)=>{let[L,h]=useState(()=>Math.min(Math.max(0,t),Math.max(0,e.length-1))),[y,P]=useState(false),[O,C]=useState(false),B=useRef(null),z=useRef(null),H=useRef(e),A=useRef(L),v=useRef(l),N=useRef(m),X=useRef(y),{setCurrentIndex:$}=Lt(),{setTranslateY:q,animateTo:K,snapBack:oe,viewportHeight:J}=ar({trackRef:z,transitionDuration:a,easing:$o});useEffect(()=>{H.current=e;},[e]),useEffect(()=>{A.current=L;},[L]),useEffect(()=>{v.current=l;},[l]),useEffect(()=>{N.current=m;},[m]),useEffect(()=>{X.current=y;},[y]),useEffect(()=>{if(e.length===0){h(0);return}if(L>=e.length){let I=e.length-1,U=e[I];h(I),$(I),U&&r?.(U,I);}},[e.length,L,$,r,e]);let x=useCallback(I=>or(I,L),[L]),w=useCallback(I=>{let U=H.current;N.current&&!v.current&&U.length-I<=i&&n?.();},[i,n]),k=useCallback(async(I,U=true)=>{if(X.current)return;let F=H.current,M=Math.max(0,Math.min(I,F.length-1)),ae=A.current;if(M===ae){q(0);return}let xe=M>ae?-1:1;if(U){P(true),C(true),await K(xe*J),h(M),$(M),q(0);let we=F[M];we&&r?.(we,M),w(M),C(false),P(false);}else {h(M),$(M),q(0);let we=F[M];we&&(r?.(we,M),w(M));}},[J,K,q,$,r,w]),R=useCallback((I=true)=>{let U=H.current,F=A.current;F<U.length-1&&k(F+1,I);},[k]),D=useCallback((I=true)=>{let U=A.current;U>0&&k(U-1,I);},[k]),E=useCallback((I,U,F)=>{let M=H.current,ae=A.current,xe=ae>0,we=ae<M.length-1,Xt=F;(U==="down"&&!xe||U==="up"&&!we)&&(Xt*=.3),q(Xt);},[q]),_=useCallback(async()=>{let I=H.current;if(!(A.current<I.length-1)){await oe();return}P(true),C(true),await K(-J);let M=A.current+1,ae=H.current;if(M<ae.length){h(M),$(M);let xe=ae[M];xe&&r?.(xe,M),w(M);}q(0),C(false),P(false);},[J,K,oe,q,$,r,w]),se=useCallback(async()=>{if(!(A.current>0)){await oe();return}P(true),C(true),await K(J);let F=A.current-1;if(F>=0){h(F),$(F);let M=H.current[F];M&&r?.(M,F);}q(0),C(false),P(false);},[J,K,oe,q,$,r]),ge=useCallback(async()=>{await oe();},[oe]),{bind:ur}=Ut({onSwipeUp:_,onSwipeDown:se,onSwipeProgress:E,onSwipeCancel:ge,threshold:p/J,velocityThreshold:c,hapticEnabled:f,disabled:g||y,enableProgressState:false});useImperativeHandle(V,()=>({slideTo:k,slideNext:R,slidePrev:D,get activeIndex(){return A.current},get totalSlides(){return H.current.length},get isBeginning(){return A.current===0},get isEnd(){return A.current===H.current.length-1}})),useEffect(()=>{let I=e[L];I&&r?.(I,L);},[]);let Ze=[];if(L>0&&Ze.push({index:L-1,position:-1}),Ze.push({index:L,position:0}),L<e.length-1&&Ze.push({index:L+1,position:1}),e.length===0)return jsx("div",{ref:B,style:Y(Se.container,S),className:b,"data-xhub-reel-feed":true,children:l&&jsx("div",{style:{...Se.loadingIndicator,top:"50%",bottom:"auto"},children:jsx("div",{style:Se.spinner})})});let cr={...Se.track};return jsxs("div",{ref:B,...ur(),style:Y(Se.container,S),className:b,"data-xhub-reel-feed":true,children:[jsx("style",{children:`
|
|
6
|
+
@keyframes xhub-reel-spin {
|
|
7
|
+
to { transform: rotate(360deg); }
|
|
8
|
+
}
|
|
9
|
+
`}),jsx("div",{ref:z,style:cr,children:Ze.map(({index:I,position:U})=>{let F=e[I];if(!F)return null;let M=x(I),ae=I===L&&!O;return jsx("div",{"data-index":I,style:{...Se.slide,top:U*J},children:jsx(Be,{video:F,isActive:ae,priority:M,onLike:()=>o?.(F),onComment:()=>s?.(F),onShare:()=>d?.(F),onAuthorClick:()=>u?.(F)})},F.id)})}),l&&jsx("div",{style:Se.loadingIndicator,children:jsx("div",{style:Se.spinner})})]})});Ke.displayName="VideoFeed";function Yt({videos:e,initialIndex:t=0,onLoadMore:n,hasMore:r=true,isLoading:o=false,onLike:s,onComment:d,onShare:u,onAuthorClick:l,onVideoChange:m,className:i=""}){let a=useRef(null),p=useCallback((b,V)=>{m?.(b,V);},[m]),c=useCallback(b=>{s?.(b);},[s]),g=useCallback(b=>{d?.(b);},[d]),f=useCallback(b=>{u?.(b);},[u]),S=useCallback(b=>{l?.(b);},[l]);return jsx("div",{className:`h-screen w-full overflow-hidden bg-black ${i}`,children:jsx(Ke,{ref:a,videos:e,initialIndex:t,onLoadMore:n,hasMore:r,isLoading:o,onVideoChange:p,onLike:c,onComment:g,onShare:f,onAuthorClick:S})})}function dr(e){let{container:t,...n}=e,r=typeof t=="string"?document.querySelector(t):t;if(!r||!(r instanceof HTMLElement))throw new Error("[XHubReelEmbed] Invalid container element");let o=createRoot(r),s=n,d=u=>{s=u,o.render(createElement(Yt,u));};return d(n),{updateVideos:u=>{d({...s,videos:u});},destroy:()=>{o.unmount();}}}typeof window<"u"&&(window.XHubReel=dr);export{st as ActionBar,xn as BottomSheet,At as IconButton,lt as PlayPauseOverlay,In as Spinner,An as Toast,Ke as VideoFeed,Be as VideoFeedItem,_t as VideoPlayer,Yt as XHubReelEmbed,dr as createXHubReelEmbed,gt as useVideoGestures};
|
package/package.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xhub-reel/embed",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Embeddable widget for XHubReel",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "XHubReel Team",
|
|
7
|
+
"homepage": "https://github.com/xhub-reel/xhub-reel#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/xhub-reel/xhub-reel.git",
|
|
11
|
+
"directory": "packages/embed"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/xhub-reel/xhub-reel/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"xhub-reel",
|
|
18
|
+
"embed",
|
|
19
|
+
"widget",
|
|
20
|
+
"iframe",
|
|
21
|
+
"react",
|
|
22
|
+
"video"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"import": "./dist/index.mjs",
|
|
33
|
+
"require": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@xhub-reel/core": "0.1.0",
|
|
39
|
+
"@xhub-reel/design-tokens": "0.0.2",
|
|
40
|
+
"@xhub-reel/feed": "0.1.0",
|
|
41
|
+
"@xhub-reel/gestures": "0.1.0",
|
|
42
|
+
"@xhub-reel/player": "0.1.0",
|
|
43
|
+
"@xhub-reel/player-core": "0.0.2",
|
|
44
|
+
"@xhub-reel/player-engine": "0.0.2",
|
|
45
|
+
"@xhub-reel/types": "0.0.2",
|
|
46
|
+
"@xhub-reel/ui": "0.1.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"react": ">=18.0.0",
|
|
50
|
+
"react-dom": ">=18.0.0",
|
|
51
|
+
"hls.js": ">=1.5.0",
|
|
52
|
+
"motion": ">=11.0.0",
|
|
53
|
+
"lucide-react": ">=0.460.0",
|
|
54
|
+
"@use-gesture/react": ">=10.0.0",
|
|
55
|
+
"zustand": ">=4.0.0"
|
|
56
|
+
},
|
|
57
|
+
"peerDependenciesMeta": {
|
|
58
|
+
"hls.js": {
|
|
59
|
+
"optional": false
|
|
60
|
+
},
|
|
61
|
+
"motion": {
|
|
62
|
+
"optional": false
|
|
63
|
+
},
|
|
64
|
+
"lucide-react": {
|
|
65
|
+
"optional": false
|
|
66
|
+
},
|
|
67
|
+
"@use-gesture/react": {
|
|
68
|
+
"optional": false
|
|
69
|
+
},
|
|
70
|
+
"zustand": {
|
|
71
|
+
"optional": false
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@types/react": "^19.0.2",
|
|
76
|
+
"@types/react-dom": "^19.0.2",
|
|
77
|
+
"react": "^19.0.0",
|
|
78
|
+
"react-dom": "^19.0.0",
|
|
79
|
+
"hls.js": "^1.5.18",
|
|
80
|
+
"motion": "^12.0.0",
|
|
81
|
+
"lucide-react": "^0.468.0",
|
|
82
|
+
"@use-gesture/react": "^10.3.1",
|
|
83
|
+
"zustand": "^5.0.2",
|
|
84
|
+
"tsup": "^8.3.5",
|
|
85
|
+
"typescript": "^5.7.2"
|
|
86
|
+
},
|
|
87
|
+
"sideEffects": false,
|
|
88
|
+
"files": [
|
|
89
|
+
"dist"
|
|
90
|
+
],
|
|
91
|
+
"scripts": {
|
|
92
|
+
"build": "tsup",
|
|
93
|
+
"dev": "tsup --watch",
|
|
94
|
+
"clean": "rm -rf dist",
|
|
95
|
+
"typecheck": "tsc --noEmit",
|
|
96
|
+
"lint": "eslint src --max-warnings 0",
|
|
97
|
+
"lint:fix": "eslint src --fix"
|
|
98
|
+
}
|
|
99
|
+
}
|