340 lines
11 KiB
TypeScript
340 lines
11 KiB
TypeScript
// Metro module 7914 (f7915).
|
|
import Durations from "../../utils/Durations";
|
|
import SnowflakeUtils from "../../utils/SnowflakeUtils";
|
|
import { intl, t } from "../../intl/index.native";
|
|
import Module3771 from "../../_bundle/Module3771";
|
|
import { ContentInventoryTraitType } from "../../_bundle/Module7915";
|
|
import { intervalToDuration } from "../../_bundle/Module3414";
|
|
import { ContentInventoryEntryType } from "../../_bundle/Module7909";
|
|
function $mk79518($env) {
|
|
return (a0) => a0.type === $env[0];
|
|
}
|
|
let formatActiveTimestamp, formatTimestampToA11yLabel, c5003_6, formatEndedTimestamp;
|
|
const calculateTimestampDurations = function calculateTimestampDurations(a0, a1) {
|
|
const r18 = Math.max(a0 - a1, 0) / Durations.Millis.SECOND;
|
|
return {
|
|
seconds: Math.floor(r18) % Durations.Seconds.MINUTE,
|
|
minutes: Math.floor(r18 / Durations.Seconds.MINUTE) % Durations.Seconds.MINUTE,
|
|
hours: Math.floor(r18 / Durations.Seconds.HOUR),
|
|
days: Math.floor(r18 / Durations.Seconds.DAY)
|
|
};
|
|
};
|
|
formatActiveTimestamp = function formatActiveTimestamp(entry, now) {
|
|
let r35;
|
|
const r7 = "end" in entry ? entry.end : void 0;
|
|
const r10 = "isCountDown" in entry && entry.isCountDown != null && entry.isCountDown;
|
|
if (r10 && (r7 != null && r7 > now)) {
|
|
r35 = calculateTimestampDurations(r7, now);
|
|
} else {
|
|
const r9 = "id" in entry ? SnowflakeUtils.extractTimestamp(entry.id) : entry.start;
|
|
r35 = calculateTimestampDurations(r7 != null ? r10 ? now : Math.min(r7, now) : now, r9);
|
|
}
|
|
const { seconds, minutes, hours } = r35;
|
|
const r40 = hours > 0 ? String(minutes).padStart(2, "0") : minutes;
|
|
const r52 = String(seconds).padStart(2, "0");
|
|
return hours > 0 ? `${hours}:${r40}:${r52}` : `${r40}:${r52}`;
|
|
};
|
|
formatTimestampToA11yLabel = function formatTimestampToA11yLabel({ hours, minutes, seconds }) {
|
|
const r4 = [];
|
|
if (hours > 0) {
|
|
r4.push(intl.formatToPlainString(t.xCjYxK, {
|
|
hours
|
|
}));
|
|
}
|
|
r4.push(intl.formatToPlainString(t.iXLF9W, {
|
|
minutes
|
|
}));
|
|
r4.push(intl.formatToPlainString(t.geSp4K, {
|
|
seconds
|
|
}));
|
|
return r4.join(", ");
|
|
};
|
|
formatEndedTimestamp = function formatEndedTimestamp(entry2, stateFromStores, a2, r3 = {}) {
|
|
let formatSet = r3.formatSet;
|
|
if (formatSet === void 0) {
|
|
formatSet = c5003_6;
|
|
}
|
|
const r22 = Module3771(a2).diff(Module3771(SnowflakeUtils.extractTimestamp(entry2.id)), "s");
|
|
const r26 = Math.abs(r22);
|
|
if (r26 < Durations.Seconds.MINUTE) {
|
|
return formatSet.secondsAgo(r22);
|
|
}
|
|
if (r26 < Durations.Seconds.HOUR) {
|
|
return formatSet.minutesAgo(Math.round(r22 / Durations.Seconds.MINUTE));
|
|
}
|
|
if (r26 < 12 * Durations.Seconds.HOUR) {
|
|
return formatSet.hoursAgo(Math.round(r22 / Durations.Seconds.HOUR));
|
|
}
|
|
if (r26 < 9 * Durations.Seconds.DAY) {
|
|
return formatSet.daysAgo(Math.round(r22 / Durations.Seconds.DAY));
|
|
}
|
|
if (r26 < 4 * Durations.Seconds.WEEK) {
|
|
return formatSet.weeksAgo(Math.round(r22 / (7 * Durations.Seconds.DAY)));
|
|
}
|
|
return formatSet.monthsAgo(Math.round(r22 / Durations.Seconds.DAYS_30));
|
|
};
|
|
c5003_6 = {
|
|
secondsAgo: (a0) => intl.formatToPlainString(t.EOrEJl, {
|
|
count: a0
|
|
}),
|
|
minutesAgo: (a0) => intl.formatToPlainString(t.LRNgHp, {
|
|
count: a0
|
|
}),
|
|
hoursAgo: (a0) => intl.formatToPlainString(t.raJpz3, {
|
|
count: a0
|
|
}),
|
|
daysAgo: (a0) => intl.formatToPlainString(t.KkvKhi, {
|
|
count: a0
|
|
}),
|
|
weeksAgo: (a0) => intl.formatToPlainString(t.sDtO6D, {
|
|
count: a0
|
|
}),
|
|
monthsAgo: (a0) => intl.formatToPlainString(t.ITymou, {
|
|
count: a0
|
|
})
|
|
};
|
|
const r24 = {
|
|
secondsAgo: (a0) => intl.formatToPlainString(t.jfUoRQ, {
|
|
count: a0
|
|
}),
|
|
minutesAgo: (a0) => intl.formatToPlainString(t.DmvRVO, {
|
|
count: a0
|
|
}),
|
|
hoursAgo: (a0) => intl.formatToPlainString(t.AfXezt, {
|
|
count: a0
|
|
}),
|
|
daysAgo: (a0) => intl.formatToPlainString(t.Lru1rV, {
|
|
count: a0
|
|
}),
|
|
weeksAgo: (a0) => intl.formatToPlainString(t["jovF+x"], {
|
|
count: a0
|
|
}),
|
|
monthsAgo: (a0) => intl.formatToPlainString(t.nmSbST, {
|
|
count: a0
|
|
})
|
|
};
|
|
export { calculateTimestampDurations };
|
|
export function calculateActiveTimestampDurations(a0, a1) {
|
|
const r4 = "end" in a0 ? a0.end : void 0;
|
|
const r8 = "isCountDown" in a0 && a0.isCountDown != null && a0.isCountDown;
|
|
if (r8 && r4 != null && r4 > a1) {
|
|
return calculateTimestampDurations(r4, a1);
|
|
}
|
|
const r7 = "id" in a0 ? SnowflakeUtils.extractTimestamp(a0.id) : a0.start;
|
|
return calculateTimestampDurations(r4 != null ? r8 ? a1 : Math.min(r4, a1) : a1, r7);
|
|
}
|
|
export { formatActiveTimestamp };
|
|
export { formatTimestampToA11yLabel };
|
|
export function formatActiveA11yTimestamp(a0, a1) {
|
|
let r27;
|
|
const r5 = "end" in a0 ? a0.end : void 0;
|
|
const r8 = "isCountDown" in a0 && a0.isCountDown != null && a0.isCountDown;
|
|
if (r8 && (r5 != null && r5 > a1)) {
|
|
r27 = calculateTimestampDurations(r5, a1);
|
|
} else {
|
|
const r7 = "id" in a0 ? SnowflakeUtils.extractTimestamp(a0.id) : a0.start;
|
|
r27 = calculateTimestampDurations(r5 != null ? r8 ? a1 : Math.min(r5, a1) : a1, r7);
|
|
}
|
|
return formatTimestampToA11yLabel({
|
|
hours: r27.hours,
|
|
minutes: r27.minutes,
|
|
seconds: r27.seconds
|
|
});
|
|
}
|
|
export { r24 as A11Y_FORMAT_SET };
|
|
export { formatEndedTimestamp };
|
|
export function formatEntryTimestamp(a0, a1, r7 = Date.now(), r8 = {}) {
|
|
let env16097;
|
|
const IS_LIVE = ContentInventoryTraitType.IS_LIVE;
|
|
const r23 = env16097 = {};
|
|
env16097[0] = IS_LIVE;
|
|
let r27 = a0.traits.find($mk79518(r23))?.is_live;
|
|
if (r27 == null) {
|
|
r27 = false;
|
|
}
|
|
return r27 ? formatActiveTimestamp(a0, r7) : formatEndedTimestamp(a0, 0, r7, r8);
|
|
}
|
|
export function getTrait(a0, a1) {
|
|
let env16093;
|
|
const r0 = env16093 = {};
|
|
env16093[0] = a1;
|
|
return a0.traits.find($mk79518(r0));
|
|
}
|
|
export function isEntryActive(a0) {
|
|
let env16094;
|
|
const IS_LIVE = ContentInventoryTraitType.IS_LIVE;
|
|
const r11 = env16094 = {};
|
|
env16094[0] = IS_LIVE;
|
|
let r16 = a0.traits.find($mk79518(r11))?.is_live;
|
|
if (r16 == null) {
|
|
r16 = false;
|
|
}
|
|
return r16;
|
|
}
|
|
export function isEntryNew(a0) {
|
|
let env16098;
|
|
const FIRST_TIME = ContentInventoryTraitType.FIRST_TIME;
|
|
const r11 = env16098 = {};
|
|
env16098[0] = FIRST_TIME;
|
|
let r16 = a0.traits.find($mk79518(r11))?.first_time;
|
|
if (r16 == null) {
|
|
r16 = false;
|
|
}
|
|
return r16;
|
|
}
|
|
export function isEntryRecent(a0) {
|
|
return SnowflakeUtils.age(a0.id) / Durations.Millis.HOUR < 48;
|
|
}
|
|
export function isEntryExpired(a0) {
|
|
return a0.expires_at != null && new Date(a0.expires_at) < new Date();
|
|
}
|
|
export function isEntryLive(a0) {
|
|
let env16099;
|
|
const IS_LIVE = ContentInventoryTraitType.IS_LIVE;
|
|
const r15 = env16099 = {};
|
|
env16099[0] = IS_LIVE;
|
|
let r19 = a0.traits.find($mk79518(r15))?.is_live;
|
|
if (r19 == null) {
|
|
r19 = false;
|
|
}
|
|
if (r19) {
|
|
r19 = !(a0.expires_at != null && new Date(a0.expires_at) < new Date());
|
|
}
|
|
return r19;
|
|
}
|
|
export function getEntryDuration(a0) {
|
|
let env16095;
|
|
const DURATION_SECONDS = ContentInventoryTraitType.DURATION_SECONDS;
|
|
const r10 = env16095 = {};
|
|
env16095[0] = DURATION_SECONDS;
|
|
return a0.traits.find($mk79518(r10))?.duration_seconds;
|
|
}
|
|
export function getAggregateRange(a0) {
|
|
let env16100;
|
|
const AGGREGATE_RANGE = ContentInventoryTraitType.AGGREGATE_RANGE;
|
|
const r10 = env16100 = {};
|
|
env16100[0] = AGGREGATE_RANGE;
|
|
return a0.traits.find($mk79518(r10))?.range;
|
|
}
|
|
export function isEntryMarathon(a0) {
|
|
let env16101;
|
|
const MARATHON = ContentInventoryTraitType.MARATHON;
|
|
const r10 = env16101 = {};
|
|
env16101[0] = MARATHON;
|
|
return a0.traits.find($mk79518(r10))?.marathon;
|
|
}
|
|
export function getResurrectedEntryLastPlayTime(a0) {
|
|
let env16102;
|
|
const RESURRECTED = ContentInventoryTraitType.RESURRECTED;
|
|
const r14 = env16102 = {};
|
|
env16102[0] = RESURRECTED;
|
|
const r18 = a0.traits.find($mk79518(r14));
|
|
return r18?.resurrected_last_played != null ? new Date(r18.resurrected_last_played) : void 0;
|
|
}
|
|
export function getFullResurrectedBadgeText(a0) {
|
|
const r19 = intervalToDuration({
|
|
start: a0,
|
|
end: new Date()
|
|
});
|
|
const { months: months2 = 0, weeks = 0, days = 0 } = r19;
|
|
return intl.formatToPlainString(t.NXBtjF, {
|
|
months: months2,
|
|
weeks: months2 > 0 ? 0 : weeks,
|
|
days: months2 > 0 ? 0 : weeks > 0 ? 0 : days
|
|
});
|
|
}
|
|
export function getEpisodeBadgeText(a0) {
|
|
if (a0 != null && a0 !== "") {
|
|
const r7 = /\w+ (\d+), \w+ (\d+)/.exec(a0);
|
|
return r7 == null ? null : intl.formatToPlainString(t.ijVm6y, {
|
|
seasonNum: r7[1],
|
|
episodeNum: r7[2]
|
|
});
|
|
}
|
|
return null;
|
|
}
|
|
export function getRichGameStateBadgeText(a0, a1) {
|
|
const r1 = a1 == null;
|
|
let count = void 0;
|
|
if (!r1) {
|
|
const size = a1.size;
|
|
count = size == null ? void 0 : size[0];
|
|
}
|
|
if (count == null) {
|
|
count = void 0;
|
|
}
|
|
const r19 = a1 == null;
|
|
let max = void 0;
|
|
if (!r19) {
|
|
const size2 = a1.size;
|
|
max = size2 == null ? void 0 : size2[1];
|
|
}
|
|
if (max == null) {
|
|
max = void 0;
|
|
}
|
|
const r11 = count != null && (max != null && (count > 0 && max > 0)) ? intl.formatToPlainString(t.wmUSiy, {
|
|
count,
|
|
max
|
|
}) : count != null && count > 0 ? intl.formatToPlainString(t.UTYMsa, {
|
|
count
|
|
}) : void 0;
|
|
return r11 != null && a0 != null ? `${a0} (${r11})` : a0 == null ? r11 : a0;
|
|
}
|
|
export function isEntryTopGame(a0) {
|
|
return a0.content_type === ContentInventoryEntryType.TOP_GAME;
|
|
}
|
|
export function getStreakCount(a0) {
|
|
let env16096;
|
|
const STREAK_DAYS = ContentInventoryTraitType.STREAK_DAYS;
|
|
const r10 = env16096 = {};
|
|
env16096[0] = STREAK_DAYS;
|
|
return a0.traits.find($mk79518(r10))?.streak_count_days;
|
|
}
|
|
export function isValidStreak(a0) {
|
|
let env16103;
|
|
const STREAK_DAYS = ContentInventoryTraitType.STREAK_DAYS;
|
|
const r13 = env16103 = {};
|
|
env16103[0] = STREAK_DAYS;
|
|
const streak_count_days = a0.traits.find($mk79518(r13))?.streak_count_days;
|
|
if (streak_count_days == null) {
|
|
return false;
|
|
}
|
|
if (streak_count_days < 3) {
|
|
return false;
|
|
}
|
|
const r23 = SnowflakeUtils.extractTimestamp(a0.id);
|
|
return !(Date.now() - r23 > 48 * Durations.Millis.HOUR);
|
|
}
|
|
export function getMarathonDescription(a0) {
|
|
let env16104;
|
|
const DURATION_SECONDS = ContentInventoryTraitType.DURATION_SECONDS;
|
|
const r14 = env16104 = {};
|
|
env16104[0] = DURATION_SECONDS;
|
|
const duration_seconds = a0.traits.find($mk79518(r14))?.duration_seconds;
|
|
if (duration_seconds == null) {
|
|
return {
|
|
text: null,
|
|
tooltipText: null
|
|
};
|
|
}
|
|
const hours = Math.round(duration_seconds / Durations.Seconds.HOUR);
|
|
return hours <= 0 ? {
|
|
text: null,
|
|
tooltipText: null
|
|
} : {
|
|
text: intl.formatToPlainString(t.vZaMem, {
|
|
hours
|
|
}),
|
|
tooltipText: intl.formatToPlainString(t.S5F485, {
|
|
hours
|
|
})
|
|
};
|
|
}
|
|
export function getTrendingType(a0) {
|
|
let env16105;
|
|
const TRENDING_CONTENT = ContentInventoryTraitType.TRENDING_CONTENT;
|
|
const r10 = env16105 = {};
|
|
env16105[0] = TRENDING_CONTENT;
|
|
return a0.traits.find($mk79518(r10))?.trending;
|
|
}
|