decord/source/modules/user_profile/hooks/useActivityTimer.tsx

72 lines
2.9 KiB
TypeScript
Raw Normal View History

2026-09-02 09:53:35 +00:00
// Module ID: 9435
// Function ID: 9436
2026-07-29 08:29:29 +00:00
// Name: useActivityTimer
2026-09-02 09:53:35 +00:00
// Dependencies: [32, 19, 684, 8053, 4362, 2]
2026-07-20 16:05:17 +00:00
// Exports: default, formatTime, formatTimeForA11yLabel
2026-09-02 09:53:35 +00:00
// Module 9435 (useActivityTimer)
import setDefault from "set" /* 684 */;
import calculateTimestampDurations from "calculateTimestampDurations" /* 8053 */;
2026-08-24 06:08:38 +00:00
import closure_3 from "_slicedToArray" /* 32 */;
import noop from "noop" /* 19 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-29 08:29:29 +00:00
({ useEffect: c4, useState: c5 } = noop);
let result = require("set").fileFinishedImporting("modules/user_profile/hooks/useActivityTimer.tsx");
2026-07-20 16:05:17 +00:00
export default function useActivityTimer(start) {
start = start.start;
2026-07-29 08:29:29 +00:00
let first;
2026-08-24 06:08:38 +00:00
importDefault = undefined;
2026-09-01 10:26:29 +00:00
const interval = new first(4362).Interval();
2026-07-23 10:11:24 +00:00
first = callback(callback3(interval), 1)[0];
2026-07-20 16:05:17 +00:00
const tmp3 = callback(callback3(() => Date.now()), 2);
2026-07-29 08:29:29 +00:00
importDefault = tmp3[1];
2026-07-20 16:05:17 +00:00
const items = [first];
callback2(() => {
2026-08-24 06:08:38 +00:00
first.start(callback(closure_1_2[2]).Millis.HALF_SECOND, () => callback(Date.now()));
2026-07-29 08:29:29 +00:00
return () => closure_0.stop();
2026-07-20 16:05:17 +00:00
}, items);
const diff = start.end - start;
2026-08-24 06:08:38 +00:00
const result = diff / setDefault.Millis.SECOND;
2026-07-20 16:05:17 +00:00
const diff1 = tmp3[0] - start;
2026-08-24 06:08:38 +00:00
const bound = Math.max(Math.min(diff1 / setDefault.Millis.SECOND, result), 0);
2026-07-20 16:05:17 +00:00
return { elapsed: bound, duration: result, percentage: Math.max(Math.min(bound / result, 1), 0) };
};
export const formatTime = function formatTime(arg0) {
2026-07-29 08:29:29 +00:00
const rounded = Math.floor(arg0);
2026-08-24 06:08:38 +00:00
const result = rounded % setDefault.Seconds.MINUTE;
const rounded1 = Math.floor(arg0 / setDefault.Seconds.MINUTE);
const result1 = rounded1 % setDefault.Seconds.MINUTE;
const rounded2 = Math.floor(arg0 / setDefault.Seconds.HOUR);
2026-07-29 08:29:29 +00:00
if (0 === rounded2) {
const _String4 = String;
const _String5 = String;
const StringResult = String(result1);
const padStartResult = String(result1).padStart(2, "0");
2026-07-20 16:05:17 +00:00
const _HermesInternal2 = HermesInternal;
2026-07-29 08:29:29 +00:00
let combined = "" + padStartResult + ":" + String(result).padStart(2, "0");
const StringResult1 = String(result);
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
const _String = String;
const padStartResult1 = String(rounded2).padStart(2, "0");
const _String2 = String;
const StringResult2 = String(rounded2);
const _String3 = String;
const StringResult3 = String(result1);
const padStartResult2 = String(result1).padStart(2, "0");
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
2026-07-29 08:29:29 +00:00
combined = "" + padStartResult1 + ":" + padStartResult2 + ":" + String(result).padStart(2, "0");
const StringResult4 = String(result);
2026-07-20 16:05:17 +00:00
}
return combined;
};
export const formatTimeForA11yLabel = function formatTimeForA11yLabel(arg0) {
2026-07-29 08:29:29 +00:00
const rounded = Math.floor(arg0);
2026-08-24 06:08:38 +00:00
const seconds = rounded % setDefault.Seconds.MINUTE;
const rounded1 = Math.floor(arg0 / setDefault.Seconds.MINUTE);
const minutes = rounded1 % setDefault.Seconds.MINUTE;
const hours = Math.floor(arg0 / setDefault.Seconds.HOUR);
return calculateTimestampDurations.formatTimestampToA11yLabel({ hours, minutes, seconds });
2026-07-20 16:05:17 +00:00
};