@therealtinhtute/baroiplayer 1.2.1 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/README.md +90 -71
  2. package/dist/components/icons/index.d.ts +36 -0
  3. package/dist/components/icons/index.d.ts.map +1 -0
  4. package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts +4 -0
  5. package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts.map +1 -0
  6. package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts +5 -0
  7. package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts.map +1 -0
  8. package/dist/components/icons/svg-icons/AudioIcon.d.ts +5 -0
  9. package/dist/components/icons/svg-icons/AudioIcon.d.ts.map +1 -0
  10. package/dist/components/icons/svg-icons/BackwardIcon.d.ts +5 -0
  11. package/dist/components/icons/svg-icons/BackwardIcon.d.ts.map +1 -0
  12. package/dist/components/icons/svg-icons/CameraIcon.d.ts +5 -0
  13. package/dist/components/icons/svg-icons/CameraIcon.d.ts.map +1 -0
  14. package/dist/components/icons/svg-icons/CheckIcon.d.ts +5 -0
  15. package/dist/components/icons/svg-icons/CheckIcon.d.ts.map +1 -0
  16. package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts +4 -0
  17. package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts.map +1 -0
  18. package/dist/components/icons/svg-icons/ForwardIcon.d.ts +5 -0
  19. package/dist/components/icons/svg-icons/ForwardIcon.d.ts.map +1 -0
  20. package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts +5 -0
  21. package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts.map +1 -0
  22. package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts +5 -0
  23. package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts.map +1 -0
  24. package/dist/components/icons/svg-icons/LoadingIcon.d.ts +5 -0
  25. package/dist/components/icons/svg-icons/LoadingIcon.d.ts.map +1 -0
  26. package/dist/components/icons/svg-icons/PauseIcon.d.ts +5 -0
  27. package/dist/components/icons/svg-icons/PauseIcon.d.ts.map +1 -0
  28. package/dist/components/icons/svg-icons/PlayIcon.d.ts +5 -0
  29. package/dist/components/icons/svg-icons/PlayIcon.d.ts.map +1 -0
  30. package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts +5 -0
  31. package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts.map +1 -0
  32. package/dist/components/icons/svg-icons/QualityIcon.d.ts +5 -0
  33. package/dist/components/icons/svg-icons/QualityIcon.d.ts.map +1 -0
  34. package/dist/components/icons/svg-icons/SettingsIcon.d.ts +5 -0
  35. package/dist/components/icons/svg-icons/SettingsIcon.d.ts.map +1 -0
  36. package/dist/components/icons/svg-icons/SliderIcon.d.ts +5 -0
  37. package/dist/components/icons/svg-icons/SliderIcon.d.ts.map +1 -0
  38. package/dist/components/icons/svg-icons/SubtitleIcon.d.ts +5 -0
  39. package/dist/components/icons/svg-icons/SubtitleIcon.d.ts.map +1 -0
  40. package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts +5 -0
  41. package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts.map +1 -0
  42. package/dist/components/icons/svg-icons/UnPiPIcon.d.ts +4 -0
  43. package/dist/components/icons/svg-icons/UnPiPIcon.d.ts.map +1 -0
  44. package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts +5 -0
  45. package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts.map +1 -0
  46. package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts +5 -0
  47. package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts.map +1 -0
  48. package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts +5 -0
  49. package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts.map +1 -0
  50. package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts +5 -0
  51. package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts.map +1 -0
  52. package/dist/components/variants/gradient/gradient-audio.d.ts +13 -0
  53. package/dist/components/variants/gradient/gradient-audio.d.ts.map +1 -0
  54. package/dist/components/variants/gradient/gradient-controls.d.ts +4 -0
  55. package/dist/components/variants/gradient/gradient-controls.d.ts.map +1 -0
  56. package/dist/components/variants/gradient/gradient-glyphs.d.ts +30 -0
  57. package/dist/components/variants/gradient/gradient-glyphs.d.ts.map +1 -0
  58. package/dist/components/variants/gradient/gradient-video.d.ts +16 -0
  59. package/dist/components/variants/gradient/gradient-video.d.ts.map +1 -0
  60. package/dist/index.css +1 -1
  61. package/dist/index.d.ts +5 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +1 -41
  64. package/dist/index.js.map +1 -1
  65. package/dist/index.mjs +750 -5640
  66. package/dist/index.mjs.map +1 -1
  67. package/dist/package.json +3 -0
  68. package/package.json +110 -114
  69. package/src/components/variants/gradient/gradient-audio.tsx +47 -0
  70. package/src/components/variants/gradient/gradient-controls.tsx +254 -0
  71. package/src/components/variants/gradient/gradient-glyphs.test.tsx +69 -0
  72. package/src/components/variants/gradient/gradient-glyphs.tsx +129 -0
  73. package/src/components/variants/gradient/gradient-skin.css +211 -0
  74. package/src/components/variants/gradient/gradient-video.tsx +70 -0
  75. package/src/index.ts +5 -198
  76. package/src/test/accessibility-utils.ts +0 -59
  77. package/dist/context/media.js +0 -1
  78. package/dist/context/media.mjs +0 -3
  79. package/dist/context/store.js +0 -1
  80. package/dist/context/store.mjs +0 -3
  81. package/dist/context-Bzd5QCKM.cjs +0 -7
  82. package/dist/context-Bzd5QCKM.cjs.map +0 -1
  83. package/dist/context-DD_SH4tT.js +0 -1053
  84. package/dist/context-DD_SH4tT.js.map +0 -1
  85. package/dist/core-events-BRnLMB7s.cjs +0 -2
  86. package/dist/core-events-BRnLMB7s.cjs.map +0 -1
  87. package/dist/core-events-v_mKdj5p.js +0 -417
  88. package/dist/core-events-v_mKdj5p.js.map +0 -1
  89. package/dist/core-plugins-CMBv-yVh.cjs +0 -2
  90. package/dist/core-plugins-CMBv-yVh.cjs.map +0 -1
  91. package/dist/core-plugins-CqCxLkbd.js +0 -754
  92. package/dist/core-plugins-CqCxLkbd.js.map +0 -1
  93. package/dist/core.js +0 -15
  94. package/dist/core.js.map +0 -1
  95. package/dist/core.mjs +0 -960
  96. package/dist/core.mjs.map +0 -1
  97. package/dist/enhanced-components-BwjBqSA1.js +0 -2858
  98. package/dist/enhanced-components-BwjBqSA1.js.map +0 -1
  99. package/dist/enhanced-components-C-ka-XLp.cjs +0 -2
  100. package/dist/enhanced-components-C-ka-XLp.cjs.map +0 -1
  101. package/dist/hooks-B-IIWPJr.js +0 -1842
  102. package/dist/hooks-B-IIWPJr.js.map +0 -1
  103. package/dist/hooks-DcHzmBwA.cjs +0 -4
  104. package/dist/hooks-DcHzmBwA.cjs.map +0 -1
  105. package/dist/minimal-components-BYsMQde5.js +0 -1610
  106. package/dist/minimal-components-BYsMQde5.js.map +0 -1
  107. package/dist/minimal-components-CsxQbDp7.cjs +0 -2
  108. package/dist/minimal-components-CsxQbDp7.cjs.map +0 -1
  109. package/dist/minimal-components.css +0 -1
  110. package/dist/mona-loading.gif +0 -0
  111. package/dist/performance-monitor-DCSijLJg.js +0 -312
  112. package/dist/performance-monitor-DCSijLJg.js.map +0 -1
  113. package/dist/performance-monitor-wNFKmqMr.cjs +0 -2
  114. package/dist/performance-monitor-wNFKmqMr.cjs.map +0 -1
  115. package/dist/rolldown-runtime-BmowowmI.js +0 -14
  116. package/dist/rolldown-runtime-mLOUI7ql.cjs +0 -1
  117. package/dist/utils-D2gQ7c2R.js +0 -64
  118. package/dist/utils-D2gQ7c2R.js.map +0 -1
  119. package/dist/utils-DJaAwiZ9.cjs +0 -2
  120. package/dist/utils-DJaAwiZ9.cjs.map +0 -1
  121. package/dist/utils.js +0 -1
  122. package/dist/utils.mjs +0 -3
  123. package/src/adapters/videojs-adapter.tsx +0 -470
  124. package/src/assets/mona-loading.gif +0 -0
  125. package/src/components/AnimateLoading.tsx +0 -111
  126. package/src/components/LoadingState.tsx +0 -239
  127. package/src/components/__tests__/media-player-accessibility.test.tsx +0 -510
  128. package/src/components/__tests__/media-player-react19.test.tsx +0 -457
  129. package/src/components/accessibility/keyboard-help-overlay.tsx +0 -207
  130. package/src/components/audio-player.tsx +0 -85
  131. package/src/components/basic/index.ts +0 -37
  132. package/src/components/enhanced/advanced-features.tsx +0 -311
  133. package/src/components/enhanced/debug-panel.tsx +0 -448
  134. package/src/components/enhanced/enhanced-controls.tsx +0 -597
  135. package/src/components/enhanced/enhanced-media-player.tsx +0 -566
  136. package/src/components/enhanced/error-handling.tsx +0 -338
  137. package/src/components/enhanced/index.ts +0 -39
  138. package/src/components/enhanced/media-player-enhanced.tsx +0 -383
  139. package/src/components/examples/basic-video-player.tsx +0 -50
  140. package/src/components/examples/custom-controls-example.tsx +0 -63
  141. package/src/components/examples/enhanced-controls-example.tsx +0 -100
  142. package/src/components/examples/enhanced-media-player-example.tsx +0 -302
  143. package/src/components/examples/loading-states-demo.tsx +0 -141
  144. package/src/components/examples/react-19-demo.tsx +0 -349
  145. package/src/components/examples/volume-orientation-demo.tsx +0 -105
  146. package/src/components/icon-demo.tsx +0 -196
  147. package/src/components/legacy.tsx +0 -87
  148. package/src/components/media-metadata-display.tsx +0 -99
  149. package/src/components/media-player-audio.tsx +0 -39
  150. package/src/components/media-player-controls.tsx +0 -223
  151. package/src/components/media-player-error.tsx +0 -163
  152. package/src/components/media-player-fullscreen.tsx +0 -109
  153. package/src/components/media-player-hls.tsx +0 -111
  154. package/src/components/media-player-loading.tsx +0 -76
  155. package/src/components/media-player-play.tsx +0 -75
  156. package/src/components/media-player-root.tsx +0 -338
  157. package/src/components/media-player-seek.tsx +0 -168
  158. package/src/components/media-player-time.tsx +0 -99
  159. package/src/components/media-player-tooltip.tsx +0 -58
  160. package/src/components/media-player-video.tsx +0 -54
  161. package/src/components/media-player-volume.tsx +0 -155
  162. package/src/components/media-player.tsx +0 -292
  163. package/src/components/media-suspense.tsx +0 -344
  164. package/src/components/player-settings-form.tsx +0 -158
  165. package/src/components/react-player-wrapper.tsx +0 -651
  166. package/src/components/simple-video-player.tsx +0 -62
  167. package/src/components/ui/blur-poster.tsx +0 -96
  168. package/src/components/ui/empty-state.tsx +0 -91
  169. package/src/components/ui/enhanced-seek-bar.tsx +0 -254
  170. package/src/components/ui/error-state.tsx +0 -124
  171. package/src/components/ui/fullscreen-button.tsx +0 -81
  172. package/src/components/ui/loading-skeleton.tsx +0 -107
  173. package/src/components/ui/media-resource-preloader.tsx +0 -458
  174. package/src/components/ui/offline-message.tsx +0 -98
  175. package/src/components/ui/play-button.tsx +0 -99
  176. package/src/components/ui/seek-bar.tsx +0 -191
  177. package/src/components/ui/time-display.tsx +0 -61
  178. package/src/components/ui/volume-control.tsx +0 -190
  179. package/src/components/unified/base-media-player.tsx +0 -252
  180. package/src/components/unified/media-player.tsx +0 -75
  181. package/src/components/variants/minimal/AccessibleMinimalPlayer.tsx +0 -587
  182. package/src/components/variants/minimal/EnhancedMinimalMediaPlayer.tsx +0 -573
  183. package/src/components/variants/minimal/MinimalControls.tsx +0 -124
  184. package/src/components/variants/minimal/MinimalLoading.tsx +0 -28
  185. package/src/components/variants/minimal/MinimalMediaPlayer.tsx +0 -318
  186. package/src/components/variants/minimal/MinimalOverlay.tsx +0 -58
  187. package/src/components/variants/minimal/MinimalPlayButton.tsx +0 -56
  188. package/src/components/variants/minimal/MinimalSeekBar.tsx +0 -140
  189. package/src/components/variants/minimal/MinimalVolumeControl.tsx +0 -75
  190. package/src/components/variants/minimal/SimpleMinimalPlayer.tsx +0 -206
  191. package/src/components/variants/minimal/components/CenterPlayButton.tsx +0 -22
  192. package/src/components/variants/minimal/components/ControlBar.tsx +0 -142
  193. package/src/components/variants/minimal/components/EnhancedSettingsMenu.tsx +0 -412
  194. package/src/components/variants/minimal/components/PlaybackControls.tsx +0 -46
  195. package/src/components/variants/minimal/components/RightControls.tsx +0 -164
  196. package/src/components/variants/minimal/components/SeekBar.tsx +0 -127
  197. package/src/components/variants/minimal/components/SettingsDropdown.tsx +0 -68
  198. package/src/components/variants/minimal/components/SubtitleDisplay.tsx +0 -21
  199. package/src/components/variants/minimal/components/TimeDisplay.tsx +0 -15
  200. package/src/components/variants/minimal/components/VideoElement.tsx +0 -35
  201. package/src/components/variants/minimal/components/VolumeControl.tsx +0 -220
  202. package/src/components/variants/minimal/index.ts +0 -23
  203. package/src/components/video-player.tsx +0 -100
  204. package/src/context/__tests__/media-store.test.ts +0 -509
  205. package/src/context/error-handling.ts +0 -398
  206. package/src/context/media-context.tsx +0 -254
  207. package/src/context/media-provider.tsx +0 -264
  208. package/src/context/media-store.ts +0 -387
  209. package/src/context/persistence.ts +0 -462
  210. package/src/core/events/event-system.ts +0 -448
  211. package/src/core/events/hooks.ts +0 -325
  212. package/src/core/events/index.ts +0 -22
  213. package/src/core/events/middleware.ts +0 -286
  214. package/src/core/index.ts +0 -22
  215. package/src/core/optimization/bundle-optimizer.tsx +0 -312
  216. package/src/core/performance/cicd.ts +0 -98
  217. package/src/core/performance/index.ts +0 -38
  218. package/src/core/performance/media-loading-optimizer.ts +0 -545
  219. package/src/core/performance/performance-budgets.ts +0 -437
  220. package/src/core/performance/performance-monitor.tsx +0 -488
  221. package/src/core/performance/performance-testing.ts +0 -461
  222. package/src/core/plugins/__tests__/registry.test.ts +0 -595
  223. package/src/core/plugins/base-plugin.ts +0 -225
  224. package/src/core/plugins/enhanced-plugin-system.ts +0 -435
  225. package/src/core/plugins/examples/analytics-plugin.ts +0 -241
  226. package/src/core/plugins/index.ts +0 -39
  227. package/src/core/plugins/registry.ts +0 -546
  228. package/src/core/plugins/types.ts +0 -169
  229. package/src/core/plugins/utils.ts +0 -317
  230. package/src/core/progressive-loading.tsx +0 -331
  231. package/src/core/providers/enhanced-hls-provider.ts +0 -307
  232. package/src/core/providers/lazy-provider.tsx +0 -14
  233. package/src/core/providers/service-provider.tsx +0 -164
  234. package/src/core/utils.tsx +0 -34
  235. package/src/features/media-session/media-session-manager.ts +0 -411
  236. package/src/features/picture-in-picture/pip-manager.ts +0 -428
  237. package/src/features/playlist/playlist-manager.ts +0 -626
  238. package/src/features/subtitles/subtitle-manager.ts +0 -435
  239. package/src/features/subtitles/subtitle-parser.ts +0 -284
  240. package/src/features/thumbnails/thumbnail-generator.ts +0 -528
  241. package/src/hooks/__tests__/currentTime-fix.test.ts +0 -149
  242. package/src/hooks/__tests__/use-media-player.test.ts +0 -712
  243. package/src/hooks/__tests__/use-media-state.test.tsx +0 -316
  244. package/src/hooks/accessibility/index.ts +0 -27
  245. package/src/hooks/accessibility/use-accessibility-preferences.ts +0 -190
  246. package/src/hooks/accessibility/use-focus-management.ts +0 -183
  247. package/src/hooks/accessibility/use-keyboard-shortcuts.ts +0 -152
  248. package/src/hooks/accessibility/use-screen-reader.ts +0 -212
  249. package/src/hooks/core/index.ts +0 -47
  250. package/src/hooks/legacy.ts +0 -21
  251. package/src/hooks/use-buffer-health.ts +0 -218
  252. package/src/hooks/use-enhanced-media-player.ts +0 -575
  253. package/src/hooks/use-focus-trap.tsx +0 -162
  254. package/src/hooks/use-intelligent-preloading.ts +0 -387
  255. package/src/hooks/use-keyboard-controls.ts +0 -115
  256. package/src/hooks/use-keyboard-shortcuts.ts +0 -255
  257. package/src/hooks/use-media-actions.ts +0 -184
  258. package/src/hooks/use-media-metadata.ts +0 -91
  259. package/src/hooks/use-media-optimistic.ts +0 -264
  260. package/src/hooks/use-media-player.ts +0 -343
  261. package/src/hooks/use-media-state.ts +0 -194
  262. package/src/hooks/use-memory-optimization.ts +0 -360
  263. package/src/hooks/use-network-status.ts +0 -124
  264. package/src/hooks/use-optimistic-controls.ts +0 -95
  265. package/src/hooks/use-optimized-media.ts +0 -283
  266. package/src/hooks/use-smart-preload.ts +0 -229
  267. package/src/hooks/use-touch-gestures.ts +0 -461
  268. package/src/hooks/useEnhancedSubtitles.ts +0 -258
  269. package/src/hooks/useKeyboardShortcuts.ts +0 -106
  270. package/src/hooks/useMediaControls.ts +0 -52
  271. package/src/hooks/useScreenshot.ts +0 -77
  272. package/src/hooks/useSubtitles.ts +0 -91
  273. package/src/hooks/useVideoPlayer.ts +0 -278
  274. package/src/icons/components/FullscreenIcon.tsx +0 -36
  275. package/src/icons/components/SettingsIcon.tsx +0 -37
  276. package/src/icons/components/animated/LoadingIcon.tsx +0 -27
  277. package/src/icons/components/animated/PlayPauseIcon.tsx +0 -42
  278. package/src/icons/components/media/PauseIcon.tsx +0 -38
  279. package/src/icons/components/media/PlayIcon.tsx +0 -37
  280. package/src/icons/components/volume/VolumeIcon.tsx +0 -38
  281. package/src/icons/components/volume/VolumeOffIcon.tsx +0 -38
  282. package/src/icons/index.ts +0 -56
  283. package/src/icons/provider.tsx +0 -58
  284. package/src/icons/types.ts +0 -60
  285. package/src/index-enhanced.ts +0 -35
  286. package/src/index-legacy.ts +0 -324
  287. package/src/index.css +0 -102
  288. package/src/lib/__tests__/async-utils.test.ts +0 -291
  289. package/src/lib/async-utils.ts +0 -194
  290. package/src/lib/deprecation.ts +0 -51
  291. package/src/lib/format-time.ts +0 -37
  292. package/src/lib/index.ts +0 -4
  293. package/src/lib/utils.ts +0 -6
  294. package/src/styles/globals.css +0 -462
  295. package/src/styles/minimal-player.css +0 -621
  296. package/src/styles/pixel-art.css +0 -41
  297. package/src/styles/videojs.css +0 -100
  298. package/src/types/assets.d.ts +0 -29
  299. package/src/types/events.ts +0 -47
  300. package/src/types/formats.ts +0 -79
  301. package/src/types/index.ts +0 -203
  302. package/src/types/videojs-plugins.d.ts +0 -14
