// Module ID: 15414 // Function ID: 15415 // Name: useVideoSegmentAnalytics // Dependencies: [32, 19, 7394, 2] // Exports: default // Module 15414 (useVideoSegmentAnalytics) import DiscordVideoPlayerTypes from "DiscordVideoPlayerTypes" /* 7394 */; import _slicedToArray from "_slicedToArray" /* 32 */; import "react"; import react from "react" /* 19 */; import size from "module_2" /* 2 */; let closure_4; let hasOwnProperty; let metroRequire; ({ useRef: closure_4, useCallback: hasOwnProperty, useEffect: metroRequire } = react); const result = size.fileFinishedImporting("modules/video_player/useVideoSegmentAnalytics.tsx"); export default function useVideoSegmentAnalytics(getCurrentVideoTime) { getCurrentVideoTime = getCurrentVideoTime.getCurrentVideoTime; const onAnalytics = getCurrentVideoTime.onAnalytics; const emitIntervalMs = getCurrentVideoTime.emitIntervalMs; const minSegmentDurationMs = getCurrentVideoTime.minSegmentDurationMs; let tmp = emitIntervalMs(minSegmentDurationMs.useState(null), 2); const first = tmp[0]; let closure_5 = tmp[1]; let tmp3 = emitIntervalMs(minSegmentDurationMs.useState(false), 2); const first1 = tmp3[0]; let closure_7 = tmp3[1]; const tmp5 = emitIntervalMs(minSegmentDurationMs.useState(false), 2); const first2 = tmp5[0]; let closure_9 = tmp5[1]; const tmp7 = emitIntervalMs(minSegmentDurationMs.useState(false), 2); const first3 = tmp7[0]; let closure_11 = tmp7[1]; const ref = first(null); const ref2 = first(Date.now()); const ref3 = first(false); const items = [onAnalytics]; const tmp9 = closure_5((segmentEndSec) => { if (segmentEndSec.segmentEndSec >= segmentEndSec.segmentStartSec) { const obj = { start_time: null, end_time: null, duration: segmentEndSec.endTimeMs - segmentEndSec.startTimeMs, segment_start_sec: null, segment_end_sec: null, segment_duration_sec: segmentEndSec.segmentEndSec - segmentEndSec.segmentStartSec }; ({ startTimeMs: obj.start_time, endTimeMs: obj.end_time } = segmentEndSec); ({ segmentStartSec: obj.segment_start_sec, segmentEndSec: obj.segment_end_sec } = segmentEndSec); onAnalytics(obj); } }, items); let closure_15 = tmp9; const items1 = [getCurrentVideoTime, first2, first3]; const tmp10 = closure_5(() => { const tmp = getCurrentVideoTime(); if (null != tmp) { const tmp2 = first2; if (tmp2) { const tmp3 = first3; if (tmp3) { const _Date = Date; const timestamp = Date.now(); const obj = { startTimeMs: timestamp, endTimeMs: timestamp, segmentStartSec: tmp, segmentEndSec: tmp }; closure_5(obj); ref3.current = true; } } } }, items1); let closure_16 = tmp10; const items2 = [first, tmp9, emitIntervalMs, minSegmentDurationMs, getCurrentVideoTime]; const tmp11 = closure_5(() => { const tmp = getCurrentVideoTime(); if (null != tmp) { if (null != first) { const _Date = Date; const timestamp = Date.now(); let tmp3 = timestamp - ref2.current < emitIntervalMs; const tmp14 = ref2; if (!tmp3) { tmp3 = tmp - tmp11.segmentStartSec < minSegmentDurationMs / 1000; } if (!tmp3) { const obj = { endTimeMs: timestamp, segmentEndSec: tmp }; const merged = Object.assign(tmp11); closure_15(obj); const obj2 = { startTimeMs: timestamp, endTimeMs: timestamp, segmentStartSec: tmp, segmentEndSec: tmp }; closure_5(obj2); tmp14.current = timestamp; } } } }, items2); let closure_17 = tmp11; const items3 = [first2, first3]; first1(() => { const tmp = first2 && first3; if (!tmp) { closure_5(null); ref3.current = false; } }, items3); const items4 = [first1, first2, first3, first, tmp11, tmp9, tmp10, getCurrentVideoTime]; first1(() => { const tmp = first1; if (tmp) { const tmp2 = first2; if (tmp2) { const tmp3 = first3; if (tmp3) { if (!ref3.current) { closure_16(); } const _window = window; ref.current = window.setInterval(() => { closure_1_17(); }, 200); } return () => { if (null != ref.current) { const _clearInterval = clearInterval; clearInterval(ref.current); ref.current = null; } }; } } const tmp4 = getCurrentVideoTime(); if (null != first) { if (null != tmp4) { const _Date = Date; if (tmp4 - first.segmentStartSec > 0.2) { const obj = { endTimeMs: tmp7, segmentEndSec: tmp4 }; const merged = Object.assign(tmp5); closure_15(obj); } } } closure_5(null); ref3.current = false; if (null != ref.current) { let _clearInterval = clearInterval; clearInterval(tmp14.current); ref.current = null; } }, items4); const items5 = [first, tmp9, getCurrentVideoTime]; let tmp14 = closure_5(() => { const tmp = getCurrentVideoTime(); if (null != first) { if (null != tmp) { const _Date = Date; if (tmp - first.segmentStartSec > 0.2) { const obj = { endTimeMs: tmp4, segmentEndSec: tmp }; const merged = Object.assign(tmp2); closure_15(obj); } closure_5(null); ref3.current = false; } } }, items5); const tmp15 = first(tmp14); const ref4 = tmp15; tmp15.current = tmp14; let obj = { handlePlayerStateChange: closure_5((arg0) => { if (DiscordVideoPlayerTypes.VideoPlayerState.PLAYING === arg0) { closure_7(true); } else if (DiscordVideoPlayerTypes.VideoPlayerState.PAUSED === arg0) { ref4.current(); closure_7(false); } }, []), handleLoadEnd: closure_5(() => { closure_9(true); }, []), handleFirstFrame: closure_5(() => { closure_11(true); }, []), handleSeek: closure_5(() => { ref4.current(); }, []) }; return obj; }; export const SEGMENT_ANALYTICS_EMIT_INTERVAL_MS = 4000; export const SEGMENT_ANALYTICS_MIN_DURATION_MS = 2000;