softbuilders-react-video-player 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. package/dist/components/BigPlayButton/index.d.ts +1 -1
  2. package/dist/components/BigPlayButton/index.js +2 -3
  3. package/dist/components/BigPlayButton/index.js.map +1 -1
  4. package/dist/components/BigPlayButton/index.tsx +31 -0
  5. package/dist/components/BufferTracker/index.d.ts +1 -2
  6. package/dist/components/BufferTracker/index.js +3 -2
  7. package/dist/components/BufferTracker/index.js.map +1 -1
  8. package/dist/components/BufferTracker/index.tsx +19 -0
  9. package/dist/components/ChapterTooltip/index.d.ts +1 -2
  10. package/dist/components/ChapterTooltip/index.js +4 -13
  11. package/dist/components/ChapterTooltip/index.js.map +1 -1
  12. package/dist/components/ChapterTooltip/index.tsx +65 -0
  13. package/dist/components/ChaptersPanal/index.d.ts +1 -2
  14. package/dist/components/ChaptersPanal/index.js +3 -2
  15. package/dist/components/ChaptersPanal/index.js.map +1 -1
  16. package/dist/components/ChaptersPanal/index.tsx +40 -0
  17. package/dist/components/ControlBar/index.d.ts +1 -1
  18. package/dist/components/ControlBar/index.js +14 -31
  19. package/dist/components/ControlBar/index.js.map +1 -1
  20. package/dist/components/ControlBar/index.tsx +127 -0
  21. package/dist/components/CreateNoteMenu/index.d.ts +1 -2
  22. package/dist/components/CreateNoteMenu/index.js +3 -9
  23. package/dist/components/CreateNoteMenu/index.js.map +1 -1
  24. package/dist/components/CreateNoteMenu/index.tsx +61 -0
  25. package/dist/components/CurrentTimeLabel/index.d.ts +1 -2
  26. package/dist/components/CurrentTimeLabel/index.js +2 -2
  27. package/dist/components/CurrentTimeLabel/index.js.map +1 -1
  28. package/dist/components/CurrentTimeLabel/index.tsx +13 -0
  29. package/dist/components/CurrentTimeTracker/index.d.ts +1 -2
  30. package/dist/components/CurrentTimeTracker/index.js +3 -2
  31. package/dist/components/CurrentTimeTracker/index.js.map +1 -1
  32. package/dist/components/CurrentTimeTracker/index.tsx +18 -0
  33. package/dist/components/Menu/index.d.ts +1 -2
  34. package/dist/components/Menu/index.js +2 -7
  35. package/dist/components/Menu/index.js.map +1 -1
  36. package/dist/components/Menu/index.tsx +49 -0
  37. package/dist/components/MenuButton/index.d.ts +1 -1
  38. package/dist/components/MenuButton/index.js +3 -4
  39. package/dist/components/MenuButton/index.js.map +1 -1
  40. package/dist/components/MenuButton/index.tsx +67 -0
  41. package/dist/components/NoteTooltip/index.d.ts +1 -2
  42. package/dist/components/NoteTooltip/index.js +3 -7
  43. package/dist/components/NoteTooltip/index.js.map +1 -1
  44. package/dist/components/NoteTooltip/index.tsx +46 -0
  45. package/dist/components/NotesPanal/index.d.ts +1 -2
  46. package/dist/components/NotesPanal/index.js +3 -2
  47. package/dist/components/NotesPanal/index.js.map +1 -1
  48. package/dist/components/NotesPanal/index.tsx +34 -0
  49. package/dist/components/QualityMenu/index.d.ts +1 -2
  50. package/dist/components/QualityMenu/index.js +19 -28
  51. package/dist/components/QualityMenu/index.js.map +1 -1
  52. package/dist/components/QualityMenu/index.tsx +122 -0
  53. package/dist/components/Slider/index.d.ts +1 -1
  54. package/dist/components/Slider/index.js +2 -2
  55. package/dist/components/Slider/index.js.map +1 -1
  56. package/dist/components/Slider/index.tsx +37 -0
  57. package/dist/components/SoftBuildersVideoPlayer/index.d.ts +1 -1
  58. package/dist/components/SoftBuildersVideoPlayer/index.js +3 -2
  59. package/dist/components/SoftBuildersVideoPlayer/index.js.map +1 -1
  60. package/dist/components/SoftBuildersVideoPlayer/index.tsx +108 -0
  61. package/dist/components/SubtitleMenu/index.d.ts +1 -2
  62. package/dist/components/SubtitleMenu/index.js +12 -21
  63. package/dist/components/SubtitleMenu/index.js.map +1 -1
  64. package/dist/components/SubtitleMenu/index.tsx +108 -0
  65. package/dist/components/TimeSlider/index.d.ts +1 -2
  66. package/dist/components/TimeSlider/index.js +10 -12
  67. package/dist/components/TimeSlider/index.js.map +1 -1
  68. package/dist/components/TimeSlider/index.tsx +107 -0
  69. package/dist/components/TimeSliderContainer/index.d.ts +1 -2
  70. package/dist/components/TimeSliderContainer/index.js +2 -7
  71. package/dist/components/TimeSliderContainer/index.js.map +1 -1
  72. package/dist/components/TimeSliderContainer/index.tsx +35 -0
  73. package/dist/components/Tooltip/index.d.ts +1 -1
  74. package/dist/components/Tooltip/index.js +2 -2
  75. package/dist/components/Tooltip/index.js.map +1 -1
  76. package/dist/components/Tooltip/index.tsx +16 -0
  77. package/dist/components/VideoPlayerComponent/index.d.ts +1 -2
  78. package/dist/components/VideoPlayerComponent/index.js +5 -7
  79. package/dist/components/VideoPlayerComponent/index.js.map +1 -1
  80. package/dist/components/VideoPlayerComponent/index.tsx +244 -0
  81. package/dist/components/VideoPlayerComponent/provider.d.ts +1 -1
  82. package/dist/components/VideoPlayerComponent/provider.js +4 -3
  83. package/dist/components/VideoPlayerComponent/provider.js.map +1 -1
  84. package/dist/components/VideoPlayerComponent/provider.tsx +82 -0
  85. package/dist/components/VolumeSlider/index.d.ts +1 -2
  86. package/dist/components/VolumeSlider/index.js +3 -4
  87. package/dist/components/VolumeSlider/index.js.map +1 -1
  88. package/dist/components/VolumeSlider/index.tsx +52 -0
  89. package/dist/components/icons/BackwardIcon.d.ts +3 -0
  90. package/dist/components/icons/BackwardIcon.js +4 -0
  91. package/dist/components/icons/BackwardIcon.js.map +1 -0
  92. package/dist/components/icons/BackwardIcon.tsx +20 -0
  93. package/dist/components/icons/CheckedIcon.d.ts +3 -0
  94. package/dist/components/icons/CheckedIcon.js +4 -0
  95. package/dist/components/icons/CheckedIcon.js.map +1 -0
  96. package/dist/components/icons/CheckedIcon.tsx +20 -0
  97. package/dist/components/icons/ClosedNoteIcon.d.ts +3 -0
  98. package/dist/components/icons/ClosedNoteIcon.js +4 -0
  99. package/dist/components/icons/ClosedNoteIcon.js.map +1 -0
  100. package/dist/components/icons/ClosedNoteIcon.tsx +17 -0
  101. package/dist/components/icons/ForwardIcon.d.ts +3 -0
  102. package/dist/components/icons/ForwardIcon.js +4 -0
  103. package/dist/components/icons/ForwardIcon.js.map +1 -0
  104. package/dist/components/icons/ForwardIcon.tsx +20 -0
  105. package/dist/components/icons/FullScreenIcon.d.ts +3 -0
  106. package/dist/components/icons/FullScreenIcon.js +4 -0
  107. package/dist/components/icons/FullScreenIcon.js.map +1 -0
  108. package/dist/components/icons/FullScreenIcon.tsx +20 -0
  109. package/dist/components/icons/LeftArrowIcon.d.ts +3 -0
  110. package/dist/components/icons/LeftArrowIcon.js +4 -0
  111. package/dist/components/icons/LeftArrowIcon.js.map +1 -0
  112. package/dist/components/icons/LeftArrowIcon.tsx +20 -0
  113. package/dist/components/icons/MuteIcon.d.ts +3 -0
  114. package/dist/components/icons/MuteIcon.js +4 -0
  115. package/dist/components/icons/MuteIcon.js.map +1 -0
  116. package/dist/components/icons/MuteIcon.tsx +21 -0
  117. package/dist/components/icons/NoteIcon.d.ts +3 -0
  118. package/dist/components/icons/NoteIcon.js +4 -0
  119. package/dist/components/icons/NoteIcon.js.map +1 -0
  120. package/dist/components/icons/NoteIcon.tsx +17 -0
  121. package/dist/components/icons/OpenNoteIcon.d.ts +3 -0
  122. package/dist/components/icons/OpenNoteIcon.js +4 -0
  123. package/dist/components/icons/OpenNoteIcon.js.map +1 -0
  124. package/dist/components/icons/OpenNoteIcon.tsx +17 -0
  125. package/dist/components/icons/PauseIcon.d.ts +3 -0
  126. package/dist/components/icons/PauseIcon.js +4 -0
  127. package/dist/components/icons/PauseIcon.js.map +1 -0
  128. package/dist/components/icons/PauseIcon.tsx +14 -0
  129. package/dist/components/icons/PlayIcon.d.ts +3 -0
  130. package/dist/components/icons/PlayIcon.js +4 -0
  131. package/dist/components/icons/PlayIcon.js.map +1 -0
  132. package/dist/components/icons/PlayIcon.tsx +20 -0
  133. package/dist/components/icons/SettingsIcon.d.ts +3 -0
  134. package/dist/components/icons/SettingsIcon.js +4 -0
  135. package/dist/components/icons/SettingsIcon.js.map +1 -0
  136. package/dist/components/icons/SettingsIcon.tsx +17 -0
  137. package/dist/components/icons/SubtitlesIcon.d.ts +3 -0
  138. package/dist/components/icons/SubtitlesIcon.js +4 -0
  139. package/dist/components/icons/SubtitlesIcon.js.map +1 -0
  140. package/dist/components/icons/SubtitlesIcon.tsx +14 -0
  141. package/dist/components/icons/UnmuteIcon.d.ts +3 -0
  142. package/dist/components/icons/UnmuteIcon.js +4 -0
  143. package/dist/components/icons/UnmuteIcon.js.map +1 -0
  144. package/dist/components/icons/UnmuteIcon.tsx +17 -0
  145. package/dist/components/icons/index.d.ts +14 -0
  146. package/dist/components/icons/index.js +15 -0
  147. package/dist/components/icons/index.js.map +1 -0
  148. package/dist/components/icons/index.ts +14 -0
  149. package/dist/images/index.d.ts +14 -14
  150. package/dist/images/index.js +14 -14
  151. package/dist/images/index.js.map +1 -1
  152. package/dist/index.css +663 -0
  153. package/dist/index.d.mts +49 -0
  154. package/dist/index.mjs +1383 -0
  155. package/package.json +9 -4
