decord/alpha/source/modules/parent_tools/FamilyCenterUtils.tsx

207 lines
7.7 KiB
TypeScript
Raw Normal View History

// Module ID: 7922
// Function ID: 7923
// Name: FamilyCenterUtils
// Dependencies: [7867, 7868, 1115, 2486, 4416, 7869, 2]
2026-07-29 08:29:29 +00:00
// Exports: displayTypeFromString, formatLinkTimestamp, formatTotalTime, formatUserActivityTimestamp, getActivityTypeTextConfigs, getActivityWindowTimestampFormatter, getEmptyActivityFormatter, getFailureCodeForAPIError, getOrFetchLinkedUsers, getSortedActivityTypeConfigs, getTopUserOrGuildDescription, hasActiveParentLinks, isGift, isGuildAction, isParentallyControlled, isPurchase, isUserAction
2026-07-20 16:05:17 +00:00
// Module 7922 (FamilyCenterUtils)
import util from "util" /* 1115 */;
import _modDef2486 from "module_2486" /* 2486 */;
import _modDef4416 from "module_4416" /* 4416 */;
import FamilyCenterActionCreatorsDefault from "FamilyCenterActionCreators" /* 7869 */;
import FamilyCenterStore from "FamilyCenterStore" /* 7867 */;
2026-07-23 10:11:24 +00:00
require = fn;
const FamilyCenterConstants = fn(7868);
({ ACTION_TO_TEXT: closure_4, FAMILY_CENTER_ERROR_CODE_TO_FAILURE: hasOwnProperty, FamilyCenterFailureCode: metroRequire, TeenActionDisplayType: closure_7, UserLinkStatus: closure_8, UserLinkType: closure_9 } = FamilyCenterConstants);
2026-07-29 08:29:29 +00:00
let c10 = 86400;
let c11 = 172800;
const size = fn(2);
let result = size.fileFinishedImporting("modules/parent_tools/FamilyCenterUtils.tsx");
2026-07-20 16:05:17 +00:00
export const getEmptyActivityFormatter = function getEmptyActivityFormatter() {
2026-07-29 08:29:29 +00:00
const obj = { today: null, yesterday: null, days: null };
const intl = util.intl;
obj.today = intl.string(_modDef2486.VjIAQQ);
const intl2 = util.intl;
obj.yesterday = intl2.string(_modDef2486["2a8xHY"]);
obj.days = _modDef2486.Xt6oND;
2026-07-20 16:05:17 +00:00
return obj;
};
export const getActivityWindowTimestampFormatter = function getActivityWindowTimestampFormatter(arg0) {
2026-07-29 08:29:29 +00:00
const obj = { today: null, yesterday: null, days: null };
const intl = util.intl;
2026-07-20 16:05:17 +00:00
const string = intl.string;
const tmp4 = _modDef2486;
2026-07-20 16:05:17 +00:00
if (arg0) {
obj.today = string(tmp4["2AtcIs"]);
const intl3 = tmp(1115).intl;
obj.yesterday = intl3.string(tmp3(2486).stOECr);
obj.days = tmp3(2486).n8n5Ba;
2026-07-20 16:05:17 +00:00
let tmp5 = obj;
} else {
obj.today = string(tmp4.g1ZX6m);
const intl2 = tmp(1115).intl;
obj.yesterday = intl2.string(tmp3(2486).s3qSVt);
obj.days = tmp3(2486).f1UJiC;
2026-07-20 16:05:17 +00:00
tmp5 = obj;
}
return tmp5;
};
export const formatUserActivityTimestamp = function formatUserActivityTimestamp(time, timestampFormatter, arg2) {
const diffResult = _modDef4416().diff(_modDef4416(time), "s");
2026-07-29 08:29:29 +00:00
const tmp3 = timestampFormatter();
const obj = _modDef4416();
_modDef4416(time).format("LL");
2026-07-29 08:29:29 +00:00
if (diffResult < c10) {
let yesterday = tmp3.today;
} else if (diffResult < c11) {
yesterday = tmp3.yesterday;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
let num = arg2;
const intl = util.intl;
2026-07-20 16:05:17 +00:00
const _Math = Math;
2026-07-29 08:29:29 +00:00
const rounded = Math.floor(diffResult / tmp5);
if (arg2 == null) {
num = 999;
2026-07-20 16:05:17 +00:00
}
const obj3 = { days: Math.min(rounded, num) };
yesterday = intl.formatToPlainString(tmp3.days, obj3);
2026-07-20 16:05:17 +00:00
}
return yesterday;
};
export const formatLinkTimestamp = function formatLinkTimestamp(arg0, SENT_TIMESTAMP_FORMATTER) {
const diffResult = _modDef4416().diff(_modDef4416(arg0), "s");
const time = SENT_TIMESTAMP_FORMATTER();
_modDef4416(arg0);
2026-07-20 16:05:17 +00:00
if (diffResult < 60) {
let yesterday = time.seconds;
2026-07-20 16:05:17 +00:00
} else if (diffResult < 3600) {
const intl4 = util.intl;
const obj2 = { count: null };
2026-07-20 16:05:17 +00:00
const _Math3 = Math;
obj2.count = Math.floor(diffResult / 60);
yesterday = intl4.formatToPlainString(time.minutes, obj2);
2026-07-29 08:29:29 +00:00
} else if (diffResult < c10) {
const intl3 = util.intl;
const obj3 = { count: null };
2026-07-20 16:05:17 +00:00
const _Math2 = Math;
obj3.count = Math.floor(diffResult / 3600);
yesterday = intl3.formatToPlainString(time.hours, obj3);
2026-07-29 08:29:29 +00:00
} else if (diffResult < c11) {
yesterday = time.yesterday;
2026-07-20 16:05:17 +00:00
} else if (diffResult < 604800) {
const intl2 = util.intl;
const obj4 = { count: null };
2026-07-20 16:05:17 +00:00
const _Math = Math;
obj4.count = Math.floor(diffResult / tmp12);
yesterday = intl2.formatToPlainString(time.days, obj4);
2026-07-20 16:05:17 +00:00
} else {
const intl = util.intl;
const obj5 = { date: tmp4 };
yesterday = intl.formatToPlainString(time.date, obj5);
2026-07-20 16:05:17 +00:00
}
return yesterday;
};
export const isUserAction = function isUserAction(action) {
2026-07-29 08:29:29 +00:00
return action.display_type === constants2.USER_ADD || action.display_type === constants2.USER_INTERACTION || action.display_type === constants2.USER_CALLED;
2026-07-20 16:05:17 +00:00
};
export const isGuildAction = function isGuildAction(action) {
2026-07-29 08:29:29 +00:00
return action.display_type === constants2.GUILD_ADD || action.display_type === tmp.GUILD_INTERACTION;
2026-07-20 16:05:17 +00:00
};
export const isPurchase = function isPurchase(action) {
return action.display_type === constants2.PURCHASES;
};
export const isGift = function isGift(action) {
return action.display_type === constants2.GIFTS;
};
export const displayTypeFromString = function displayTypeFromString(arg0) {
const values = Object.values(constants2);
2026-07-29 08:29:29 +00:00
for (const item10011 of values) {
if (item10011.toString() === arg0) {
obj.return();
return item10011;
2026-07-20 16:05:17 +00:00
}
}
};
export const getFailureCodeForAPIError = function getFailureCodeForAPIError(arg0) {
let GENERIC_ERROR = hasOwnProperty[arg0.code];
2026-07-29 08:29:29 +00:00
if (GENERIC_ERROR == null) {
2026-07-20 16:05:17 +00:00
GENERIC_ERROR = constants.GENERIC_ERROR;
}
return GENERIC_ERROR;
};
export const getSortedActivityTypeConfigs = function getSortedActivityTypeConfigs() {
const map = new Map(React4);
2026-07-29 08:29:29 +00:00
if (0 === map.size) {
2026-07-20 16:05:17 +00:00
let items = [];
} else {
const _Array = Array;
2026-07-29 08:29:29 +00:00
items = Array.from(map.entries()).sort((arg0, arg1) => arg0[1].priority - arg1[1].priority);
const arr = Array.from(map.entries());
2026-07-20 16:05:17 +00:00
}
return items;
};
2026-07-29 08:29:29 +00:00
export const getActivityTypeTextConfigs = function getActivityTypeTextConfigs() {
return new Map(React4);
2026-07-29 08:29:29 +00:00
};
2026-07-20 16:05:17 +00:00
export const formatTotalTime = function formatTotalTime(arg0) {
const rounded = Math.floor(arg0 / 60);
const result = arg0 % 60;
if (rounded > 0) {
const _HermesInternal2 = HermesInternal;
let combined = "" + rounded + "h " + result + "m";
} else {
const _HermesInternal = HermesInternal;
combined = "" + result + "m";
}
return combined;
};
export const getOrFetchLinkedUsers = function getOrFetchLinkedUsers() {
if (FamilyCenterStore.getAreLinkedUsersProcessed()) {
2026-07-29 08:29:29 +00:00
return obj.getLinkedUsers();
2026-07-20 16:05:17 +00:00
} else {
const linkedUsers = FamilyCenterActionCreatorsDefault.fetchLinkedUsers();
2026-07-20 16:05:17 +00:00
}
obj = FamilyCenterStore;
2026-07-29 08:29:29 +00:00
};
export const hasActiveParentLinks = function hasActiveParentLinks() {
const values = Object.values(FamilyCenterStore.getLinkedUsers());
2026-07-29 08:29:29 +00:00
return values.some((link_status) => {
let tmp = link_status.link_status === constants.ACTIVE;
if (tmp) {
tmp = link_status.link_type === constants2.PARENT;
}
return tmp;
});
2026-07-20 16:05:17 +00:00
};
export const isParentallyControlled = function isParentallyControlled() {
const values = Object.values(FamilyCenterStore.getLinkedUsers());
2026-07-29 08:29:29 +00:00
return values.some((link_status) => {
let tmp = link_status.link_status === constants.ACTIVE;
if (tmp) {
tmp = link_status.link_type === constants2.PARENT;
}
return tmp;
});
2026-07-20 16:05:17 +00:00
};
export const getTopUserOrGuildDescription = function getTopUserOrGuildDescription(dms_sent, call_count) {
if (call_count > 0) {
if (0 === dms_sent) {
const intl3 = util.intl;
const obj2 = { callCount: call_count };
let formatToPlainStringResult = intl3.formatToPlainString(_modDef2486["L/Cj7S"], obj2);
2026-07-20 16:05:17 +00:00
}
return formatToPlainStringResult;
}
if (dms_sent > 0) {
if (0 === call_count) {
const intl2 = util.intl;
const obj3 = { messageCount: dms_sent };
formatToPlainStringResult = intl2.formatToPlainString(_modDef2486["6X1F0i"], obj3);
2026-07-20 16:05:17 +00:00
}
}
const intl = util.intl;
formatToPlainStringResult = intl.formatToPlainString(_modDef2486.IYqGMG, { messageCount: dms_sent, callCount: call_count });
2026-07-20 16:05:17 +00:00
};