165 lines
5.2 KiB
TypeScript
165 lines
5.2 KiB
TypeScript
// Metro module 4724 (f4725).
|
|
import _slicedToArray from "../../_bundle/_slicedToArray";
|
|
import { CLIPS_MAX_PARTICIPANTS, CLIPS_MAX_TIMELINE_EVENTS } from "./ClipsConstants";
|
|
import { AnalyticEvents } from "../../Constants";
|
|
import { SpeakingFlags } from "../../_bundle/Module4250";
|
|
import * as _GameEventsOnPlayerExperiment from "./GameEventsOnPlayerExperiment";
|
|
import { ClipSignalTypes, GameEventType } from "./ClipsTypes";
|
|
import AnalyticsUtils from "../../utils/AnalyticsUtils";
|
|
import { getClipsRuntime } from "./ClipsV3RuntimeExperiment";
|
|
let c2882_8 = {
|
|
UNKNOWN: 0,
|
|
0: "UNKNOWN",
|
|
KILL: 1,
|
|
1: "KILL",
|
|
MULTIKILL: 2,
|
|
2: "MULTIKILL",
|
|
DEATH: 3,
|
|
3: "DEATH"
|
|
};
|
|
export function getClipCreatedAt(a0) {
|
|
return new Date(a0).toISOString();
|
|
}
|
|
export function getClipParticipantIds(a0) {
|
|
return a0.slice(0, CLIPS_MAX_PARTICIPANTS);
|
|
}
|
|
export { c2882_8 as ServerClipGameEventType };
|
|
export function getClipEventsTimeline(a0) {
|
|
let isGameEventsOnPlayerEnabled;
|
|
let r2 = a0.timeline?.length;
|
|
if (r2 == null) {
|
|
r2 = 0;
|
|
}
|
|
if (r2 !== 0) {
|
|
if (a0.decision?.timestamp != null) {
|
|
let editMetadata = a0.editMetadata;
|
|
if (editMetadata == null) {
|
|
editMetadata = {
|
|
start: 0,
|
|
end: a0.length / 1000
|
|
};
|
|
}
|
|
const r52 = a0.decision.timestamp - a0.length;
|
|
const r15 = r52 + 1000 * editMetadata.start;
|
|
const r14 = r52 + 1000 * editMetadata.end;
|
|
isGameEventsOnPlayerEnabled = _GameEventsOnPlayerExperiment.isGameEventsOnPlayerEnabled("getClipEventsTimeline");
|
|
const r70 = a0.timeline.filter((item) => {
|
|
let r12 = a0.editMetadata?.voiceAudio !== false && item.signal.type === ClipSignalTypes.SPEAKING;
|
|
if (!r12) {
|
|
let r19 = isGameEventsOnPlayerEnabled;
|
|
if (isGameEventsOnPlayerEnabled) {
|
|
r19 = item.signal.type === ClipSignalTypes.GAME_EVENT;
|
|
}
|
|
r12 = r19;
|
|
}
|
|
return r12;
|
|
}).sort((a, b) => a.timestamp - b.timestamp);
|
|
if (r70.length !== 0) {
|
|
const map = new Map();
|
|
const r11 = [];
|
|
const map2 = new Map();
|
|
for (const item of r70) {
|
|
L18: {
|
|
if (item.signal.type !== ClipSignalTypes.SPEAKING) {
|
|
continue;
|
|
}
|
|
if (item.timestamp >= r15) {
|
|
break L18;
|
|
}
|
|
map.set(item.signal.userId, (item.signal.speakingFlags & SpeakingFlags.VOICE) === SpeakingFlags.VOICE);
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
for (const item2 of map) {
|
|
const r118 = _slicedToArray(item2, 2);
|
|
const user_id = r118[0];
|
|
if (r118[1]) {
|
|
r11.push({
|
|
timestamp_ms: 0,
|
|
speaking: {
|
|
user_id,
|
|
speaking_flags: SpeakingFlags.VOICE
|
|
}
|
|
});
|
|
}
|
|
}
|
|
for (const item3 of r70) {
|
|
if (item3.signal.type === ClipSignalTypes.SPEAKING) {
|
|
if (item3.timestamp < r15) {
|
|
continue;
|
|
}
|
|
if (item3.timestamp > r14) {
|
|
break;
|
|
}
|
|
const r216 = (item3.signal.speakingFlags & SpeakingFlags.VOICE) === SpeakingFlags.VOICE;
|
|
let r220 = map.get(item3.signal.userId);
|
|
if (r220 == null) {
|
|
r220 = false;
|
|
}
|
|
if (r220 === r216) {
|
|
continue;
|
|
}
|
|
map.set(item3.signal.userId, r216);
|
|
r11.push({
|
|
timestamp_ms: Math.round(item3.timestamp - r15),
|
|
speaking: {
|
|
user_id: item3.signal.userId,
|
|
speaking_flags: item3.signal.speakingFlags
|
|
}
|
|
});
|
|
continue;
|
|
}
|
|
if (item3.signal.type !== ClipSignalTypes.GAME_EVENT) {
|
|
continue;
|
|
}
|
|
if (item3.timestamp < r15) {
|
|
continue;
|
|
}
|
|
if (!(item3.timestamp > r14)) {
|
|
let type = void 0;
|
|
const eventType = item3.signal.eventType;
|
|
if (GameEventType.KILL === eventType) {
|
|
type = c2882_8.KILL;
|
|
} else if (GameEventType.MULTIKILL === eventType) {
|
|
type = c2882_8.MULTIKILL;
|
|
}
|
|
if (type == null) {
|
|
continue;
|
|
}
|
|
const r183 = Math.round(item3.timestamp - r15);
|
|
const r186 = map2.get(r183);
|
|
if (r186 != null) {
|
|
if (type !== c2882_8.MULTIKILL) {
|
|
continue;
|
|
}
|
|
r11[r186].game = {
|
|
type
|
|
};
|
|
continue;
|
|
}
|
|
map2.set(r183, r11.length);
|
|
r11.push({
|
|
timestamp_ms: r183,
|
|
game: {
|
|
type
|
|
}
|
|
});
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
const r245 = r11.slice(0, CLIPS_MAX_TIMELINE_EVENTS);
|
|
if (r245.length !== r11.length) {
|
|
AnalyticsUtils.track(AnalyticEvents.CLIP_TIMELINE_TRIMMED, {
|
|
clip_uuid: a0.id,
|
|
clip_event_timeline_size: r11.length,
|
|
clip_runtime: getClipsRuntime("getClipEventsTimeline")
|
|
});
|
|
}
|
|
return r245.length > 0 ? r245 : void 0;
|
|
}
|
|
}
|
|
}
|
|
}
|