package/dist/index.mjs ADDED
@@ -0,0 +1,1383 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+
33
+ // src/components/SoftBuildersVideoPlayer/index.tsx
34
+ import { memo, useEffect as useEffect15, useState as useState13 } from "react";
35
+
36
+ // src/components/VideoPlayerComponent/index.tsx
37
+ import { useEffect as useEffect14, useRef as useRef2, useState as useState12 } from "react";
38
+ import ReactDOM from "react-dom/client";
39
+ import videojs from "video.js";
40
+ import "video.js/dist/video-js.css";
41
+
42
+ // src/components/ControlBar/index.tsx
43
+ import { useEffect as useEffect13 } from "react";
44
+
45
+ // src/utils/index.ts
46
+ var durationFormater = (seconds) => {
47
+ seconds = Math.floor(seconds);
48
+ const hours = Math.floor(seconds / 3600);
49
+ const minutes = Math.floor(seconds % 3600 / 60);
50
+ const secs = seconds % 60;
51
+ if (hours > 0) {
52
+ return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(
53
+ 2,
54
+ "0"
55
+ )}:${String(secs).padStart(2, "0")}`;
56
+ } else {
57
+ return `${String(minutes).padStart(2, "0")}:${String(secs).padStart(
58
+ 2,
59
+ "0"
60
+ )}`;
61
+ }
62
+ };
63
+ var SRTtoVTT = (srt) => {
64
+ const lines = srt.split(/\r?\n/).filter((line) => line.trim() !== "");
65
+ let vttContent = "WEBVTT\n\n";
66
+ let currentEntry = "";
67
+ lines.forEach((line) => {
68
+ if (/^\d+$/.test(line)) {
69
+ return;
70
+ }
71
+ const timestampMatch = line.match(
72
+ /(\d{2}:\d{2}:\d{2}),(\d{3}) --> (\d{2}:\d{2}:\d{2}),(\d{3})/
73
+ );
74
+ if (timestampMatch) {
75
+ if (currentEntry) {
76
+ vttContent += currentEntry.trim() + "\n\n";
77
+ }
78
+ currentEntry = `${timestampMatch[1]}.${timestampMatch[2]} --> ${timestampMatch[3]}.${timestampMatch[4]}
79
+ `;
80
+ } else if (currentEntry) {
81
+ currentEntry += line + "\n";
82
+ }
83
+ });
84
+ if (currentEntry) {
85
+ vttContent += currentEntry.trim();
86
+ }
87
+ return vttContent.trim();
88
+ };
89
+ var convertSRTtoVTT = async (srtLink) => {
90
+ const response = await fetch(srtLink);
91
+ const srtText = await response.text();
92
+ const vttText = SRTtoVTT(srtText);
93
+ const blob = new Blob([vttText], { type: "text/vtt" });
94
+ const vttUrl = URL.createObjectURL(blob);
95
+ return vttUrl;
96
+ };
97
+
98
+ // src/components/VideoPlayerComponent/provider.tsx
99
+ import {
100
+ createContext,
101
+ useContext,
102
+ useState,
103
+ useEffect
104
+ } from "react";
105
+ import { jsx } from "react/jsx-runtime";
106
+ var SoftBuildersVideoPlayerContext = createContext(void 0);
107
+ var SoftBuildersVideoPlayerProvider = ({
108
+ children
109
+ }) => {
110
+ const [player, setPlayer] = useState(void 0);
111
+ const [currentTime, setCurrentTime] = useState(0);
112
+ const [duration, setDuration] = useState(1);
113
+ const [downloadedBufferTime, setDownloadedBufferTimeufferTime] = useState(0);
114
+ const [downloadedBufferPercentage, setDownloadedBufferPercentage] = useState(0);
115
+ useEffect(() => {
116
+ setDownloadedBufferPercentage(downloadedBufferTime * 100 / duration);
117
+ }, [downloadedBufferTime]);
118
+ return /* @__PURE__ */ jsx(
119
+ SoftBuildersVideoPlayerContext.Provider,
120
+ {
121
+ value: {
122
+ player,
123
+ setPlayer,
124
+ duration,
125
+ setDuration,
126
+ currentTime,
127
+ setCurrentTime: (value) => setCurrentTime(Math.floor(value)),
128
+ // isPaused,
129
+ // setIsPaused,
130
+ downloadedBufferTime,
131
+ setDownloadedBufferTimeufferTime,
132
+ downloadedBufferPercentage
133
+ },
134
+ children
135
+ }
136
+ );
137
+ };
138
+ var useSoftBuildersVideoPlayerContext = () => {
139
+ const context = useContext(SoftBuildersVideoPlayerContext);
140
+ if (!context) {
141
+ throw new Error(
142
+ "useSoftBuildersVideoPlayerContext must be used within an SoftBuildersVideoPlayerProvider"
143
+ );
144
+ }
145
+ return context;
146
+ };
147
+
148
+ // src/components/CurrentTimeLabel/index.tsx
149
+ import { jsx as jsx2 } from "react/jsx-runtime";
150
+ var CurrentTimeLabel = ({}) => {
151
+ const { currentTime } = useSoftBuildersVideoPlayerContext();
152
+ return /* @__PURE__ */ jsx2("p", { children: durationFormater(currentTime) });
153
+ };
154
+ var CurrentTimeLabel_default = CurrentTimeLabel;
155
+
156
+ // src/components/VolumeSlider/index.tsx
157
+ import { useEffect as useEffect2, useState as useState2 } from "react";
158
+
159
+ // src/components/Slider/index.tsx
160
+ import { jsx as jsx3 } from "react/jsx-runtime";
161
+ var Slider = (_a) => {
162
+ var _b = _a, {
163
+ value,
164
+ handleValueChange,
165
+ min = 0,
166
+ max = 100
167
+ } = _b, rest = __objRest(_b, [
168
+ "value",
169
+ "handleValueChange",
170
+ "min",
171
+ "max"
172
+ ]);
173
+ return /* @__PURE__ */ jsx3(
174
+ "input",
175
+ __spreadValues({
176
+ type: "range",
177
+ min,
178
+ max,
179
+ value,
180
+ onChange: handleValueChange,
181
+ className: "sb-w-full sb-h-2 sb-bg-transparent sb-bg-opacity-50 sb-rounded-lg sb-appearance-none sb-cursor-pointer sb-range-slider sb-slider-thumb " + rest.className,
182
+ style: {
183
+ background: `linear-gradient(to right, #f97316 ${value}%, #30303070 ${value}%)`
184
+ }
185
+ }, rest)
186
+ );
187
+ };
188
+ var Slider_default = Slider;
189
+
190
+ // src/components/icons/BackwardIcon.tsx
191
+ import { jsx as jsx4 } from "react/jsx-runtime";
192
+ var SvgBackwardIcon = (props) => /* @__PURE__ */ jsx4(
193
+ "svg",
194
+ __spreadProps(__spreadValues({
195
+ xmlns: "http://www.w3.org/2000/svg",
196
+ width: "1em",
197
+ height: "1em",
198
+ fill: "none",
199
+ viewBox: "0 0 16 15"
200
+ }, props), {
201
+ children: /* @__PURE__ */ jsx4(
202
+ "path",
203
+ {
204
+ stroke: "#fff",
205
+ strokeLinecap: "round",
206
+ strokeLinejoin: "round",
207
+ strokeWidth: 2,
208
+ d: "M1 2.16v4m0 0h4m-4 0 3.093-2.906a6 6 0 1 1-1.42 6.24"
209
+ }
210
+ )
211
+ })
212
+ );
213
+ var BackwardIcon_default = SvgBackwardIcon;
214
+
215
+ // src/components/icons/CheckedIcon.tsx
216
+ import { jsx as jsx5 } from "react/jsx-runtime";
217
+ var SvgCheckedIcon = (props) => /* @__PURE__ */ jsx5(
218
+ "svg",
219
+ __spreadProps(__spreadValues({
220
+ xmlns: "http://www.w3.org/2000/svg",
221
+ width: "1em",
222
+ height: "1em",
223
+ fill: "none",
224
+ viewBox: "0 0 12 10"
225
+ }, props), {
226
+ children: /* @__PURE__ */ jsx5(
227
+ "path",
228
+ {
229
+ stroke: "#FFF",
230
+ strokeLinecap: "round",
231
+ strokeLinejoin: "round",
232
+ strokeWidth: 1.5,
233
+ d: "M1 5.8 3.857 9 11 1"
234
+ }
235
+ )
236
+ })
237
+ );
238
+ var CheckedIcon_default = SvgCheckedIcon;
239
+
240
+ // src/components/icons/ClosedNoteIcon.tsx
241
+ import { jsx as jsx6 } from "react/jsx-runtime";
242
+ var SvgClosedNoteIcon = (props) => /* @__PURE__ */ jsx6(
243
+ "svg",
244
+ __spreadProps(__spreadValues({
245
+ xmlns: "http://www.w3.org/2000/svg",
246
+ width: "1em",
247
+ height: "1em",
248
+ fill: "none",
249
+ viewBox: "0 0 13 12"
250
+ }, props), {
251
+ children: /* @__PURE__ */ jsx6(
252
+ "path",
253
+ {
254
+ fill: "#fff",
255
+ d: "M12.428 9a2.5 2.5 0 0 1-.657 1.053l-1.27 1.214a2.6 2.6 0 0 1-1.1.63V9.5c0-.276.235-.5.523-.5zm.108-6.5V8H9.924c-.864 0-1.567.673-1.567 1.5V12H2.612C1.172 12 0 10.879 0 9.5v-7C0 1.122 1.172 0 2.612 0h7.312c1.44 0 2.612 1.122 2.612 2.5m-8.88 6.25c0-.414-.35-.75-.783-.75s-.784.336-.784.75.351.75.784.75c.432 0 .783-.336.783-.75m0-2.75c0-.414-.35-.75-.783-.75s-.784.336-.784.75.351.75.784.75c.432 0 .783-.336.783-.75m0-2.75c0-.414-.35-.75-.783-.75s-.784.336-.784.75.351.75.784.75c.432 0 .783-.336.783-.75"
256
+ }
257
+ )
258
+ })
259
+ );
260
+ var ClosedNoteIcon_default = SvgClosedNoteIcon;
261
+
262
+ // src/components/icons/ForwardIcon.tsx
263
+ import { jsx as jsx7 } from "react/jsx-runtime";
264
+ var SvgForwardIcon = (props) => /* @__PURE__ */ jsx7(
265
+ "svg",
266
+ __spreadProps(__spreadValues({
267
+ xmlns: "http://www.w3.org/2000/svg",
268
+ width: "1em",
269
+ height: "1em",
270
+ fill: "none",
271
+ viewBox: "0 0 16 15"
272
+ }, props), {
273
+ children: /* @__PURE__ */ jsx7(
274
+ "path",
275
+ {
276
+ stroke: "#fff",
277
+ strokeLinecap: "round",
278
+ strokeLinejoin: "round",
279
+ strokeWidth: 2,
280
+ d: "M14.85 2.165v4m0 0h-4m4 0L11.764 3.26a6 6 0 1 0 1.413 6.24"
281
+ }
282
+ )
283
+ })
284
+ );
285
+ var ForwardIcon_default = SvgForwardIcon;
286
+
287
+ // src/components/icons/FullScreenIcon.tsx
288
+ import { jsx as jsx8 } from "react/jsx-runtime";
289
+ var SvgFullScreenIcon = (props) => /* @__PURE__ */ jsx8(
290
+ "svg",
291
+ __spreadProps(__spreadValues({
292
+ xmlns: "http://www.w3.org/2000/svg",
293
+ width: "1em",
294
+ height: "1em",
295
+ fill: "none",
296
+ viewBox: "0 0 11 11"
297
+ }, props), {
298
+ children: /* @__PURE__ */ jsx8(
299
+ "path",
300
+ {
301
+ stroke: "#FFF",
302
+ strokeLinecap: "round",
303
+ strokeLinejoin: "round",
304
+ strokeWidth: 2,
305
+ d: "M7 1h3m0 0v3m0-3L6.5 4.5M4 10H1m0 0V7m0 3 3.5-3.5"
306
+ }
307
+ )
308
+ })
309
+ );
310
+ var FullScreenIcon_default = SvgFullScreenIcon;
311
+
312
+ // src/components/icons/LeftArrowIcon.tsx
313
+ import { jsx as jsx9 } from "react/jsx-runtime";
314
+ var SvgLeftArrowIcon = (props) => /* @__PURE__ */ jsx9(
315
+ "svg",
316
+ __spreadProps(__spreadValues({
317
+ xmlns: "http://www.w3.org/2000/svg",
318
+ width: "1em",
319
+ height: "1em",
320
+ fill: "none",
321
+ viewBox: "0 0 6 11"
322
+ }, props), {
323
+ children: /* @__PURE__ */ jsx9(
324
+ "path",
325
+ {
326
+ stroke: "#FFF",
327
+ strokeLinecap: "round",
328
+ strokeLinejoin: "round",
329
+ strokeWidth: 2,
330
+ d: "m5 9.97-4-4 4-4"
331
+ }
332
+ )
333
+ })
334
+ );
335
+ var LeftArrowIcon_default = SvgLeftArrowIcon;
336
+
337
+ // src/components/icons/MuteIcon.tsx
338
+ import { jsx as jsx10, jsxs } from "react/jsx-runtime";
339
+ var SvgMuteIcon = (props) => /* @__PURE__ */ jsxs(
340
+ "svg",
341
+ __spreadProps(__spreadValues({
342
+ xmlns: "http://www.w3.org/2000/svg",
343
+ width: "1em",
344
+ height: "1em",
345
+ fill: "none",
346
+ viewBox: "0 0 17 13"
347
+ }, props), {
348
+ children: [
349
+ /* @__PURE__ */ jsx10("path", { fill: "#FFF", d: "M7.925 1.5 4.59 4.357H1.925v4.286H4.59L7.925 11.5z" }),
350
+ /* @__PURE__ */ jsx10(
351
+ "path",
352
+ {
353
+ stroke: "#E5E7EB",
354
+ strokeLinecap: "round",
355
+ strokeLinejoin: "round",
356
+ strokeWidth: 2,
357
+ d: "m15.925 4.357-4 4.286m0-4.286 4 4.286m-8-7.143L4.59 4.357H1.925v4.286H4.59L7.925 11.5z"
358
+ }
359
+ )
360
+ ]
361
+ })
362
+ );
363
+ var MuteIcon_default = SvgMuteIcon;
364
+
365
+ // src/components/icons/NoteIcon.tsx
366
+ import { jsx as jsx11 } from "react/jsx-runtime";
367
+
368
+ // src/components/icons/OpenNoteIcon.tsx
369
+ import { jsx as jsx12 } from "react/jsx-runtime";
370
+
371
+ // src/components/icons/PauseIcon.tsx
372
+ import { jsx as jsx13 } from "react/jsx-runtime";
373
+ var SvgPauseIcon = (props) => /* @__PURE__ */ jsx13(
374
+ "svg",
375
+ __spreadProps(__spreadValues({
376
+ xmlns: "http://www.w3.org/2000/svg",
377
+ width: "1em",
378
+ height: "1em",
379
+ fill: "none",
380
+ viewBox: "0 0 9 14"
381
+ }, props), {
382
+ children: /* @__PURE__ */ jsx13("path", { fill: "#fff", d: "M2.89 0H0v13.333h2.89zM8.78 0H5.89v13.333h2.89z" })
383
+ })
384
+ );
385
+ var PauseIcon_default = SvgPauseIcon;
386
+
387
+ // src/components/icons/PlayIcon.tsx
388
+ import { jsx as jsx14 } from "react/jsx-runtime";
389
+ var SvgPlayIcon = (props) => /* @__PURE__ */ jsx14(
390
+ "svg",
391
+ __spreadProps(__spreadValues({
392
+ xmlns: "http://www.w3.org/2000/svg",
393
+ width: "1em",
394
+ height: "1em",
395
+ fill: "none",
396
+ viewBox: "0 0 13 15"
397
+ }, props), {
398
+ children: /* @__PURE__ */ jsx14(
399
+ "path",
400
+ {
401
+ stroke: "#fff",
402
+ strokeLinecap: "round",
403
+ strokeLinejoin: "round",
404
+ strokeWidth: 2,
405
+ d: "m1.37 1 10.11 6.5L1.37 14z"
406
+ }
407
+ )
408
+ })
409
+ );
410
+ var PlayIcon_default = SvgPlayIcon;
411
+
412
+ // src/components/icons/SettingsIcon.tsx
413
+ import { jsx as jsx15 } from "react/jsx-runtime";
414
+ var SvgSettingsIcon = (props) => /* @__PURE__ */ jsx15(
415
+ "svg",
416
+ __spreadProps(__spreadValues({
417
+ xmlns: "http://www.w3.org/2000/svg",
418
+ width: "1em",
419
+ height: "1em",
420
+ fill: "none",
421
+ viewBox: "0 0 13 13"
422
+ }, props), {
423
+ children: /* @__PURE__ */ jsx15(
424
+ "path",
425
+ {
426
+ fill: "#FFF",
427
+ d: "m12.507 8.062-1.117-.645a5 5 0 0 0 0-1.84l1.117-.644a.32.32 0 0 0 .144-.367 6.5 6.5 0 0 0-1.434-2.48.315.315 0 0 0-.388-.06l-1.116.645a5 5 0 0 0-1.594-.92V.464a.314.314 0 0 0-.246-.307 6.6 6.6 0 0 0-2.862 0 .314.314 0 0 0-.247.307v1.29a5.1 5.1 0 0 0-1.593.92l-1.114-.645a.31.31 0 0 0-.388.06 6.5 6.5 0 0 0-1.434 2.48.314.314 0 0 0 .144.366l1.117.645a5 5 0 0 0 0 1.84l-1.117.645a.32.32 0 0 0-.144.367c.291.933.787 1.777 1.434 2.48.1.106.262.133.388.06l1.116-.645c.47.403 1.01.715 1.594.92v1.29c0 .146.102.274.246.306a6.6 6.6 0 0 0 2.862 0 .314.314 0 0 0 .247-.307v-1.29a5.1 5.1 0 0 0 1.593-.92l1.117.645c.128.074.288.05.388-.06a6.5 6.5 0 0 0 1.433-2.48.324.324 0 0 0-.146-.369m-6.065.532a2.1 2.1 0 0 1-2.097-2.097 2.1 2.1 0 0 1 2.097-2.096 2.1 2.1 0 0 1 2.096 2.096 2.1 2.1 0 0 1-2.096 2.097"
428
+ }
429
+ )
430
+ })
431
+ );
432
+ var SettingsIcon_default = SvgSettingsIcon;
433
+
434
+ // src/components/icons/UnmuteIcon.tsx
435
+ import { jsx as jsx16 } from "react/jsx-runtime";
436
+ var SvgUnmuteIcon = (props) => /* @__PURE__ */ jsx16(
437
+ "svg",
438
+ __spreadProps(__spreadValues({
439
+ xmlns: "http://www.w3.org/2000/svg",
440
+ width: "1em",
441
+ height: "1em",
442
+ fill: "none",
443
+ viewBox: "0 0 8 15"
444
+ }, props), {
445
+ children: /* @__PURE__ */ jsx16(
446
+ "path",
447
+ {
448
+ fill: "#FFF",
449
+ d: "M7.659 14.275h-.001l-3.979-3.251a.16.16 0 0 0-.104-.035H2.252A1.33 1.33 0 0 1 .924 9.66V5.32A1.33 1.33 0 0 1 2.252 3.99h1.323a.16.16 0 0 0 .101-.035L7.66.725a.163.163 0 0 1 .265.126v13.297a.162.162 0 0 1-.264.127z"
450
+ }
451
+ )
452
+ })
453
+ );
454
+ var UnmuteIcon_default = SvgUnmuteIcon;
455
+
456
+ // src/components/icons/SubtitlesIcon.tsx
457
+ import { jsx as jsx17, jsxs as jsxs2 } from "react/jsx-runtime";
458
+ var SvgSubtitlesIcon = (props) => /* @__PURE__ */ jsxs2("svg", __spreadProps(__spreadValues({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em" }, props), { children: [
459
+ /* @__PURE__ */ jsx17(
460
+ "path",
461
+ {
462
+ fill: "#FFF",
463
+ d: "m78.649 64.733 4.772-.014c4.355-.012 8.711-.012 13.067-.01 4.703 0 9.407-.01 14.11-.02q13.815-.023 27.629-.023 11.23-.001 22.463-.012 31.861-.026 63.724-.025h6.94c18.57.001 37.138-.018 55.707-.046q28.618-.043 57.235-.04c10.706 0 21.413-.006 32.119-.027q13.673-.028 27.347-.009c4.647.006 9.295.007 13.943-.01q6.39-.024 12.783.004 2.303.005 4.605-.012c17.985-.122 33.209 4.858 46.137 17.55 8.927 9.239 14.882 21.979 14.901 34.934l.012 2.976-.003 3.246.01 3.467q.01 5.763.011 11.526l.015 8.254q.02 11.222.024 22.445l.012 14.022q.019 19.423.026 38.845v5.027l.002 5.048v2.53q.009 20.274.046 40.55.035 20.83.037 41.661-.001 11.69.025 23.38.023 9.956.012 19.913-.006 5.075.011 10.15c.013 3.677.007 7.353-.004 11.03l.025 3.206c-.1 15.234-5.618 28.587-16.181 39.571L478 426l-1.71 1.742c-12.91 12.154-30.359 13.722-47.23 13.639q-2.341.005-4.684.014c-4.25.013-8.502.007-12.753-.003-4.6-.007-9.2.004-13.8.012-8.996.013-17.991.01-26.987.002a15973 15973 0 0 0-25.105-.003q-3.18 0-6.358.003c-19.85.008-39.7-.002-59.55-.018a31884 31884 0 0 0-51.037.003 46445 46445 0 0 1-65.678.01l-3.148-.001q-10.951-.003-21.904.009-13.356.013-26.712-.01c-4.539-.008-9.077-.011-13.616-.001q-6.243.013-12.487-.012a631 631 0 0 0-4.493.006c-19.337.087-36.076-3.874-50.342-17.72-11.99-13.314-15.732-28.763-15.667-46.265l-.011-3.376c-.01-3.706-.007-7.412-.003-11.118q-.007-4.003-.015-8.006-.018-9.72-.012-19.439.002-7.905-.005-15.812l-.001-2.28-.004-4.584q-.014-21.467-.003-42.935c.006-13.068-.006-26.137-.025-39.205q-.03-20.168-.024-40.336.005-11.307-.014-22.614-.019-9.625-.002-19.252.01-4.903-.005-9.806c-.063-21.392.482-40.17 16.182-56.468L33 80l1.64-1.707C46.883 66.577 62.55 64.697 78.65 64.733M57 111c-3.615 5.55-3.427 10.594-3.394 16.994l-.019 3.364c-.017 3.722-.012 7.443-.007 11.165q-.01 4.002-.026 8.003c-.02 6.495-.025 12.99-.023 19.485a9577 9577 0 0 1-.017 20.405l-.003 2.295c-.019 14.32-.018 28.641-.01 42.961.005 13.096-.016 26.191-.05 39.287q-.05 20.178-.043 40.355c.002 7.55-.003 15.1-.028 22.65q-.033 9.641-.006 19.283.016 4.917-.01 9.834c-.019 3.558-.006 7.114.015 10.671l-.038 3.124c.093 7.623 1.84 12.297 7.234 17.703 6.322 4.896 14.068 4.11 21.659 4.042q2.337.007 4.673.02c4.269.017 8.537.003 12.806-.017 4.608-.015 9.216-.002 13.824.008 9.023.015 18.044.002 27.067-.02 10.505-.023 21.01-.021 31.516-.019 18.742.004 37.484-.017 56.226-.051q27.285-.05 54.569-.041 29.71.012 59.42-.015l3.173-.004 6.31-.006q10.986-.009 21.973-.006 13.386.003 26.77-.032c4.554-.012 9.107-.019 13.66-.013q6.252.006 12.502-.023 2.264-.008 4.526.001c2.05.007 4.098-.004 6.147-.02l3.45-.005c6.13-.735 10.246-3.731 14.154-8.378 3.27-6.025 3.426-11.188 3.381-17.962l.014-3.318c.012-3.663.003-7.326-.007-10.99q.007-3.942.016-7.885c.013-6.395.01-12.79.002-19.185a8074 8074 0 0 1-.003-17.841q0-2.258.003-4.514c.008-14.102-.002-28.204-.018-42.306q-.018-18.139.003-36.278a23436 23436 0 0 0 .01-46.65l-.001-2.235q-.003-7.785.009-15.572.014-10.484-.015-20.972-.006-3.847.004-7.696c.008-3.502-.002-7.004-.017-10.507l.02-3.075c-.055-6.664-.708-12.636-5.014-18.037l-1.7-1.352-1.675-1.398c-4.658-2.84-9.18-3.477-14.556-3.481-1.96-.01-1.96-.01-3.96-.018l-4.33.011-4.617-.011c-4.226-.01-8.452-.008-12.677-.004-4.559.002-9.117-.007-13.675-.014q-13.395-.018-26.788-.012a26146 26146 0 0 1-31.19-.01q-29.507-.013-59.014-.003c-18.001.006-36.002-.006-54.003-.025q-27.72-.03-55.438-.024c-10.376.002-20.753 0-31.13-.014q-13.248-.019-26.498-.002-6.76.011-13.521-.005-6.189-.015-12.378.007-2.239.004-4.478-.008c-10.356-.052-17.722-.02-24.759 8.386"
464
+ }
465
+ ),
466
+ /* @__PURE__ */ jsx17(
467
+ "path",
468
+ {
469
+ fill: "#FFF",
470
+ d: "M211.594 166.027C225.564 177.95 232.89 192.341 237 210v15h-38l-2-12c-3.428-9.924-9.002-16.527-18.25-21.375-8.317-3.952-19.394-4.22-28.062-1.187C141.226 194.932 134.624 202.24 131 212c-1.17 3.683-1.154 7.207-1.193 11.057l-.025 2.13q-.035 3.484-.055 6.97l-.017 2.417q-.039 6.342-.06 12.685-.02 5.22-.082 10.44c-.05 4.218-.074 8.437-.081 12.657a438 438 0 0 1-.046 4.793c-.172 12.03 1.188 23.276 9.907 32.394 7.225 6.372 16.431 10.19 26.16 9.809 8.312-1.173 15.45-3.473 21.492-9.352h2l.75-1.625c1.25-2.375 1.25-2.375 3.188-5 4.139-6.774 5.081-13.528 6.062-21.375h38c0 21.963-4.801 38.798-20.363 54.422L214 337l-1.918 2.016c-13.517 13.248-32.973 17.296-51.127 17.296-18.978-.262-36.43-7.932-49.955-21.312-16.343-18.293-21.143-37.855-21.203-61.969l-.009-2.324q-.022-6.097-.028-12.193c-.006-4.15-.03-8.301-.058-12.451a1811 1811 0 0 1-.026-9.7q-.004-2.29-.024-4.582c-.185-22.871 5.05-43.382 21.063-60.465 27.59-27.967 70.078-29.363 100.879-5.289M391 162.5a300 300 0 0 1 4 3.5l2 1.54c13.042 10.34 22.013 28.145 24 44.46v13h-38l-3-14c-4.092-9.822-9.492-15.253-19-20-8.913-3.553-18.759-3.316-27.625.25-9.012 4.09-14.51 10.719-18.187 19.813-2.989 7.986-2.348 17.084-2.356 25.457l-.01 3.922q-.009 4.095-.007 8.192c0 3.47-.014 6.939-.031 10.408-.014 3.347-.013 6.693-.014 10.04l-.022 3.729c.035 13.571 1.681 25.006 11.057 35.294 7.318 6.316 16.193 9.264 25.738 9.106 9.753-.837 18.156-5.38 24.77-12.524 5.983-7.59 7.067-14.967 8.687-24.687h38c0 20.87-4.852 37.261-19 53l-1.57 1.852c-10.837 11.926-28.103 20.027-44.063 21.37-21.875.91-40.916-3.117-57.91-17.921-13.741-12.868-23.846-30.701-24.597-49.89a557 557 0 0 1-.021-4.03l-.015-2.24q-.021-3.648-.027-7.297l-.009-2.538q-.022-6.658-.028-13.315c-.006-4.547-.03-9.095-.058-13.642a2163 2163 0 0 1-.026-10.584q-.004-2.512-.024-5.023c-.175-23.795 5.888-42.815 22.536-60.43C321.02 145.335 363.02 141.156 391 162.5"
471
+ }
472
+ )
473
+ ] }));
474
+ var SubtitlesIcon_default = SvgSubtitlesIcon;
475
+
476
+ // src/components/VolumeSlider/index.tsx
477
+ import { jsx as jsx18, jsxs as jsxs3 } from "react/jsx-runtime";
478
+ var MIN = 0;
479
+ var MAX = 100;
480
+ var VolumeSlider = ({}) => {
481
+ const { player } = useSoftBuildersVideoPlayerContext();
482
+ const [volume, setVolume] = useState2(0);
483
+ useEffect2(() => {
484
+ setVolume((player == null ? void 0 : player.muted()) ? 0 : Number(player == null ? void 0 : player.volume()) * 100 || 0);
485
+ }, [player]);
486
+ const handleValueChange = (e) => {
487
+ const newVolume = Number(e.target.value);
488
+ setVolume(newVolume);
489
+ player == null ? void 0 : player.volume(newVolume / 100);
490
+ if (newVolume === 0) {
491
+ player == null ? void 0 : player.muted(true);
492
+ } else {
493
+ player == null ? void 0 : player.muted(false);
494
+ }
495
+ };
496
+ return /* @__PURE__ */ jsxs3("div", { className: "sb-flex sb-items-center sb-gap-2", children: [
497
+ volume === 0 || (player == null ? void 0 : player.muted()) ? /* @__PURE__ */ jsx18(MuteIcon_default, { className: "sb-w-3 sb-h-3" }) : /* @__PURE__ */ jsx18(UnmuteIcon_default, { className: "sb-w-3 sb-h-3" }),
498
+ /* @__PURE__ */ jsx18(
499
+ Slider_default,
500
+ {
501
+ value: volume,
502
+ handleValueChange,
503
+ min: MIN,
504
+ max: MAX
505
+ }
506
+ )
507
+ ] });
508
+ };
509
+ var VolumeSlider_default = VolumeSlider;
510
+
511
+ // src/components/QualityMenu/index.tsx
512
+ import { useEffect as useEffect4, useState as useState4 } from "react";
513
+
514
+ // src/components/MenuButton/index.tsx
515
+ import { useCallback, useEffect as useEffect3, useRef, useState as useState3 } from "react";
516
+ import { jsx as jsx19, jsxs as jsxs4 } from "react/jsx-runtime";
517
+ var MenuButton = ({ buttonContent, menuContent, close }) => {
518
+ const [isOpen, setIsOpen] = useState3(false);
519
+ const buttonRef = useRef(null);
520
+ const menuRef = useRef(null);
521
+ const toggleMenu = () => setIsOpen((prev) => !prev);
522
+ const closeMenu = useCallback(() => {
523
+ setIsOpen(false);
524
+ }, []);
525
+ useEffect3(() => {
526
+ const handleClickOutside = (event) => {
527
+ if (buttonRef.current && !buttonRef.current.contains(event.target) && menuRef.current && !menuRef.current.contains(event.target)) {
528
+ setIsOpen(false);
529
+ }
530
+ };
531
+ document.addEventListener("mousedown", handleClickOutside);
532
+ return () => document.removeEventListener("mousedown", handleClickOutside);
533
+ }, []);
534
+ useEffect3(() => {
535
+ if (close) close(closeMenu);
536
+ }, [close, closeMenu]);
537
+ return /* @__PURE__ */ jsxs4("div", { className: "sb-relative", children: [
538
+ /* @__PURE__ */ jsx19(
539
+ "button",
540
+ {
541
+ ref: buttonRef,
542
+ onClick: toggleMenu,
543
+ "aria-haspopup": "true",
544
+ "aria-expanded": isOpen,
545
+ "aria-label": "Open menu",
546
+ children: buttonContent
547
+ }
548
+ ),
549
+ isOpen && /* @__PURE__ */ jsx19(
550
+ "div",
551
+ {
552
+ ref: menuRef,
553
+ role: "menu",
554
+ "aria-orientation": "vertical",
555
+ "aria-labelledby": "Open menu",
556
+ className: "sb-absolute sb-shadow-lg sb-right-0 sb-bottom-10",
557
+ children: menuContent
558
+ }
559
+ )
560
+ ] });
561
+ };
562
+ var MenuButton_default = MenuButton;
563
+
564
+ // src/components/QualityMenu/index.tsx
565
+ import { jsx as jsx20, jsxs as jsxs5 } from "react/jsx-runtime";
566
+ var QualityOption = ({
567
+ isSelected,
568
+ quality,
569
+ onClick
570
+ }) => {
571
+ return /* @__PURE__ */ jsx20("button", { className: "hover:sb-text-orange-500 sb-p-2", onClick, children: /* @__PURE__ */ jsxs5("div", { className: "sb-grid sb-grid-cols-12 sb-items-center sb-gap-2", children: [
572
+ /* @__PURE__ */ jsx20("div", { className: "sb-col-span-3", children: isSelected ? /* @__PURE__ */ jsx20(CheckedIcon_default, { className: "sb-w-5 sb-h-5" }) : /* @__PURE__ */ jsx20("div", {}) }),
573
+ /* @__PURE__ */ jsx20("p", { className: "sb-text-left sb-col-span-9", children: quality.label })
574
+ ] }) });
575
+ };
576
+ var QualityMenu = ({}) => {
577
+ const { player } = useSoftBuildersVideoPlayerContext();
578
+ const [closeMenuFunction, setCloseMenuFunction] = useState4(void 0);
579
+ const [qualities, setQualities] = useState4(
580
+ []
581
+ );
582
+ const [currentQualitySrc, setCurrentQualitySrc] = useState4(void 0);
583
+ useEffect4(() => {
584
+ if (player) {
585
+ const sources = player.currentSources();
586
+ const qs = JSON.parse(
587
+ JSON.stringify(sources)
588
+ );
589
+ setQualities(qs);
590
+ const source = player.currentSource();
591
+ const quality = JSON.parse(
592
+ JSON.stringify(source)
593
+ );
594
+ setCurrentQualitySrc(quality.src);
595
+ }
596
+ }, [player]);
597
+ return /* @__PURE__ */ jsx20(
598
+ MenuButton_default,
599
+ {
600
+ buttonContent: /* @__PURE__ */ jsx20(SettingsIcon_default, { className: "sb-w-3 sb-h-3" }),
601
+ menuContent: /* @__PURE__ */ jsx20("div", { className: "sb-rounded-md sb-bg-[#303030] sb-bg-opacity-50 sb-py-5 sb-w-[150px]", children: /* @__PURE__ */ jsxs5("div", { className: "sb-flex sb-flex-col sb-gap-3", children: [
602
+ /* @__PURE__ */ jsxs5("div", { className: "sb-px-5 sb-flex sb-flex-row sb-gap-3 sb-items-start", children: [
603
+ /* @__PURE__ */ jsx20(
604
+ "button",
605
+ {
606
+ onClick: () => {
607
+ if (closeMenuFunction) {
608
+ closeMenuFunction();
609
+ }
610
+ },
611
+ className: "hover:sb-scale-150",
612
+ children: /* @__PURE__ */ jsx20(LeftArrowIcon_default, { className: "sb-w-3 sb-h-3" })
613
+ }
614
+ ),
615
+ /* @__PURE__ */ jsx20("h3", { children: "Quality" })
616
+ ] }),
617
+ /* @__PURE__ */ jsx20("div", { className: "sb-w-full sb-h-[.1px] sb-bg-[#AAAAAA] sb-bg-opacity-70" }),
618
+ /* @__PURE__ */ jsx20("div", { className: "sb-px-5 sb-flex sb-flex-col sb-gap-3 sb-items-start", children: qualities.map((q, i) => {
619
+ return /* @__PURE__ */ jsx20(
620
+ QualityOption,
621
+ {
622
+ isSelected: currentQualitySrc === q.src,
623
+ quality: q,
624
+ onClick: () => {
625
+ const source = qualities.find(
626
+ (_q) => q.label == _q.label
627
+ );
628
+ if (source && source.src != currentQualitySrc) {
629
+ player == null ? void 0 : player.src(source.src);
630
+ const currentTime = player == null ? void 0 : player.currentTime();
631
+ setCurrentQualitySrc(source.src);
632
+ player == null ? void 0 : player.currentTime(currentTime);
633
+ player == null ? void 0 : player.play();
634
+ }
635
+ }
636
+ },
637
+ `quality-${q.label}-${i}`
638
+ );
639
+ }) })
640
+ ] }) }),
641
+ close: (fn) => {
642
+ setCloseMenuFunction(() => fn);
643
+ }
644
+ }
645
+ );
646
+ };
647
+ var QualityMenu_default = QualityMenu;
648
+
649
+ // src/components/CreateNoteMenu/index.tsx
650
+ import { useState as useState5 } from "react";
651
+ import { jsx as jsx21, jsxs as jsxs6 } from "react/jsx-runtime";
652
+ var CreateNoteMenu = ({ handleSaveNoteAction }) => {
653
+ const { player } = useSoftBuildersVideoPlayerContext();
654
+ const [note, setNote] = useState5("");
655
+ const handleSaveNote = () => {
656
+ if (handleSaveNoteAction) {
657
+ const time = (player == null ? void 0 : player.currentTime()) || 0;
658
+ handleSaveNoteAction(time, note).then((response) => {
659
+ setNote("");
660
+ });
661
+ } else {
662
+ window.alert(
663
+ "Video Player, there is no implementation for the handleSaveNoteAction function"
664
+ );
665
+ }
666
+ };
667
+ return /* @__PURE__ */ jsx21(
668
+ MenuButton_default,
669
+ {
670
+ buttonContent: /* @__PURE__ */ jsx21(ClosedNoteIcon_default, { className: "sb-w-3 sb-h-3" }),
671
+ menuContent: /* @__PURE__ */ jsx21("div", { className: "sb-rounded-md sb-bg-[#303030] sb-bg-opacity-50 sb-py-5 sb-w-[220px]", children: /* @__PURE__ */ jsxs6("div", { className: "sb-flex sb-flex-col sb-gap-3", children: [
672
+ /* @__PURE__ */ jsx21("h3", { className: "sb-px-5", children: "Add Note" }),
673
+ /* @__PURE__ */ jsx21("div", { className: "sb-w-full sb-h-[.1px] sb-bg-[#AAAAAA] sb-bg-opacity-70" }),
674
+ /* @__PURE__ */ jsxs6("div", { className: "sb-px-5 sb-flex sb-flex-col sb-gap-4 sb-items-start", children: [
675
+ /* @__PURE__ */ jsx21(
676
+ "input",
677
+ {
678
+ name: "note",
679
+ type: "text",
680
+ placeholder: "Add a note",
681
+ value: note,
682
+ onChange: (e) => setNote(e.target.value),
683
+ required: true,
684
+ className: "sb-text-white placeholder:sb-text-white sb-w-full sb-bg-transparent sb-px-4 sb-py-3 sb-border sb-border-[#AAAAAA] sb-rounded-md"
685
+ }
686
+ ),
687
+ /* @__PURE__ */ jsx21("button", { className: "sb-w-full", onClick: handleSaveNote, children: /* @__PURE__ */ jsx21("div", { className: "sb-px-4 sb-py-3 sb-text-center sb-font-bold sb-bg-orange-500 sb-rounded-md", children: "Save" }) })
688
+ ] })
689
+ ] }) })
690
+ }
691
+ );
692
+ };
693
+ var CreateNoteMenu_default = CreateNoteMenu;
694
+
695
+ // src/components/NotesPanal/index.tsx
696
+ import { useEffect as useEffect6, useState as useState7 } from "react";
697
+
698
+ // src/components/NoteTooltip/index.tsx
699
+ import { useEffect as useEffect5, useState as useState6 } from "react";
700
+
701
+ // src/components/Tooltip/index.tsx
702
+ import { jsx as jsx22 } from "react/jsx-runtime";
703
+ var Tooltip = ({ open, children }) => {
704
+ if (!open) return null;
705
+ return /* @__PURE__ */ jsx22("div", { className: "sb-absolute sb-bottom-full sb-mb-2 sb-left-1/2 sb-transform sb--translate-x-1/2 sb-z-10 sb-whitespace-nowrap", children });
706
+ };
707
+ var Tooltip_default = Tooltip;
708
+
709
+ // src/components/NoteTooltip/index.tsx
710
+ import { jsx as jsx23, jsxs as jsxs7 } from "react/jsx-runtime";
711
+ var NoteTooltip = ({ note }) => {
712
+ const [open, setOpen] = useState6(false);
713
+ const { currentTime } = useSoftBuildersVideoPlayerContext();
714
+ useEffect5(() => {
715
+ if (currentTime === Math.floor(note.time)) {
716
+ setOpen(true);
717
+ setTimeout(() => {
718
+ setOpen(false);
719
+ }, 5e3);
720
+ }
721
+ }, [currentTime, note.time]);
722
+ return /* @__PURE__ */ jsx23(
723
+ "div",
724
+ {
725
+ className: "sb-w-1 sb-h-1 sb-rounded-full sb-bg-white sb-absolute sb-z-30",
726
+ style: { left: `${note.percentage}%` },
727
+ onMouseEnter: () => setOpen(true),
728
+ onMouseLeave: () => setOpen(false),
729
+ children: /* @__PURE__ */ jsx23("div", { className: "sb-relative", children: /* @__PURE__ */ jsx23(Tooltip_default, { open, children: /* @__PURE__ */ jsxs7("div", { className: "sb-flex sb-flex-col sb-gap-2 sb-items-center", children: [
730
+ /* @__PURE__ */ jsx23("p", { children: note.label }),
731
+ /* @__PURE__ */ jsx23("p", { className: "sb-p-2 sb-bg-[#303030] sb-bg-opacity-50 sb-rounded-md", children: durationFormater(note.time) })
732
+ ] }) }) })
733
+ }
734
+ );
735
+ };
736
+ var NoteTooltip_default = NoteTooltip;
737
+
738
+ // src/components/NotesPanal/index.tsx
739
+ import { jsx as jsx24 } from "react/jsx-runtime";
740
+ var NotesPanal = ({ notes }) => {
741
+ const [ns, setNs] = useState7([]);
742
+ const { duration } = useSoftBuildersVideoPlayerContext();
743
+ useEffect6(() => {
744
+ const newNs = notes.map((n) => {
745
+ const percentage = Math.floor(n.time * 100 / duration);
746
+ return __spreadProps(__spreadValues({}, n), {
747
+ percentage
748
+ });
749
+ });
750
+ setNs(newNs);
751
+ }, [notes, duration]);
752
+ return /* @__PURE__ */ jsx24("div", { id: "notes-panal", className: "sb-w-full sb-h-full sb-relative ", children: ns.map((n, i) => /* @__PURE__ */ jsx24(NoteTooltip_default, { note: n }, `note-${i}-${n.time}`)) });
753
+ };
754
+ var NotesPanal_default = NotesPanal;
755
+
756
+ // src/components/ChaptersPanal/index.tsx
757
+ import { useEffect as useEffect8, useState as useState9 } from "react";
758
+
759
+ // src/components/ChapterTooltip/index.tsx
760
+ import { useEffect as useEffect7, useState as useState8 } from "react";
761
+ import { jsx as jsx25, jsxs as jsxs8 } from "react/jsx-runtime";
762
+ var ChapterTooltip = ({ chapter }) => {
763
+ const { player } = useSoftBuildersVideoPlayerContext();
764
+ const [open, setOpen] = useState8(false);
765
+ const { currentTime } = useSoftBuildersVideoPlayerContext();
766
+ useEffect7(() => {
767
+ if (currentTime === Math.floor(chapter.startTime)) {
768
+ setOpen(true);
769
+ setTimeout(() => {
770
+ setOpen(false);
771
+ }, 5e3);
772
+ }
773
+ }, [currentTime, chapter.startTime]);
774
+ const handleClickChapter = () => {
775
+ player == null ? void 0 : player.currentTime(chapter.startTime);
776
+ };
777
+ return /* @__PURE__ */ jsx25(
778
+ "div",
779
+ {
780
+ id: `ii-section-${chapter.title}`,
781
+ className: "sb-flex sb-items-center sb-w-full sb-h-full sb-absolute sb-z-20",
782
+ style: {
783
+ left: `${chapter.startPercentage}%`,
784
+ width: `${chapter.endPercentage - chapter.startPercentage}%`
785
+ },
786
+ onMouseEnter: () => setOpen(true),
787
+ onMouseLeave: () => setOpen(false),
788
+ children: /* @__PURE__ */ jsx25(
789
+ "button",
790
+ {
791
+ id: `section-${chapter.title}`,
792
+ className: "sb-h-full sb-w-full",
793
+ onClick: handleClickChapter,
794
+ children: /* @__PURE__ */ jsx25("div", { className: "sb-relative sb-flex sb-h-full sb-w-full sb-justify-between sb-items-center", children: /* @__PURE__ */ jsx25(Tooltip_default, { open, children: /* @__PURE__ */ jsxs8("div", { className: "sb-flex sb-flex-col sb-gap-2 sb-items-center", children: [
795
+ /* @__PURE__ */ jsx25("p", { children: chapter.title }),
796
+ /* @__PURE__ */ jsxs8("p", { className: "sb-p-2 sb-bg-[#303030] sb-bg-opacity-50 sb-rounded-md", children: [
797
+ durationFormater(chapter.startTime),
798
+ " -",
799
+ " ",
800
+ durationFormater(chapter.endTime)
801
+ ] })
802
+ ] }) }) })
803
+ }
804
+ )
805
+ }
806
+ );
807
+ };
808
+ var ChapterTooltip_default = ChapterTooltip;
809
+
810
+ // src/components/ChaptersPanal/index.tsx
811
+ import { jsx as jsx26 } from "react/jsx-runtime";
812
+ var ChaptersPanal = ({ chapters }) => {
813
+ const [cs, setCs] = useState9([]);
814
+ const { duration } = useSoftBuildersVideoPlayerContext();
815
+ useEffect8(() => {
816
+ const newCs = chapters.map((c) => {
817
+ const startPercentage = Math.floor(c.startTime * 100 / duration);
818
+ const endPercentage = Math.floor(c.endTime * 100 / duration);
819
+ return __spreadProps(__spreadValues({}, c), {
820
+ startPercentage,
821
+ endPercentage
822
+ });
823
+ });
824
+ setCs(newCs);
825
+ }, [chapters, duration]);
826
+ return /* @__PURE__ */ jsx26("div", { id: "chapters-panal", className: "sb-w-full sb-h-full sb-relative ", children: cs.map((c, i) => /* @__PURE__ */ jsx26(ChapterTooltip_default, { chapter: c }, `chapter-${i}-${c.startTime}`)) });
827
+ };
828
+ var ChaptersPanal_default = ChaptersPanal;
829
+
830
+ // src/components/TimeSlider/index.tsx
831
+ import { useEffect as useEffect9, useState as useState10 } from "react";
832
+ import { jsx as jsx27, jsxs as jsxs9 } from "react/jsx-runtime";
833
+ var MIN2 = 0;
834
+ var MAX2 = 100;
835
+ var DEFERENCE = Math.abs(MAX2 - MIN2);
836
+ var BAR_PERCENTAGE_WIDTH = 0.5;
837
+ var TimeSlider = ({ chapters }) => {
838
+ const [timeSlider, setTimeSlider] = useState10(0);
839
+ const { player, duration, downloadedBufferPercentage } = useSoftBuildersVideoPlayerContext();
840
+ const handleValueChange = (e) => {
841
+ const newTimeSlider = Number(e.target.value);
842
+ setTimeSlider(newTimeSlider);
843
+ const time = newTimeSlider * duration / DEFERENCE;
844
+ player == null ? void 0 : player.currentTime(time);
845
+ };
846
+ useEffect9(() => {
847
+ const intervalId = setInterval(() => {
848
+ const currentTime = (player == null ? void 0 : player.currentTime()) || 0;
849
+ const time = currentTime * DEFERENCE / duration;
850
+ setTimeSlider(time);
851
+ }, 1e3);
852
+ return () => clearInterval(intervalId);
853
+ }, [player, duration]);
854
+ const [maskCuttes, setMaskCuttes] = useState10("");
855
+ useEffect9(() => {
856
+ const arr = ["black 0%"];
857
+ chapters.forEach((c) => {
858
+ const startPercentage = Math.floor(c.startTime * 100 / duration);
859
+ const endPercentage = Math.floor(c.endTime * 100 / duration);
860
+ arr.push(`black ${startPercentage}%`);
861
+ arr.push(`transparent ${startPercentage}%`);
862
+ arr.push(`transparent ${startPercentage + BAR_PERCENTAGE_WIDTH}%`);
863
+ arr.push(`black ${startPercentage + BAR_PERCENTAGE_WIDTH}%`);
864
+ arr.push(`black ${endPercentage}%`);
865
+ arr.push(`transparent ${endPercentage}%`);
866
+ arr.push(`transparent ${endPercentage + BAR_PERCENTAGE_WIDTH}%`);
867
+ arr.push(`black ${endPercentage + BAR_PERCENTAGE_WIDTH}%`);
868
+ });
869
+ arr.push(`black 100%`);
870
+ setMaskCuttes(arr.toString());
871
+ }, [chapters, duration]);
872
+ return /* @__PURE__ */ jsxs9("div", { className: " sb-w-full sb-h-2 sb-flex sb-items-center sb-justify-center", children: [
873
+ /* @__PURE__ */ jsx27("div", { className: "sb-absolute sb-top-0 sb-left-0 sb-w-full sb-z-10", children: /* @__PURE__ */ jsx27(
874
+ Slider_default,
875
+ {
876
+ value: timeSlider,
877
+ handleValueChange,
878
+ min: MIN2,
879
+ max: MAX2,
880
+ style: {
881
+ background: "transparent"
882
+ }
883
+ }
884
+ ) }),
885
+ /* @__PURE__ */ jsx27(
886
+ "div",
887
+ {
888
+ className: "sb-absolute sb-top-0 sb-left-0 sb-w-full sb-h-2 sb-bg-slate-400 sb-rounded-md",
889
+ style: {
890
+ background: `
891
+ linear-gradient(to right,
892
+ #f97316 0%,
893
+ #f97316 ${timeSlider}%,
894
+ #f9731640 ${timeSlider}%,
895
+ #f9731640 ${downloadedBufferPercentage}%,
896
+ #30303030 ${timeSlider}%,
897
+ #30303030 100%
898
+ )
899
+ `,
900
+ maskImage: `
901
+ linear-gradient(to right,
902
+ ${maskCuttes}
903
+ )
904
+ `,
905
+ maskSize: "100% 100%",
906
+ maskRepeat: "no-repeat"
907
+ }
908
+ }
909
+ )
910
+ ] });
911
+ };
912
+ var TimeSlider_default = TimeSlider;
913
+
914
+ // src/components/TimeSliderContainer/index.tsx
915
+ import { jsx as jsx28, jsxs as jsxs10 } from "react/jsx-runtime";
916
+ var TimeSliderContainer = ({ notes, chapters }) => {
917
+ return /* @__PURE__ */ jsxs10(
918
+ "div",
919
+ {
920
+ id: "time-slider-container",
921
+ className: "sb-w-full sb-relative sb-flex sb-items-center sb-justify-center",
922
+ children: [
923
+ /* @__PURE__ */ jsx28(
924
+ "div",
925
+ {
926
+ id: "notes-panal",
927
+ className: "sb-absolute sb-w-full sb-h-full sb-top-[27%] sb-left-0",
928
+ children: /* @__PURE__ */ jsx28(NotesPanal_default, { notes })
929
+ }
930
+ ),
931
+ /* @__PURE__ */ jsx28("div", { className: "sb-absolute sb-w-full sb-h-full sb-top-0 sb-left-0", children: /* @__PURE__ */ jsx28(ChaptersPanal_default, { chapters }) }),
932
+ /* @__PURE__ */ jsx28(TimeSlider_default, { chapters })
933
+ ]
934
+ }
935
+ );
936
+ };
937
+ var TimeSliderContainer_default = TimeSliderContainer;
938
+
939
+ // src/components/BufferTracker/index.tsx
940
+ import { useEffect as useEffect10 } from "react";
941
+ import { Fragment, jsx as jsx29 } from "react/jsx-runtime";
942
+ var BufferTracker = () => {
943
+ const { player, setDownloadedBufferTimeufferTime } = useSoftBuildersVideoPlayerContext();
944
+ useEffect10(() => {
945
+ const intervalId = setInterval(() => {
946
+ if (player) setDownloadedBufferTimeufferTime(player.bufferedEnd());
947
+ }, 1e3);
948
+ return () => clearInterval(intervalId);
949
+ }, [player]);
950
+ return /* @__PURE__ */ jsx29(Fragment, {});
951
+ };
952
+ var BufferTracker_default = BufferTracker;
953
+
954
+ // src/components/CurrentTimeTracker/index.tsx
955
+ import { useEffect as useEffect11 } from "react";
956
+ import { Fragment as Fragment2, jsx as jsx30 } from "react/jsx-runtime";
957
+ var CurrentTimeTracker = () => {
958
+ const { setCurrentTime, player } = useSoftBuildersVideoPlayerContext();
959
+ useEffect11(() => {
960
+ const intervalId = setInterval(() => {
961
+ setCurrentTime((player == null ? void 0 : player.currentTime()) || 0);
962
+ }, 500);
963
+ return () => clearInterval(intervalId);
964
+ }, [player]);
965
+ return /* @__PURE__ */ jsx30(Fragment2, {});
966
+ };
967
+ var CurrentTimeTracker_default = CurrentTimeTracker;
968
+
969
+ // src/components/SubtitleMenu/index.tsx
970
+ import { useEffect as useEffect12, useState as useState11 } from "react";
971
+ import { jsx as jsx31, jsxs as jsxs11 } from "react/jsx-runtime";
972
+ var SubtitleOption = ({
973
+ isSelected,
974
+ subtitle,
975
+ onClick
976
+ }) => {
977
+ return /* @__PURE__ */ jsx31("button", { className: "hover:sb-text-orange-500 sb-p-2", onClick, children: /* @__PURE__ */ jsxs11("div", { className: "sb-grid sb-grid-cols-12 sb-items-center sb-gap-2", children: [
978
+ /* @__PURE__ */ jsx31("div", { className: "sb-col-span-3", children: isSelected ? /* @__PURE__ */ jsx31(CheckedIcon_default, { className: "sb-w-5 sb-h-5" }) : /* @__PURE__ */ jsx31("div", {}) }),
979
+ /* @__PURE__ */ jsx31("p", { className: "sb-text-left sb-col-span-9", children: subtitle.label })
980
+ ] }) });
981
+ };
982
+ var SubtitleMenu = ({}) => {
983
+ const { player } = useSoftBuildersVideoPlayerContext();
984
+ const [closeMenuFunction, setCloseMenuFunction] = useState11(void 0);
985
+ const [subtitles, setSubtitles] = useState11([]);
986
+ const handleSelectSubtitle = (textTrack) => {
987
+ const newSubtitles = subtitles.map((s) => {
988
+ if (s.label === textTrack.label) {
989
+ s.mode = "showing";
990
+ } else {
991
+ s.mode = "disabled";
992
+ }
993
+ return s;
994
+ });
995
+ setSubtitles(newSubtitles);
996
+ };
997
+ useEffect12(() => {
998
+ var _a;
999
+ if (player) {
1000
+ const textTracks = (_a = player.textTracks()) == null ? void 0 : _a.tracks_;
1001
+ setSubtitles(textTracks);
1002
+ }
1003
+ }, [player]);
1004
+ return /* @__PURE__ */ jsx31(
1005
+ MenuButton_default,
1006
+ {
1007
+ buttonContent: /* @__PURE__ */ jsx31(SubtitlesIcon_default, { className: "sb-w-3 sb-h-3" }),
1008
+ menuContent: /* @__PURE__ */ jsx31("div", { className: "sb-rounded-md sb-bg-[#303030] sb-bg-opacity-50 sb-py-5 sb-w-[150px]", children: /* @__PURE__ */ jsxs11("div", { className: "sb-flex sb-flex-col sb-gap-3", children: [
1009
+ /* @__PURE__ */ jsxs11("div", { className: "sb-px-5 sb-flex sb-flex-row sb-gap-3 sb-items-start", children: [
1010
+ /* @__PURE__ */ jsx31(
1011
+ "button",
1012
+ {
1013
+ onClick: () => {
1014
+ if (closeMenuFunction) {
1015
+ closeMenuFunction();
1016
+ }
1017
+ },
1018
+ className: "hover:sb-scale-150",
1019
+ children: /* @__PURE__ */ jsx31(LeftArrowIcon_default, { className: "sb-w-3 sb-h-3" })
1020
+ }
1021
+ ),
1022
+ /* @__PURE__ */ jsx31("h3", { children: "Subtitle" })
1023
+ ] }),
1024
+ /* @__PURE__ */ jsx31("div", { className: "sb-w-full sb-h-[.1px] sb-bg-[#AAAAAA] sb-bg-opacity-70" }),
1025
+ /* @__PURE__ */ jsx31("div", { className: "sb-px-5 sb-flex sb-flex-col sb-gap-3 sb-items-start", children: subtitles.map((q, i) => {
1026
+ return /* @__PURE__ */ jsx31(
1027
+ SubtitleOption,
1028
+ {
1029
+ isSelected: q.mode === "showing",
1030
+ subtitle: q,
1031
+ onClick: () => {
1032
+ handleSelectSubtitle(q);
1033
+ }
1034
+ },
1035
+ `subtitle-${q.label}-${i}`
1036
+ );
1037
+ }) })
1038
+ ] }) }),
1039
+ close: (fn) => {
1040
+ setCloseMenuFunction(() => fn);
1041
+ }
1042
+ }
1043
+ );
1044
+ };
1045
+ var SubtitleMenu_default = SubtitleMenu;
1046
+
1047
+ // src/components/ControlBar/index.tsx
1048
+ import { jsx as jsx32, jsxs as jsxs12 } from "react/jsx-runtime";
1049
+ var ControlBar = ({
1050
+ player,
1051
+ isPaused,
1052
+ setIsPaused,
1053
+ duration,
1054
+ notes,
1055
+ chapters,
1056
+ seekStep = 5,
1057
+ handleSaveNoteAction
1058
+ }) => {
1059
+ const { setPlayer, setDuration } = useSoftBuildersVideoPlayerContext();
1060
+ const seek = (duration2) => {
1061
+ const currentTime = Number((player == null ? void 0 : player.currentTime()) || 0);
1062
+ player == null ? void 0 : player.currentTime(currentTime + duration2);
1063
+ };
1064
+ const togglePlay = () => {
1065
+ if (isPaused) player == null ? void 0 : player.play();
1066
+ else player == null ? void 0 : player.pause();
1067
+ setIsPaused(!isPaused);
1068
+ };
1069
+ useEffect13(() => {
1070
+ setPlayer(player);
1071
+ }, [player]);
1072
+ useEffect13(() => {
1073
+ setDuration(duration);
1074
+ }, [duration]);
1075
+ return /* @__PURE__ */ jsxs12("div", { className: "sb-flex sb-items-center sb-justify-center sb-gap-3 sb-w-full", children: [
1076
+ /* @__PURE__ */ jsx32(BufferTracker_default, {}),
1077
+ /* @__PURE__ */ jsx32(CurrentTimeTracker_default, {}),
1078
+ /* @__PURE__ */ jsx32(
1079
+ "button",
1080
+ {
1081
+ onClick: () => {
1082
+ seek(-seekStep);
1083
+ },
1084
+ children: /* @__PURE__ */ jsx32(BackwardIcon_default, { className: "sb-w-3 sb-h-3" })
1085
+ }
1086
+ ),
1087
+ /* @__PURE__ */ jsx32("button", { onClick: togglePlay, children: isPaused ? /* @__PURE__ */ jsx32(PlayIcon_default, { className: "sb-w-3 sb-h-3" }) : /* @__PURE__ */ jsx32(PauseIcon_default, { className: "sb-w-3 sb-h-3" }) }),
1088
+ /* @__PURE__ */ jsx32(
1089
+ "button",
1090
+ {
1091
+ onClick: () => {
1092
+ seek(seekStep);
1093
+ },
1094
+ children: /* @__PURE__ */ jsx32(ForwardIcon_default, { className: "sb-w-3 sb-h-3" })
1095
+ }
1096
+ ),
1097
+ /* @__PURE__ */ jsx32(CurrentTimeLabel_default, {}),
1098
+ /* @__PURE__ */ jsx32("div", { className: "sb-w-[30%] hover:sb-w-[45%] sb-transition-all sb-ease-in-out sb-duration-500", children: /* @__PURE__ */ jsx32(TimeSliderContainer_default, { chapters, notes }) }),
1099
+ /* @__PURE__ */ jsx32("p", { children: durationFormater(duration) }),
1100
+ /* @__PURE__ */ jsx32("div", { className: "sb-w-[10%]", children: /* @__PURE__ */ jsx32(VolumeSlider_default, {}) }),
1101
+ /* @__PURE__ */ jsx32(QualityMenu_default, {}),
1102
+ /* @__PURE__ */ jsx32(
1103
+ "button",
1104
+ {
1105
+ onClick: () => {
1106
+ if (player == null ? void 0 : player.isFullscreen()) {
1107
+ player == null ? void 0 : player.exitFullscreen();
1108
+ } else {
1109
+ player == null ? void 0 : player.requestFullscreen();
1110
+ }
1111
+ },
1112
+ children: /* @__PURE__ */ jsx32(FullScreenIcon_default, { className: "sb-w-3 sb-h-3" })
1113
+ }
1114
+ ),
1115
+ handleSaveNoteAction && /* @__PURE__ */ jsx32(CreateNoteMenu_default, { handleSaveNoteAction }),
1116
+ /* @__PURE__ */ jsx32(SubtitleMenu_default, {})
1117
+ ] });
1118
+ };
1119
+ var ControlBar_default = ControlBar;
1120
+
1121
+ // src/components/BigPlayButton/index.tsx
1122
+ import { jsx as jsx33 } from "react/jsx-runtime";
1123
+ var BigPlayButton = ({ player, isPaused, setIsPaused }) => {
1124
+ const togglePlay = () => {
1125
+ if (isPaused) player == null ? void 0 : player.play();
1126
+ else player == null ? void 0 : player.pause();
1127
+ setIsPaused(!isPaused);
1128
+ };
1129
+ return /* @__PURE__ */ jsx33("button", { onClick: togglePlay, children: /* @__PURE__ */ jsx33("div", { className: "sb-w-16 sb-h-16 sb-rounded-full sb-bg-white/30 sb-backdrop-blur-lg sb-flex sb-items-center sb-justify-center ", children: isPaused ? /* @__PURE__ */ jsx33(PlayIcon_default, { className: "sb-w-4 sb-h-4" }) : /* @__PURE__ */ jsx33(PauseIcon_default, { className: "sb-w-4 sb-h-4" }) }) });
1130
+ };
1131
+ var BigPlayButton_default = BigPlayButton;
1132
+
1133
+ // src/components/VideoPlayerComponent/index.tsx
1134
+ import { jsx as jsx34 } from "react/jsx-runtime";
1135
+ var bigPlayButtonRoot = {};
1136
+ var renderBigPlayButton = (id, player, isPaused, setIsPaused) => {
1137
+ const container = document.getElementById(`video-container-${id}`);
1138
+ if (container) {
1139
+ const element = container.querySelector(".vjs-big-play-button");
1140
+ if (element) {
1141
+ if (!bigPlayButtonRoot[id]) {
1142
+ bigPlayButtonRoot[id] = ReactDOM.createRoot(element);
1143
+ }
1144
+ bigPlayButtonRoot[id].render(
1145
+ /* @__PURE__ */ jsx34(
1146
+ BigPlayButton_default,
1147
+ {
1148
+ player,
1149
+ isPaused,
1150
+ setIsPaused
1151
+ }
1152
+ )
1153
+ );
1154
+ }
1155
+ }
1156
+ };
1157
+ var controlBarRoot = {};
1158
+ var renderControlBar = (id, player, isPaused, setIsPaused, duration, notes, chapters, seekStep = 5, handleSaveNoteAction) => {
1159
+ const container = document.getElementById(`video-container-${id}`);
1160
+ if (container) {
1161
+ const element = container.querySelector(".vjs-control-bar");
1162
+ if (element) {
1163
+ if (!controlBarRoot[id]) {
1164
+ controlBarRoot[id] = ReactDOM.createRoot(element);
1165
+ }
1166
+ element.style.display = "block";
1167
+ controlBarRoot[id].render(
1168
+ /* @__PURE__ */ jsx34(SoftBuildersVideoPlayerProvider, { children: /* @__PURE__ */ jsx34(
1169
+ ControlBar_default,
1170
+ {
1171
+ player,
1172
+ isPaused,
1173
+ setIsPaused,
1174
+ duration,
1175
+ notes,
1176
+ chapters,
1177
+ seekStep,
1178
+ handleSaveNoteAction
1179
+ }
1180
+ ) })
1181
+ );
1182
+ }
1183
+ }
1184
+ };
1185
+ var VideoPlayerComponent = ({
1186
+ id,
1187
+ options,
1188
+ notes,
1189
+ chapters,
1190
+ startTime = 0,
1191
+ handleSaveNoteAction,
1192
+ onPlay,
1193
+ onPause
1194
+ }) => {
1195
+ const videoRef = useRef2(void 0);
1196
+ const playerRef = useRef2(void 0);
1197
+ const [isReady, setIsReady] = useState12(false);
1198
+ const [isPaused, setIsPaused] = useState12(!options.autoplay);
1199
+ const [duration, setDuratoin] = useState12(1);
1200
+ const onReady = (player) => {
1201
+ playerRef.current = player;
1202
+ setIsReady(true);
1203
+ player.currentTime(startTime);
1204
+ player.on("waiting", () => {
1205
+ });
1206
+ player.on("dispose", () => {
1207
+ videojs.log("player will dispose");
1208
+ setIsReady(false);
1209
+ });
1210
+ player.on("loadedmetadata", () => {
1211
+ const d = player.duration();
1212
+ setDuratoin(d);
1213
+ });
1214
+ };
1215
+ useEffect14(() => {
1216
+ if (!playerRef.current) {
1217
+ const videoElement = document.createElement("video-js");
1218
+ videoElement.classList.add("vjs-big-play-centered");
1219
+ videoRef.current.appendChild(videoElement);
1220
+ playerRef.current = videojs(videoElement, options, () => {
1221
+ onReady(playerRef.current);
1222
+ });
1223
+ }
1224
+ return () => {
1225
+ if (playerRef.current) {
1226
+ playerRef.current.dispose();
1227
+ playerRef.current = void 0;
1228
+ setTimeout(() => {
1229
+ if (bigPlayButtonRoot[id]) {
1230
+ bigPlayButtonRoot[id].unmount();
1231
+ bigPlayButtonRoot[id] = void 0;
1232
+ }
1233
+ if (controlBarRoot[id]) {
1234
+ controlBarRoot[id].unmount();
1235
+ controlBarRoot[id] = void 0;
1236
+ }
1237
+ }, 0);
1238
+ }
1239
+ };
1240
+ }, [options]);
1241
+ useEffect14(() => {
1242
+ if (playerRef && (playerRef == null ? void 0 : playerRef.current) && isReady) {
1243
+ const currentTime = playerRef.current.currentTime() || 0;
1244
+ if (isPaused) {
1245
+ if (onPause) onPause(currentTime);
1246
+ } else {
1247
+ if (onPlay) onPlay(currentTime);
1248
+ }
1249
+ }
1250
+ }, [isPaused, isReady]);
1251
+ useEffect14(() => {
1252
+ if (isReady) {
1253
+ const controlBarTimeout = setTimeout(() => {
1254
+ renderControlBar(
1255
+ id,
1256
+ playerRef.current,
1257
+ isPaused,
1258
+ setIsPaused,
1259
+ duration,
1260
+ notes,
1261
+ chapters,
1262
+ 5,
1263
+ handleSaveNoteAction
1264
+ );
1265
+ }, 500);
1266
+ return () => clearTimeout(controlBarTimeout);
1267
+ }
1268
+ }, [
1269
+ id,
1270
+ playerRef,
1271
+ isPaused,
1272
+ setIsPaused,
1273
+ notes,
1274
+ chapters,
1275
+ isReady,
1276
+ handleSaveNoteAction,
1277
+ duration
1278
+ ]);
1279
+ useEffect14(() => {
1280
+ if (isReady) {
1281
+ const playButtonTimeout = setTimeout(() => {
1282
+ renderBigPlayButton(id, playerRef.current, isPaused, setIsPaused);
1283
+ }, 500);
1284
+ return () => clearTimeout(playButtonTimeout);
1285
+ }
1286
+ }, [id, isPaused, isReady]);
1287
+ useEffect14(() => {
1288
+ if (playerRef.current) {
1289
+ const intervalId = setInterval(() => {
1290
+ setIsPaused(playerRef.current.paused());
1291
+ }, 500);
1292
+ return () => clearInterval(intervalId);
1293
+ }
1294
+ }, []);
1295
+ return /* @__PURE__ */ jsx34(
1296
+ "div",
1297
+ {
1298
+ id: `video-container-${id}`,
1299
+ className: "sb-relative sb-rounded-md sb-overflow-hidden",
1300
+ children: /* @__PURE__ */ jsx34("div", { "data-vjs-player": true, children: /* @__PURE__ */ jsx34("div", { ref: videoRef }) })
1301
+ }
1302
+ );
1303
+ };
1304
+ var VideoPlayerComponent_default = VideoPlayerComponent;
1305
+
1306
+ // src/components/SoftBuildersVideoPlayer/index.tsx
1307
+ import { jsx as jsx35 } from "react/jsx-runtime";
1308
+ var DEFAULT_OPTIONS = {
1309
+ autoplay: false,
1310
+ controls: true,
1311
+ fluid: true,
1312
+ muted: true,
1313
+ height: 420,
1314
+ width: 720,
1315
+ sources: [],
1316
+ tracks: []
1317
+ };
1318
+ var Component = ({
1319
+ options,
1320
+ notes,
1321
+ chapters,
1322
+ startTime = 0,
1323
+ handleSaveNoteAction,
1324
+ onPlay,
1325
+ onPause
1326
+ }) => {
1327
+ options = __spreadProps(__spreadValues({}, options), {
1328
+ responsive: true,
1329
+ inactivityTimeout: 0,
1330
+ fullscreen: {
1331
+ navigationUI: "hide"
1332
+ }
1333
+ });
1334
+ if (options.autoplay === void 0)
1335
+ options.autoplay = DEFAULT_OPTIONS.autoplay;
1336
+ if (options.controls === void 0)
1337
+ options.controls = DEFAULT_OPTIONS.controls;
1338
+ if (options.fluid === void 0) options.fluid = DEFAULT_OPTIONS.fluid;
1339
+ if (options.muted === void 0) options.muted = DEFAULT_OPTIONS.muted;
1340
+ if (options.height === void 0) options.height = DEFAULT_OPTIONS.height;
1341
+ if (options.width === void 0) options.width = DEFAULT_OPTIONS.width;
1342
+ const [tracks, setTracks] = useState13([]);
1343
+ useEffect15(() => {
1344
+ const getTracks = async () => {
1345
+ const newTracks = [];
1346
+ for (const [i, s] of options.tracks.entries()) {
1347
+ let src = s.src;
1348
+ if (s.memeType == "text/srt") {
1349
+ src = await convertSRTtoVTT(s.src);
1350
+ }
1351
+ newTracks.push(__spreadProps(__spreadValues({}, s), {
1352
+ src
1353
+ }));
1354
+ }
1355
+ setTracks(newTracks);
1356
+ };
1357
+ getTracks();
1358
+ }, [options.tracks]);
1359
+ const id = (Date.now() + Math.random() * 100).toString();
1360
+ return /* @__PURE__ */ jsx35(
1361
+ VideoPlayerComponent_default,
1362
+ {
1363
+ id,
1364
+ chapters,
1365
+ options: __spreadProps(__spreadValues({}, options), { tracks }),
1366
+ notes,
1367
+ startTime,
1368
+ handleSaveNoteAction,
1369
+ onPause,
1370
+ onPlay
1371
+ }
1372
+ );
1373
+ };
1374
+ var SoftBuildersVideoPlayer = memo(Component, (prevProps, nextProps) => {
1375
+ return prevProps.options === nextProps.options && prevProps.notes === nextProps.notes && prevProps.chapters === nextProps.chapters && prevProps.startTime === nextProps.startTime;
1376
+ });
1377
+ var SoftBuildersVideoPlayer_default = SoftBuildersVideoPlayer;
1378
+
1379
+ // src/index.ts
1380
+ var src_default = SoftBuildersVideoPlayer_default;
1381
+ export {
1382
+ src_default as default
1383
+ };