60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
// Metro module 7854 (f7855).
|
|
import { setYear, isSameDay, differenceInDays, differenceInMonths } from "../../../../_bundle/Module3414";
|
|
export const FRIEND_ANNIVERSARY_ELIGIBILITY_WINDOW_DAYS = 7;
|
|
export function isFriendAnniversary(a0) {
|
|
const date = new Date();
|
|
const fullYear = date.getFullYear();
|
|
for (const item of [-1, 0, 1]) {
|
|
const r36 = setYear(a0, fullYear + item);
|
|
if (isSameDay(r36, a0)) {
|
|
continue;
|
|
}
|
|
if (!(Math.abs(differenceInDays(date, r36)) <= 7)) {
|
|
continue;
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
export function yearsSince(a0) {
|
|
return Math.round(differenceInMonths(new Date(), a0) / 12);
|
|
}
|
|
export function categorizeFriendAnniversariesByAffinity(a0, a1, a2) {
|
|
const set = new Set();
|
|
let c16043_0 = set;
|
|
const set2 = new Set();
|
|
let c16043_1 = set2;
|
|
if (a2) {
|
|
a0.slice(0, Math.ceil(a0.length / 2)).forEach((item) => {
|
|
c16043_0.add(item);
|
|
});
|
|
a0.forEach((item) => {
|
|
c16043_1.add(item);
|
|
});
|
|
} else {
|
|
for (const item of a0) {
|
|
const r39 = a1(item);
|
|
if (r39 != null && r39 > 0.7) {
|
|
set.add(item);
|
|
}
|
|
if (r39 != null && r39 > 0.5) {
|
|
set2.add(item);
|
|
}
|
|
}
|
|
}
|
|
return {
|
|
highestAffinity: set,
|
|
highAffinity: set2
|
|
};
|
|
}
|
|
export function pruneTimestampMap(a0, a1, a2) {
|
|
const r2 = {};
|
|
for (const key in a0) {
|
|
const r9 = a0[key];
|
|
if (a1 - r9 <= a2) {
|
|
r2[key] = r9;
|
|
}
|
|
}
|
|
return r2;
|
|
}
|