Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5014.js (118.4 MB)
206 lines
7.7 KiB
TypeScript
206 lines
7.7 KiB
TypeScript
// Module ID: 7922
|
|
// Function ID: 7923
|
|
// Name: FamilyCenterUtils
|
|
// Dependencies: [7867, 7868, 1115, 2486, 4416, 7869, 2]
|
|
// Exports: displayTypeFromString, formatLinkTimestamp, formatTotalTime, formatUserActivityTimestamp, getActivityTypeTextConfigs, getActivityWindowTimestampFormatter, getEmptyActivityFormatter, getFailureCodeForAPIError, getOrFetchLinkedUsers, getSortedActivityTypeConfigs, getTopUserOrGuildDescription, hasActiveParentLinks, isGift, isGuildAction, isParentallyControlled, isPurchase, isUserAction
|
|
|
|
// 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 */;
|
|
|
|
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);
|
|
let c10 = 86400;
|
|
let c11 = 172800;
|
|
const size = fn(2);
|
|
let result = size.fileFinishedImporting("modules/parent_tools/FamilyCenterUtils.tsx");
|
|
|
|
export const getEmptyActivityFormatter = function getEmptyActivityFormatter() {
|
|
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;
|
|
return obj;
|
|
};
|
|
export const getActivityWindowTimestampFormatter = function getActivityWindowTimestampFormatter(arg0) {
|
|
const obj = { today: null, yesterday: null, days: null };
|
|
const intl = util.intl;
|
|
const string = intl.string;
|
|
const tmp4 = _modDef2486;
|
|
if (arg0) {
|
|
obj.today = string(tmp4["2AtcIs"]);
|
|
const intl3 = tmp(1115).intl;
|
|
obj.yesterday = intl3.string(tmp3(2486).stOECr);
|
|
obj.days = tmp3(2486).n8n5Ba;
|
|
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;
|
|
tmp5 = obj;
|
|
}
|
|
return tmp5;
|
|
};
|
|
export const formatUserActivityTimestamp = function formatUserActivityTimestamp(time, timestampFormatter, arg2) {
|
|
const diffResult = _modDef4416().diff(_modDef4416(time), "s");
|
|
const tmp3 = timestampFormatter();
|
|
const obj = _modDef4416();
|
|
_modDef4416(time).format("LL");
|
|
if (diffResult < c10) {
|
|
let yesterday = tmp3.today;
|
|
} else if (diffResult < c11) {
|
|
yesterday = tmp3.yesterday;
|
|
} else {
|
|
let num = arg2;
|
|
const intl = util.intl;
|
|
const _Math = Math;
|
|
const rounded = Math.floor(diffResult / tmp5);
|
|
if (arg2 == null) {
|
|
num = 999;
|
|
}
|
|
const obj3 = { days: Math.min(rounded, num) };
|
|
yesterday = intl.formatToPlainString(tmp3.days, obj3);
|
|
}
|
|
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);
|
|
if (diffResult < 60) {
|
|
let yesterday = time.seconds;
|
|
} else if (diffResult < 3600) {
|
|
const intl4 = util.intl;
|
|
const obj2 = { count: null };
|
|
const _Math3 = Math;
|
|
obj2.count = Math.floor(diffResult / 60);
|
|
yesterday = intl4.formatToPlainString(time.minutes, obj2);
|
|
} else if (diffResult < c10) {
|
|
const intl3 = util.intl;
|
|
const obj3 = { count: null };
|
|
const _Math2 = Math;
|
|
obj3.count = Math.floor(diffResult / 3600);
|
|
yesterday = intl3.formatToPlainString(time.hours, obj3);
|
|
} else if (diffResult < c11) {
|
|
yesterday = time.yesterday;
|
|
} else if (diffResult < 604800) {
|
|
const intl2 = util.intl;
|
|
const obj4 = { count: null };
|
|
const _Math = Math;
|
|
obj4.count = Math.floor(diffResult / tmp12);
|
|
yesterday = intl2.formatToPlainString(time.days, obj4);
|
|
} else {
|
|
const intl = util.intl;
|
|
const obj5 = { date: tmp4 };
|
|
yesterday = intl.formatToPlainString(time.date, obj5);
|
|
}
|
|
return yesterday;
|
|
};
|
|
export const isUserAction = function isUserAction(action) {
|
|
return action.display_type === constants2.USER_ADD || action.display_type === constants2.USER_INTERACTION || action.display_type === constants2.USER_CALLED;
|
|
};
|
|
export const isGuildAction = function isGuildAction(action) {
|
|
return action.display_type === constants2.GUILD_ADD || action.display_type === tmp.GUILD_INTERACTION;
|
|
};
|
|
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);
|
|
for (const item10011 of values) {
|
|
if (item10011.toString() === arg0) {
|
|
obj.return();
|
|
return item10011;
|
|
}
|
|
}
|
|
};
|
|
export const getFailureCodeForAPIError = function getFailureCodeForAPIError(arg0) {
|
|
let GENERIC_ERROR = hasOwnProperty[arg0.code];
|
|
if (GENERIC_ERROR == null) {
|
|
GENERIC_ERROR = constants.GENERIC_ERROR;
|
|
}
|
|
return GENERIC_ERROR;
|
|
};
|
|
export const getSortedActivityTypeConfigs = function getSortedActivityTypeConfigs() {
|
|
const map = new Map(React4);
|
|
if (0 === map.size) {
|
|
let items = [];
|
|
} else {
|
|
const _Array = Array;
|
|
items = Array.from(map.entries()).sort((arg0, arg1) => arg0[1].priority - arg1[1].priority);
|
|
const arr = Array.from(map.entries());
|
|
}
|
|
return items;
|
|
};
|
|
export const getActivityTypeTextConfigs = function getActivityTypeTextConfigs() {
|
|
return new Map(React4);
|
|
};
|
|
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()) {
|
|
return obj.getLinkedUsers();
|
|
} else {
|
|
const linkedUsers = FamilyCenterActionCreatorsDefault.fetchLinkedUsers();
|
|
}
|
|
obj = FamilyCenterStore;
|
|
};
|
|
export const hasActiveParentLinks = function hasActiveParentLinks() {
|
|
const values = Object.values(FamilyCenterStore.getLinkedUsers());
|
|
return values.some((link_status) => {
|
|
let tmp = link_status.link_status === constants.ACTIVE;
|
|
if (tmp) {
|
|
tmp = link_status.link_type === constants2.PARENT;
|
|
}
|
|
return tmp;
|
|
});
|
|
};
|
|
export const isParentallyControlled = function isParentallyControlled() {
|
|
const values = Object.values(FamilyCenterStore.getLinkedUsers());
|
|
return values.some((link_status) => {
|
|
let tmp = link_status.link_status === constants.ACTIVE;
|
|
if (tmp) {
|
|
tmp = link_status.link_type === constants2.PARENT;
|
|
}
|
|
return tmp;
|
|
});
|
|
};
|
|
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);
|
|
}
|
|
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);
|
|
}
|
|
}
|
|
const intl = util.intl;
|
|
formatToPlainStringResult = intl.formatToPlainString(_modDef2486.IYqGMG, { messageCount: dms_sent, callCount: call_count });
|
|
};
|