@@ -1,1053 +0,0 @@
1
- import { r as e, t } from "./rolldown-runtime-BmowowmI.js";
2
- import n from "react";
3
- //#region src/context/media-context.tsx
4
- var r = {
5
- PLAY: "PLAY",
6
- PAUSE: "PAUSE",
7
- SEEK: "SEEK",
8
- SET_VOLUME: "SET_VOLUME",
9
- MUTE: "MUTE",
10
- UNMUTE: "UNMUTE",
11
- TOGGLE_MUTE: "TOGGLE_MUTE",
12
- SET_DURATION: "SET_DURATION",
13
- SET_CURRENT_TIME: "SET_CURRENT_TIME",
14
- SET_BUFFERED: "SET_BUFFERED",
15
- SET_LOADING: "SET_LOADING",
16
- SET_ERROR: "SET_ERROR",
17
- ENTER_FULLSCREEN: "ENTER_FULLSCREEN",
18
- EXIT_FULLSCREEN: "EXIT_FULLSCREEN",
19
- ENTER_PIP: "ENTER_PIP",
20
- EXIT_PIP: "EXIT_PIP",
21
- SET_PLAYBACK_RATE: "SET_PLAYBACK_RATE",
22
- SET_SUBTITLE_TRACK: "SET_SUBTITLE_TRACK",
23
- SET_RENDITION: "SET_RENDITION",
24
- TOGGLE_SUBTITLES: "TOGGLE_SUBTITLES",
25
- PREVIEW_TIME: "PREVIEW_TIME",
26
- CLEAR_PREVIEW: "CLEAR_PREVIEW",
27
- SET_BUFFERING: "SET_BUFFERING",
28
- SET_QUALITY_LEVEL: "SET_QUALITY_LEVEL",
29
- SET_BANDWIDTH_ESTIMATE: "SET_BANDWIDTH_ESTIMATE",
30
- SET_ACTIVE_TEXT_TRACKS: "SET_ACTIVE_TEXT_TRACKS"
31
- }, i = n.createContext(null);
32
- function a() {
33
- let e = n.useContext(i);
34
- if (!e) throw Error("useMediaContext must be used within a MediaPlayer");
35
- return e;
36
- }
37
- var o = n.createContext(null);
38
- function s() {
39
- let e = n.useContext(o);
40
- if (!e) throw Error("useMediaStore must be used within a MediaPlayer");
41
- return e;
42
- }
43
- function c(e, t) {
44
- if (Object.is(e, t)) return !0;
45
- if (typeof e != "object" || !e || typeof t != "object" || !t) return !1;
46
- let n = Object.keys(e), r = Object.keys(t);
47
- if (n.length !== r.length) return !1;
48
- for (let i of n) if (!r.includes(i) || !Object.is(e[i], t[i])) return !1;
49
- return !0;
50
- }
51
- function l(e) {
52
- let t = s(), r = () => e(t.getState()), i = n.useRef(void 0), a = n.useCallback(() => {
53
- let n = e(t.getState());
54
- return i.current = n, n;
55
- }, [e]), o = n.useSyncExternalStore(t.subscribe, r, a);
56
- return n.useEffect(() => {
57
- let e = i.current;
58
- e !== void 0 && c(e, o) || (i.current = o);
59
- }, [o]), o;
60
- }
61
- function u() {
62
- return s().dispatch;
63
- }
64
- function d(e) {
65
- let t = s(), r = "getOptimisticState" in t, i = () => e(r ? t.getOptimisticState() : t.getState());
66
- return n.useSyncExternalStore(t.subscribe, i, i);
67
- }
68
- function f() {
69
- let e = s(), t = a(), n = "getOptimisticState" in e;
70
- return {
71
- isEnhanced: n,
72
- errorHandler: "errorHandler" in t ? t.errorHandler : null,
73
- isRehydrated: "isRehydrated" in t ? t.isRehydrated : !0,
74
- actionsState: n ? e.getActionState() : null
75
- };
76
- }
77
- var p = {
78
- isPlaying: !1,
79
- currentTime: 0,
80
- duration: 0,
81
- buffered: null,
82
- isLoading: !1,
83
- isBuffering: !1,
84
- error: null,
85
- volume: 1,
86
- isMuted: !1,
87
- isFullscreen: !1,
88
- isPictureInPicture: !1,
89
- playbackRate: 1,
90
- subtitlesShowing: !1,
91
- selectedSubtitleTrack: null,
92
- selectedRendition: null,
93
- qualityLevel: -1,
94
- bandwidthEstimate: 0,
95
- activeTextTracks: [],
96
- previewTime: null,
97
- previewImage: null,
98
- previewCoords: null,
99
- subtitlesList: [],
100
- renditionList: []
101
- }, m = /* @__PURE__ */ t(((e) => {
102
- var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
103
- function r(e, n, r) {
104
- var i = null;
105
- if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
106
- else r = n;
107
- return n = r.ref, {
108
- $$typeof: t,
109
- type: e,
110
- key: i,
111
- ref: n === void 0 ? null : n,
112
- props: r
113
- };
114
- }
115
- e.Fragment = n, e.jsx = r, e.jsxs = r;
116
- })), h = /* @__PURE__ */ t(((t) => {
117
- process.env.NODE_ENV !== "production" && (function() {
118
- function n(e) {
119
- if (e == null) return null;
120
- if (typeof e == "function") return e.$$typeof === k ? null : e.displayName || e.name || null;
121
- if (typeof e == "string") return e;
122
- switch (e) {
123
- case v: return "Fragment";
124
- case b: return "Profiler";
125
- case y: return "StrictMode";
126
- case w: return "Suspense";
127
- case T: return "SuspenseList";
128
- case O: return "Activity";
129
- }
130
- if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
131
- case _: return "Portal";
132
- case S: return e.displayName || "Context";
133
- case x: return (e._context.displayName || "Context") + ".Consumer";
134
- case C:
135
- var t = e.render;
136
- return e = e.displayName, e || (e = t.displayName || t.name || "", e = e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
137
- case E: return t = e.displayName || null, t === null ? n(e.type) || "Memo" : t;
138
- case D:
139
- t = e._payload, e = e._init;
140
- try {
141
- return n(e(t));
142
- } catch {}
143
- }
144
- return null;
145
- }
146
- function r(e) {
147
- return "" + e;
148
- }
149
- function i(e) {
150
- try {
151
- r(e);
152
- var t = !1;
153
- } catch {
154
- t = !0;
155
- }
156
- if (t) return t = console, t.error.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object"), r(e);
157
- }
158
- function a(e) {
159
- if (e === v) return "<>";
160
- if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
161
- try {
162
- var t = n(e);
163
- return t ? "<" + t + ">" : "<...>";
164
- } catch {
165
- return "<...>";
166
- }
167
- }
168
- function o() {
169
- var e = A.A;
170
- return e === null ? null : e.getOwner();
171
- }
172
- function s() {
173
- return Error("react-stack-top-frame");
174
- }
175
- function c(e) {
176
- if (j.call(e, "key")) {
177
- var t = Object.getOwnPropertyDescriptor(e, "key").get;
178
- if (t && t.isReactWarning) return !1;
179
- }
180
- return e.key !== void 0;
181
- }
182
- function l(e, t) {
183
- function n() {
184
- P || (P = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
185
- }
186
- n.isReactWarning = !0, Object.defineProperty(e, "key", {
187
- get: n,
188
- configurable: !0
189
- });
190
- }
191
- function u() {
192
- var e = n(this.type);
193
- return F[e] || (F[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
194
- }
195
- function d(e, t, n, r, i, a) {
196
- var o = n.ref;
197
- return e = {
198
- $$typeof: g,
199
- type: e,
200
- key: t,
201
- props: n,
202
- _owner: r
203
- }, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
204
- enumerable: !1,
205
- value: null
206
- }) : Object.defineProperty(e, "ref", {
207
- enumerable: !1,
208
- get: u
209
- }), e._store = {}, Object.defineProperty(e._store, "validated", {
210
- configurable: !1,
211
- enumerable: !1,
212
- writable: !0,
213
- value: 0
214
- }), Object.defineProperty(e, "_debugInfo", {
215
- configurable: !1,
216
- enumerable: !1,
217
- writable: !0,
218
- value: null
219
- }), Object.defineProperty(e, "_debugStack", {
220
- configurable: !1,
221
- enumerable: !1,
222
- writable: !0,
223
- value: i
224
- }), Object.defineProperty(e, "_debugTask", {
225
- configurable: !1,
226
- enumerable: !1,
227
- writable: !0,
228
- value: a
229
- }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
230
- }
231
- function f(e, t, r, a, s, u) {
232
- var f = t.children;
233
- if (f !== void 0) if (a) if (M(f)) {
234
- for (a = 0; a < f.length; a++) p(f[a]);
235
- Object.freeze && Object.freeze(f);
236
- } else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
237
- else p(f);
238
- if (j.call(t, "key")) {
239
- f = n(e);
240
- var m = Object.keys(t).filter(function(e) {
241
- return e !== "key";
242
- });
243
- a = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", R[f + a] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", a, f, m, f), R[f + a] = !0);
244
- }
245
- if (f = null, r !== void 0 && (i(r), f = "" + r), c(t) && (i(t.key), f = "" + t.key), "key" in t) for (var h in r = {}, t) h !== "key" && (r[h] = t[h]);
246
- else r = t;
247
- return f && l(r, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), d(e, f, r, o(), s, u);
248
- }
249
- function p(e) {
250
- m(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? m(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
251
- }
252
- function m(e) {
253
- return typeof e == "object" && !!e && e.$$typeof === g;
254
- }
255
- var h = e("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), k = Symbol.for("react.client.reference"), A = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
256
- return null;
257
- };
258
- h = { react_stack_bottom_frame: function(e) {
259
- return e();
260
- } };
261
- var P, F = {}, I = h.react_stack_bottom_frame.bind(h, s)(), L = N(a(s)), R = {};
262
- t.Fragment = v, t.jsx = function(e, t, n) {
263
- var r = 1e4 > A.recentlyCreatedOwnerStacks++;
264
- return f(e, t, n, !1, r ? Error("react-stack-top-frame") : I, r ? N(a(e)) : L);
265
- }, t.jsxs = function(e, t, n) {
266
- var r = 1e4 > A.recentlyCreatedOwnerStacks++;
267
- return f(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(a(e)) : L);
268
- };
269
- })();
270
- })), g = /* @__PURE__ */ t(((e, t) => {
271
- process.env.NODE_ENV === "production" ? t.exports = m() : t.exports = h();
272
- }));
273
- //#endregion
274
- //#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
275
- function _(e) {
276
- "@babel/helpers - typeof";
277
- return _ = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
278
- return typeof e;
279
- } : function(e) {
280
- return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
281
- }, _(e);
282
- }
283
- //#endregion
284
- //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
285
- function v(e, t) {
286
- if (_(e) != "object" || !e) return e;
287
- var n = e[Symbol.toPrimitive];
288
- if (n !== void 0) {
289
- var r = n.call(e, t || "default");
290
- if (_(r) != "object") return r;
291
- throw TypeError("@@toPrimitive must return a primitive value.");
292
- }
293
- return (t === "string" ? String : Number)(e);
294
- }
295
- //#endregion
296
- //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
297
- function y(e) {
298
- var t = v(e, "string");
299
- return _(t) == "symbol" ? t : t + "";
300
- }
301
- //#endregion
302
- //#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
303
- function b(e, t, n) {
304
- return (t = y(t)) in e ? Object.defineProperty(e, t, {
305
- value: n,
306
- enumerable: !0,
307
- configurable: !0,
308
- writable: !0
309
- }) : e[t] = n, e;
310
- }
311
- //#endregion
312
- //#region src/context/error-handling.ts
313
- var x = {
314
- maxRetries: 3,
315
- baseDelay: 1e3,
316
- maxDelay: 1e4,
317
- exponentialBackoff: !0,
318
- retryableErrors: ["NETWORK_ERROR", "TIMEOUT_ERROR"],
319
- retryableActions: [
320
- "PLAY",
321
- "PAUSE",
322
- "SEEK",
323
- "SET_VOLUME",
324
- "ENTER_FULLSCREEN",
325
- "EXIT_FULLSCREEN"
326
- ]
327
- }, S = class {
328
- canRecover(e) {
329
- return e.type === "NETWORK_ERROR" && e.retryCount < 3;
330
- }
331
- async recover(e) {
332
- navigator.onLine === !1 && await new Promise((e) => {
333
- let t = () => {
334
- window.removeEventListener("online", t), e(void 0);
335
- };
336
- window.addEventListener("online", t);
337
- }), await new Promise((e) => setTimeout(e, 2e3));
338
- }
339
- }, C = class {
340
- canRecover(e) {
341
- return e.type === "PLAYBACK_ERROR" && e.retryCount < 2;
342
- }
343
- async recover(e) {
344
- let t = document.querySelector("video, audio");
345
- t && (t.load(), await new Promise((e) => {
346
- let n = () => {
347
- t.removeEventListener("canplay", n), e(void 0);
348
- };
349
- t.addEventListener("canplay", n);
350
- }));
351
- }
352
- }, w = class {
353
- canRecover(e) {
354
- return e.type === "PERMISSION_ERROR" && e.action?.type === "ENTER_FULLSCREEN";
355
- }
356
- async recover(e) {
357
- console.warn("Fullscreen requires user interaction");
358
- }
359
- }, T = class {
360
- constructor(e = {}, t = []) {
361
- b(this, "config", void 0), b(this, "recoveryStrategies", void 0), b(this, "errorQueue", /* @__PURE__ */ new Map()), b(this, "listeners", /* @__PURE__ */ new Set()), this.config = {
362
- ...x,
363
- ...e
364
- }, this.recoveryStrategies = [
365
- new S(),
366
- new C(),
367
- new w(),
368
- ...t
369
- ];
370
- }
371
- createMediaError(e, t, n = 0) {
372
- let r = Date.now();
373
- if (e instanceof Error) {
374
- let i = this.categorizeError(e, t);
375
- return {
376
- type: i,
377
- message: e.message,
378
- action: t,
379
- timestamp: r,
380
- retryable: this.isRetryable(i, t),
381
- retryCount: n,
382
- originalError: e
383
- };
384
- }
385
- return {
386
- type: "UNKNOWN_ERROR",
387
- message: typeof e == "string" ? e : "Unknown error occurred",
388
- action: t,
389
- timestamp: r,
390
- retryable: this.isRetryable("UNKNOWN_ERROR", t),
391
- retryCount: n
392
- };
393
- }
394
- categorizeError(e, t) {
395
- let n = e.message.toLowerCase();
396
- return n.includes("network") || n.includes("fetch") || n.includes("connection") || e.name === "NetworkError" ? "NETWORK_ERROR" : n.includes("permission") || n.includes("denied") || n.includes("fullscreen") || e.name === "NotAllowedError" ? "PERMISSION_ERROR" : n.includes("decode") || n.includes("format") || n.includes("codec") || t?.type === "PLAY" ? "PLAYBACK_ERROR" : n.includes("timeout") || e.name === "TimeoutError" ? "TIMEOUT_ERROR" : n.includes("not supported") || n.includes("unsupported") || e.name === "NotSupportedError" ? "NOT_SUPPORTED_ERROR" : "UNKNOWN_ERROR";
397
- }
398
- isRetryable(e, t) {
399
- let n = this.config.retryableErrors.includes(e), r = !t || this.config.retryableActions.includes(t.type);
400
- return n && r;
401
- }
402
- calculateRetryDelay(e) {
403
- if (!this.config.exponentialBackoff) return this.config.baseDelay;
404
- let t = this.config.baseDelay * 2 ** e;
405
- return Math.min(t, this.config.maxDelay);
406
- }
407
- async handleError(e, t, n) {
408
- let r = this.createMediaError(e, t, t?.retryCount || 0), i = `${t?.type}-${r.timestamp}`;
409
- this.errorQueue.set(i, r), this.listeners.forEach((e) => e(r));
410
- for (let e of this.recoveryStrategies) if (e.canRecover(r)) try {
411
- await e.recover(r);
412
- break;
413
- } catch (e) {
414
- console.warn("Recovery strategy failed:", e);
415
- }
416
- if (r.retryable && r.retryCount < this.config.maxRetries && n && t) {
417
- let e = this.calculateRetryDelay(r.retryCount);
418
- console.log(`Retrying action ${t.type} in ${e}ms (attempt ${r.retryCount + 1}/${this.config.maxRetries})`), setTimeout(async () => {
419
- try {
420
- await n({
421
- ...t,
422
- retryCount: r.retryCount + 1
423
- }), this.errorQueue.delete(i);
424
- } catch (e) {
425
- await this.handleError(e, {
426
- ...t,
427
- retryCount: r.retryCount + 1
428
- }, n);
429
- }
430
- }, e);
431
- }
432
- return r;
433
- }
434
- subscribe(e) {
435
- return this.listeners.add(e), () => this.listeners.delete(e);
436
- }
437
- getErrors() {
438
- return Array.from(this.errorQueue.values());
439
- }
440
- clearError(e) {
441
- this.errorQueue.delete(e);
442
- }
443
- clearAllErrors() {
444
- this.errorQueue.clear();
445
- }
446
- getErrorStats() {
447
- let e = this.getErrors(), t = Date.now(), n = e.reduce((e, t) => (e[t.type] = (e[t.type] || 0) + 1, e), {}), r = e.filter((e) => e.retryable).length, i = e.filter((e) => t - e.timestamp < 3e5);
448
- return {
449
- totalErrors: e.length,
450
- errorsByType: n,
451
- retryableErrors: r,
452
- recentErrors: i
453
- };
454
- }
455
- }, E = {
456
- enabled: !0,
457
- key: "baroi-player-state",
458
- persist: [
459
- "volume",
460
- "isMuted",
461
- "playbackRate",
462
- "subtitlesShowing"
463
- ],
464
- debounceMs: 500
465
- };
466
- function D(e = p, t = {}) {
467
- let n = { ...e }, i = { ...e }, a = {
468
- pending: !1,
469
- error: null,
470
- lastAction: null,
471
- retryCount: 0
472
- }, o = {
473
- ...E,
474
- ...t
475
- }, s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map(), l = null, u = (e) => (s.add(e), () => s.delete(e)), d = () => {
476
- s.forEach((e) => e());
477
- }, f = () => n, m = () => i, h = () => a, g = async () => {
478
- if (!o.enabled || typeof window > "u") return;
479
- let e = o.persist.reduce((e, t) => (e[t] = n[t], e), {});
480
- try {
481
- localStorage.setItem(o.key, JSON.stringify({
482
- ...e,
483
- timestamp: Date.now()
484
- }));
485
- } catch (e) {
486
- console.warn("Failed to persist media state:", e);
487
- }
488
- }, _ = () => {
489
- l && clearTimeout(l), l = setTimeout(g, o.debounceMs);
490
- }, v = async () => {
491
- if (!(!o.enabled || typeof window > "u")) try {
492
- let e = localStorage.getItem(o.key);
493
- if (!e) return;
494
- let { timestamp: t, ...r } = JSON.parse(e);
495
- if (t && Date.now() - t > 10080 * 60 * 1e3) {
496
- y();
497
- return;
498
- }
499
- let a = {
500
- ...n,
501
- ...r
502
- };
503
- JSON.stringify(a) !== JSON.stringify(n) && (n = a, i = { ...a }, d());
504
- } catch (e) {
505
- console.warn("Failed to rehydrate media state:", e);
506
- }
507
- }, y = () => {
508
- if (!(typeof window > "u")) try {
509
- localStorage.removeItem(o.key);
510
- } catch (e) {
511
- console.warn("Failed to clear persisted state:", e);
512
- }
513
- }, b = (e) => {
514
- Object.assign(o, e);
515
- }, x = (e) => {
516
- let t = {
517
- ...n,
518
- ...e
519
- };
520
- JSON.stringify(t) !== JSON.stringify(n) && (n = t, i = { ...t }, _(), d());
521
- }, S = (e) => {
522
- let t = `${e.type}-${Date.now()}-${Math.random()}`;
523
- c.set(t, {
524
- ...e,
525
- timestamp: Date.now()
526
- });
527
- let n = w(i, e);
528
- return i = {
529
- ...i,
530
- ...n
531
- }, d(), t;
532
- }, C = (e) => {
533
- if (c.has(e)) {
534
- c.delete(e), i = { ...n };
535
- for (let [, e] of c) {
536
- let t = w(i, e);
537
- i = {
538
- ...i,
539
- ...t
540
- };
541
- }
542
- d();
543
- }
544
- }, w = (e, t) => {
545
- switch (t.type) {
546
- case r.PLAY: return {
547
- isPlaying: !0,
548
- error: null
549
- };
550
- case r.PAUSE: return { isPlaying: !1 };
551
- case r.SEEK: return { currentTime: t.detail };
552
- case r.SET_VOLUME: return { volume: Math.max(0, Math.min(1, t.detail)) };
553
- case r.MUTE: return { isMuted: !0 };
554
- case r.UNMUTE: return { isMuted: !1 };
555
- case r.TOGGLE_MUTE: return { isMuted: !e.isMuted };
556
- case r.SET_DURATION: return { duration: t.detail };
557
- case r.SET_CURRENT_TIME: return { currentTime: t.detail };
558
- case r.SET_BUFFERED: return { buffered: t.detail };
559
- case r.SET_LOADING: return { isLoading: t.detail };
560
- case r.SET_ERROR: return {
561
- error: t.detail,
562
- isLoading: !1
563
- };
564
- case r.ENTER_FULLSCREEN: return { isFullscreen: !0 };
565
- case r.EXIT_FULLSCREEN: return { isFullscreen: !1 };
566
- case r.ENTER_PIP: return { isPictureInPicture: !0 };
567
- case r.EXIT_PIP: return { isPictureInPicture: !1 };
568
- case r.SET_PLAYBACK_RATE: return { playbackRate: t.detail };
569
- case r.SET_SUBTITLE_TRACK: return { selectedSubtitleTrack: t.detail };
570
- case r.SET_RENDITION: return { selectedRendition: t.detail };
571
- case r.TOGGLE_SUBTITLES: return { subtitlesShowing: !e.subtitlesShowing };
572
- case r.PREVIEW_TIME: return { previewTime: t.detail };
573
- case r.CLEAR_PREVIEW: return {
574
- previewTime: null,
575
- previewImage: null,
576
- previewCoords: null
577
- };
578
- default: return console.warn(`Unknown media action type: ${t.type}`), {};
579
- }
580
- }, T = (e) => {
581
- let t = w(n, e);
582
- x(t);
583
- }, D = async (e) => {
584
- a = {
585
- pending: !0,
586
- error: null,
587
- lastAction: e,
588
- retryCount: e.retryCount || 0
589
- };
590
- let t = S(e);
591
- try {
592
- await new Promise((e) => setTimeout(e, 0));
593
- let r = w(n, e), o = {
594
- ...n,
595
- ...r
596
- };
597
- JSON.stringify(o) !== JSON.stringify(n) && (n = o, _()), c.delete(t), a = {
598
- pending: !1,
599
- error: null,
600
- lastAction: e,
601
- retryCount: 0
602
- }, i = { ...n };
603
- for (let [, e] of c) {
604
- let t = w(i, e);
605
- i = {
606
- ...i,
607
- ...t
608
- };
609
- }
610
- } catch (n) {
611
- C(t), a = {
612
- pending: !1,
613
- error: n instanceof Error ? n.message : "Unknown error occurred",
614
- lastAction: e,
615
- retryCount: (e.retryCount || 0) + 1
616
- }, a.retryCount < 3 && O(e.type) && setTimeout(() => {
617
- D({
618
- ...e,
619
- retryCount: a.retryCount
620
- });
621
- }, 2 ** a.retryCount * 1e3);
622
- }
623
- d();
624
- }, O = (e) => [
625
- r.PLAY,
626
- r.PAUSE,
627
- r.SEEK,
628
- r.SET_VOLUME,
629
- r.MUTE,
630
- r.UNMUTE,
631
- r.TOGGLE_MUTE
632
- ].includes(e);
633
- return v(), {
634
- subscribe: u,
635
- getState: f,
636
- setState: x,
637
- dispatch: T,
638
- getOptimisticState: m,
639
- dispatchOptimistic: D,
640
- rollbackOptimistic: C,
641
- getActionState: h,
642
- setPersistenceConfig: b,
643
- rehydrateFromStorage: v,
644
- clearPersistedState: y
645
- };
646
- }
647
- //#endregion
648
- //#region src/context/persistence.ts
649
- var O = {
650
- USER_PREFERENCES: "baroi-player-preferences",
651
- SESSION_STATE: "baroi-player-session",
652
- PLAYBACK_HISTORY: "baroi-player-history",
653
- CACHE_TIMESTAMP: "baroi-player-cache-ts"
654
- }, k = class {
655
- async getItem(e) {
656
- if (typeof window > "u") return null;
657
- try {
658
- return localStorage.getItem(e);
659
- } catch (e) {
660
- return console.warn("Failed to read from localStorage:", e), null;
661
- }
662
- }
663
- async setItem(e, t) {
664
- if (!(typeof window > "u")) try {
665
- localStorage.setItem(e, t);
666
- } catch (e) {
667
- console.warn("Failed to write to localStorage:", e);
668
- }
669
- }
670
- async removeItem(e) {
671
- if (!(typeof window > "u")) try {
672
- localStorage.removeItem(e);
673
- } catch (e) {
674
- console.warn("Failed to remove from localStorage:", e);
675
- }
676
- }
677
- async clear() {
678
- if (!(typeof window > "u")) try {
679
- Object.values(O).forEach((e) => {
680
- localStorage.removeItem(e);
681
- });
682
- } catch (e) {
683
- console.warn("Failed to clear localStorage:", e);
684
- }
685
- }
686
- }, A = {
687
- userPreferences: !0,
688
- sessionState: !0,
689
- playbackHistory: !0,
690
- maxHistoryItems: 50,
691
- maxCacheAge: 10080 * 60 * 1e3,
692
- debounceMs: 1e3,
693
- storage: new k()
694
- }, j = class {
695
- constructor(e = {}) {
696
- b(this, "config", void 0), b(this, "storage", void 0), b(this, "debounceTimeouts", /* @__PURE__ */ new Map()), this.config = {
697
- ...A,
698
- ...e
699
- }, this.storage = this.config.storage;
700
- }
701
- async getUserPreferences() {
702
- if (!this.config.userPreferences) return null;
703
- try {
704
- let e = await this.storage.getItem(O.USER_PREFERENCES);
705
- if (!e) return null;
706
- let t = JSON.parse(e);
707
- return this.isCacheExpired(t.timestamp) ? (await this.clearUserPreferences(), null) : t.preferences;
708
- } catch (e) {
709
- return console.warn("Failed to get user preferences:", e), null;
710
- }
711
- }
712
- async saveUserPreferences(e) {
713
- this.config.userPreferences && this.debounce(O.USER_PREFERENCES, async () => {
714
- try {
715
- let t = {
716
- ...await this.getUserPreferences() || {},
717
- ...e
718
- };
719
- await this.storage.setItem(O.USER_PREFERENCES, JSON.stringify({
720
- preferences: t,
721
- timestamp: Date.now()
722
- }));
723
- } catch (e) {
724
- console.warn("Failed to save user preferences:", e);
725
- }
726
- });
727
- }
728
- async clearUserPreferences() {
729
- try {
730
- await this.storage.removeItem(O.USER_PREFERENCES);
731
- } catch (e) {
732
- console.warn("Failed to clear user preferences:", e);
733
- }
734
- }
735
- async getSessionState() {
736
- if (!this.config.sessionState) return null;
737
- try {
738
- let e = await this.storage.getItem(O.SESSION_STATE);
739
- return e ? JSON.parse(e).state : null;
740
- } catch (e) {
741
- return console.warn("Failed to get session state:", e), null;
742
- }
743
- }
744
- async saveSessionState(e) {
745
- this.config.sessionState && this.debounce(O.SESSION_STATE, async () => {
746
- try {
747
- let t = {
748
- ...await this.getSessionState() || {
749
- currentTime: 0,
750
- playbackPosition: {}
751
- },
752
- ...e
753
- };
754
- await this.storage.setItem(O.SESSION_STATE, JSON.stringify({
755
- state: t,
756
- timestamp: Date.now()
757
- }));
758
- } catch (e) {
759
- console.warn("Failed to save session state:", e);
760
- }
761
- });
762
- }
763
- async clearSessionState() {
764
- try {
765
- await this.storage.removeItem(O.SESSION_STATE);
766
- } catch (e) {
767
- console.warn("Failed to clear session state:", e);
768
- }
769
- }
770
- async getPlaybackHistory() {
771
- if (!this.config.playbackHistory) return [];
772
- try {
773
- let e = await this.storage.getItem(O.PLAYBACK_HISTORY);
774
- if (!e) return [];
775
- let t = JSON.parse(e);
776
- return this.isCacheExpired(t.timestamp) ? (await this.clearPlaybackHistory(), []) : t.history || [];
777
- } catch (e) {
778
- return console.warn("Failed to get playback history:", e), [];
779
- }
780
- }
781
- async addToPlaybackHistory(e) {
782
- if (this.config.playbackHistory) try {
783
- let t = await this.getPlaybackHistory(), n = [{
784
- ...e,
785
- timestamp: Date.now()
786
- }, ...t.filter((t) => t.mediaId !== e.mediaId)].slice(0, this.config.maxHistoryItems);
787
- await this.storage.setItem(O.PLAYBACK_HISTORY, JSON.stringify({
788
- history: n,
789
- timestamp: Date.now()
790
- }));
791
- } catch (e) {
792
- console.warn("Failed to add to playback history:", e);
793
- }
794
- }
795
- async clearPlaybackHistory() {
796
- try {
797
- await this.storage.removeItem(O.PLAYBACK_HISTORY);
798
- } catch (e) {
799
- console.warn("Failed to clear playback history:", e);
800
- }
801
- }
802
- async savePlaybackPosition(e, t) {
803
- let n = (await this.getSessionState())?.playbackPosition || {};
804
- await this.saveSessionState({ playbackPosition: {
805
- ...n,
806
- [e]: t
807
- } });
808
- }
809
- async getPlaybackPosition(e) {
810
- return (await this.getSessionState())?.playbackPosition?.[e] || 0;
811
- }
812
- extractUserPreferences(e) {
813
- return {
814
- volume: e.volume,
815
- isMuted: e.isMuted,
816
- playbackRate: e.playbackRate,
817
- subtitlesShowing: e.subtitlesShowing,
818
- selectedSubtitleTrack: e.selectedSubtitleTrack?.id || null,
819
- preferredRendition: e.selectedRendition,
820
- autoplay: !1,
821
- keyboardShortcuts: !0
822
- };
823
- }
824
- extractSessionState(e, t) {
825
- return {
826
- currentTime: e.currentTime,
827
- mediaId: t,
828
- playbackPosition: {}
829
- };
830
- }
831
- async clearAll() {
832
- await this.storage.clear(), this.debounceTimeouts.clear();
833
- }
834
- isCacheExpired(e) {
835
- return !e || Date.now() - e > this.config.maxCacheAge;
836
- }
837
- debounce(e, t) {
838
- let n = this.debounceTimeouts.get(e);
839
- n && clearTimeout(n);
840
- let r = setTimeout(async () => {
841
- await t(), this.debounceTimeouts.delete(e);
842
- }, this.config.debounceMs);
843
- this.debounceTimeouts.set(e, r);
844
- }
845
- };
846
- function M(e) {
847
- let [t] = n.useState(() => new j(e));
848
- return n.useEffect(() => () => {
849
- t.clearAll();
850
- }, [t]), t;
851
- }
852
- function N(e, t, r) {
853
- let i = M(r), [a, o] = n.useState(!1);
854
- return n.useEffect(() => {
855
- let e = !0;
856
- return (async () => {
857
- try {
858
- let [n, r] = await Promise.all([i.getUserPreferences(), i.getSessionState()]);
859
- if (!e) return;
860
- let a = {
861
- ...n && {
862
- volume: n.volume,
863
- isMuted: n.isMuted,
864
- playbackRate: n.playbackRate,
865
- subtitlesShowing: n.subtitlesShowing
866
- },
867
- ...r && t === r.mediaId && { currentTime: r.currentTime }
868
- };
869
- Object.keys(a).length > 0 && console.log("Rehydrated state:", a), o(!0);
870
- } catch (e) {
871
- console.warn("Failed to rehydrate state:", e), o(!0);
872
- }
873
- })(), () => {
874
- e = !1;
875
- };
876
- }, [i, t]), n.useEffect(() => {
877
- if (!a) return;
878
- let n = i.extractUserPreferences(e);
879
- if (i.saveUserPreferences(n), t) {
880
- let n = i.extractSessionState(e, t);
881
- i.saveSessionState(n), e.currentTime > 0 && e.duration > 0 && i.savePlaybackPosition(t, e.currentTime);
882
- }
883
- }, [
884
- i,
885
- e,
886
- t,
887
- a
888
- ]), {
889
- manager: i,
890
- isRehydrated: a
891
- };
892
- }
893
- new k();
894
- //#endregion
895
- //#region src/context/media-provider.tsx
896
- var P = g();
897
- function F(e = p) {
898
- let t = { ...e }, n = /* @__PURE__ */ new Set(), i = (e) => (n.add(e), () => n.delete(e)), a = () => t, o = (e) => {
899
- let r = {
900
- ...t,
901
- ...e
902
- };
903
- JSON.stringify(r) !== JSON.stringify(t) && (t = r, n.forEach((e) => e()));
904
- };
905
- return {
906
- subscribe: i,
907
- getState: a,
908
- setState: o,
909
- dispatch: (e) => {
910
- switch (e.type) {
911
- case r.PLAY:
912
- o({
913
- isPlaying: !0,
914
- error: null
915
- });
916
- break;
917
- case r.PAUSE:
918
- o({ isPlaying: !1 });
919
- break;
920
- case r.SEEK:
921
- o({ currentTime: e.detail });
922
- break;
923
- case r.SET_VOLUME:
924
- o({ volume: Math.max(0, Math.min(1, e.detail)) });
925
- break;
926
- case r.MUTE:
927
- o({ isMuted: !0 });
928
- break;
929
- case r.UNMUTE:
930
- o({ isMuted: !1 });
931
- break;
932
- case r.TOGGLE_MUTE:
933
- o({ isMuted: !t.isMuted });
934
- break;
935
- case r.SET_DURATION:
936
- o({ duration: e.detail });
937
- break;
938
- case r.SET_CURRENT_TIME:
939
- o({ currentTime: e.detail });
940
- break;
941
- case r.SET_BUFFERED:
942
- o({ buffered: e.detail });
943
- break;
944
- case r.SET_LOADING:
945
- o({ isLoading: e.detail });
946
- break;
947
- case r.SET_ERROR:
948
- o({
949
- error: e.detail,
950
- isLoading: !1
951
- });
952
- break;
953
- case r.ENTER_FULLSCREEN:
954
- o({ isFullscreen: !0 });
955
- break;
956
- case r.EXIT_FULLSCREEN:
957
- o({ isFullscreen: !1 });
958
- break;
959
- case r.ENTER_PIP:
960
- o({ isPictureInPicture: !0 });
961
- break;
962
- case r.EXIT_PIP:
963
- o({ isPictureInPicture: !1 });
964
- break;
965
- case r.SET_PLAYBACK_RATE:
966
- o({ playbackRate: e.detail });
967
- break;
968
- case r.SET_SUBTITLE_TRACK:
969
- o({ selectedSubtitleTrack: e.detail });
970
- break;
971
- case r.SET_RENDITION:
972
- o({ selectedRendition: e.detail });
973
- break;
974
- case r.TOGGLE_SUBTITLES:
975
- o({ subtitlesShowing: !t.subtitlesShowing });
976
- break;
977
- case r.PREVIEW_TIME:
978
- o({ previewTime: e.detail });
979
- break;
980
- case r.CLEAR_PREVIEW:
981
- o({
982
- previewTime: null,
983
- previewImage: null,
984
- previewCoords: null
985
- });
986
- break;
987
- default: console.warn(`Unknown media action type: ${e.type}`);
988
- }
989
- }
990
- };
991
- }
992
- function I({ children: e, mediaId: t = "media-player", labelId: r = "media-player-label", descriptionId: a = "media-player-description", dir: s = "ltr", portalContainer: c, tooltipDelayDuration: l = 700, tooltipSideOffset: u = 4, disabled: d = !1, isVideo: f = !0, withoutTooltip: m = !1, initialState: h = {}, useEnhancedStore: g = !0, persistenceConfig: _, retryConfig: v, enableOptimisticUpdates: y = !0, enableErrorRecovery: b = !0, onStateRehydrated: x }) {
993
- let S = n.useRef(null), C = n.useRef(null), w = n.useMemo(() => {
994
- let e = {
995
- ...p,
996
- ...h
997
- };
998
- return g ? D(e, _) : F(e);
999
- }, [g, _]), E = n.useMemo(() => b && g ? new T(v) : null, [
1000
- b,
1001
- g,
1002
- v
1003
- ]), O = N(w.getState(), t, _);
1004
- n.useEffect(() => {
1005
- O?.isRehydrated && x && x(w.getState());
1006
- }, [
1007
- O?.isRehydrated,
1008
- x,
1009
- w
1010
- ]);
1011
- let k = n.useMemo(() => ({
1012
- mediaId: t,
1013
- labelId: r,
1014
- descriptionId: a,
1015
- dir: s,
1016
- rootRef: S,
1017
- mediaRef: C,
1018
- portalContainer: c,
1019
- tooltipDelayDuration: l,
1020
- tooltipSideOffset: u,
1021
- disabled: d,
1022
- isVideo: f,
1023
- withoutTooltip: m,
1024
- errorHandler: E,
1025
- isEnhanced: g,
1026
- isRehydrated: O?.isRehydrated
1027
- }), [
1028
- t,
1029
- r,
1030
- a,
1031
- s,
1032
- c,
1033
- l,
1034
- u,
1035
- d,
1036
- f,
1037
- m,
1038
- E,
1039
- g,
1040
- O?.isRehydrated
1041
- ]);
1042
- return /* @__PURE__ */ (0, P.jsx)(i.Provider, {
1043
- value: k,
1044
- children: /* @__PURE__ */ (0, P.jsx)(o.Provider, {
1045
- value: w,
1046
- children: e
1047
- })
1048
- });
1049
- }
1050
- //#endregion
1051
- export { r as a, p as c, f as d, l as f, g as i, a as l, d as m, D as n, i as o, s as p, b as r, o as s, I as t, u };
1052
-
1053
- //# sourceMappingURL=context-DD_SH4tT.js.map