/* Metro module 8375; source: modules/content_inventory/utils.tsx; dependencies: [672, 21, 1244, 3738, 8376, 3381, 8370, 2] */ function _fun66657(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#66657, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:6, offset: 0x01c04b56, size: 625 bytes, params: 8, frame: 27 let env0_0 = require; const closure = function(a0, a1) { var env0_0 = a1; return a0.traits.find(_fun66659); }; const closure2 = isEntryActive; const closure3 = function(a0) { var r0; var Date; var expires_at; var value2; var value3; var value4; var value = a0.expires_at != null; if (value) { Date = global.Date; expires_at = a0.expires_at; value2 = new Date(); Date = global.Date; value3 = Object.create(Date.prototype, {constructor: {value: Date}}); value4 = new Date(); value2 = value2 < (value4 instanceof Object ? value4 : value3); r0 = value2; } else { r0 = value; } return r0; }; const closure4 = getEntryDuration; const closure5 = getStreakCount; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const closure6 = calculateTimestampDurations; const closure7 = calculateActiveTimestampDurations; const closure8 = formatActiveTimestamp; const closure9 = formatTimestampToA11yLabel; object = {secondsAgo: function(a0) { var intl = require(dependencyMap[2]).intl; var EOrEJl = require(dependencyMap[2]).t.EOrEJl; return intl.formatToPlainString(EOrEJl, {count: a0}); }, minutesAgo: function(a0) { var intl = require(dependencyMap[2]).intl; var LRNgHp = require(dependencyMap[2]).t.LRNgHp; return intl.formatToPlainString(LRNgHp, {count: a0}); }, hoursAgo: function(a0) { return require(dependencyMap[2]).intl.formatToPlainString(require(dependencyMap[2]).t.raJpz3, {count: a0}); }, daysAgo: function(a0) { var intl = require(dependencyMap[2]).intl; var KkvKhi = require(dependencyMap[2]).t.KkvKhi; return intl.formatToPlainString(KkvKhi, {count: a0}); }, weeksAgo: function(a0) { return require(dependencyMap[2]).intl.formatToPlainString(require(dependencyMap[2]).t.sDtO6D, {count: a0}); }, monthsAgo: function(a0) { var intl = require(dependencyMap[2]).intl; var ITymou = require(dependencyMap[2]).t.ITymou; return intl.formatToPlainString(ITymou, {count: a0}); }}; const closure10 = formatEndedTimestamp; (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/content_inventory/utils.tsx'); exports.calculateTimestampDurations = closure6; exports.calculateActiveTimestampDurations = closure7; exports.formatActiveTimestamp = closure8; exports.formatTimestampToA11yLabel = closure9; exports.formatActiveA11yTimestamp = function(a0, a1) { var value2 = calculateActiveTimestampDurations(a0, a1); return formatTimestampToA11yLabel({hours: value2.hours, minutes: value2.minutes, seconds: value2.seconds}); }; exports.A11Y_FORMAT_SET = {secondsAgo: function(a0) { return require(dependencyMap[2]).intl.formatToPlainString(require(dependencyMap[2]).t.jfUoRQ, {count: a0}); }, minutesAgo: function(a0) { var intl = require(dependencyMap[2]).intl; var DmvRVO = require(dependencyMap[2]).t.DmvRVO; return intl.formatToPlainString(DmvRVO, {count: a0}); }, hoursAgo: function(a0) { var intl = require(dependencyMap[2]).intl; var AfXezt = require(dependencyMap[2]).t.AfXezt; return intl.formatToPlainString(AfXezt, {count: a0}); }, daysAgo: function(a0) { var intl = require(dependencyMap[2]).intl; var Lru1rV = require(dependencyMap[2]).t.Lru1rV; return intl.formatToPlainString(Lru1rV, {count: a0}); }, weeksAgo: function(a0) { return require(dependencyMap[2]).intl.formatToPlainString(require(dependencyMap[2]).t['jovF+x'], {count: a0}); }, monthsAgo: function(a0) { return require(dependencyMap[2]).intl.formatToPlainString(require(dependencyMap[2]).t.nmSbST, {count: a0}); }}; exports.formatEndedTimestamp = closure10; exports.formatEntryTimestamp = formatEntryTimestamp; exports.getTrait = closure; exports.isEntryActive = closure2; exports.isEntryNew = isEntryNew; exports.isEntryRecent = isEntryRecent; exports.isEntryExpired = closure3; exports.isEntryLive = isEntryLive; exports.getEntryDuration = closure4; exports.getAggregateRange = getAggregateRange; exports.isEntryMarathon = isEntryMarathon; exports.getResurrectedEntryLastPlayTime = getResurrectedEntryLastPlayTime; exports.getFullResurrectedBadgeText = getFullResurrectedBadgeText; exports.getEpisodeBadgeText = getEpisodeBadgeText; exports.getRichGameStateBadgeText = getRichGameStateBadgeText; exports.isEntryTopGame = function({content_type}) { return content_type === require(dependencyMap[6]).ContentInventoryEntryType.TOP_GAME; }; exports.getStreakCount = closure5; exports.isValidStreak = isValidStreak; exports.getMarathonDescription = getMarathonDescription; exports.getTrendingType = getTrendingType; } function getTrait({traits}, a1) { // fn#66658, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:2759, offset: 0x01c04dc7, size: 38 bytes, params: 3, frame: 11 const env0_0 = a1; return traits.find(function({type}) { return type === require; }); } function isEntryActive(a0) { // fn#66660, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:2820, offset: 0x01c04ded, size: 79 bytes, params: 2, frame: 13 const getTraitBinding = getTrait; const value = undefined; const ContentInventoryTraitType = (require(8376) /* metro dependency 8376: ContentInventoryTraitType */).ContentInventoryTraitType; const IS_LIVE = ContentInventoryTraitType.IS_LIVE; const traitBinding = getTraitBinding(a0, IS_LIVE); const is_live = traitBinding == null ? value : traitBinding.is_live; return is_live != null && is_live; } function getEntryDuration(a0) { // fn#66662, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:3041, offset: 0x01c04e90, size: 67 bytes, params: 2, frame: 13 const getTraitBinding = getTrait; const value = undefined; const ContentInventoryTraitType = (require(8376) /* metro dependency 8376: ContentInventoryTraitType */).ContentInventoryTraitType; const DURATION_SECONDS = ContentInventoryTraitType.DURATION_SECONDS; const traitBinding = getTraitBinding(a0, DURATION_SECONDS); return traitBinding == null ? value : traitBinding.duration_seconds; } function getStreakCount(a0) { // fn#66663, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:3182, offset: 0x01c04ed3, size: 69 bytes, params: 2, frame: 13 const getTraitBinding = getTrait; const value = undefined; const ContentInventoryTraitType = (require(8376) /* metro dependency 8376: ContentInventoryTraitType */).ContentInventoryTraitType; const STREAK_DAYS = ContentInventoryTraitType.STREAK_DAYS; const traitBinding = getTraitBinding(a0, STREAK_DAYS); return traitBinding == null ? value : traitBinding.streak_count_days; } function calculateTimestampDurations(a0, a1) { // fn#66664, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:124, offset: 0x01c04f18, size: 286 bytes, params: 3, frame: 19 let Math = global.Math; let value = Math.max(a0 - a1, 0); const Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis; const SECOND = Millis.SECOND; value /= SECOND; const object2 = {}; Math = global.Math; let floor = Math.floor; const value3 = Reflect.apply(floor, Math, [value]); let Seconds = (importDefault(672) /* metro dependency 672: Durations */).Seconds; let MINUTE = Seconds.MINUTE; object2.seconds = value3 % MINUTE; Math = global.Math; floor = Math.floor; Seconds = (importDefault(672) /* metro dependency 672: Durations */).Seconds; MINUTE = Seconds.MINUTE; const value4 = Reflect.apply(floor, Math, [value / MINUTE]); Seconds = (importDefault(672) /* metro dependency 672: Durations */).Seconds; MINUTE = Seconds.MINUTE; object2.minutes = value4 % MINUTE; Math = global.Math; floor = Math.floor; Seconds = (importDefault(672) /* metro dependency 672: Durations */).Seconds; const HOUR = Seconds.HOUR; object2.hours = Reflect.apply(floor, Math, [value / HOUR]); Math = global.Math; floor = Math.floor; Seconds = (importDefault(672) /* metro dependency 672: Durations */).Seconds; const DAY = Seconds.DAY; object2.days = Reflect.apply(floor, Math, [value / DAY]); return object2; } function calculateActiveTimestampDurations(a0, a1) { // fn#66665, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:412, offset: 0x01c05036, size: 192 bytes, params: 3, frame: 18 var r5; var r4; var defaultImport; let value = a1; const end = 'end' in a0 ? a0.end : undefined; const r0 = 'isCountDown' in a0 && a0.isCountDown != null && a0.isCountDown; if (r0) { if (end == null) { if ('id' in a0) { defaultImport = importDefault(21) /* metro dependency 21: SnowflakeUtils */; r5 = defaultImport.extractTimestamp(a0.id); } else { r5 = a0.start; } if (end == null) { r4 = value; } else if (r0) { r4 = value; } else { value = global.Math.min(end, value); r4 = value; } value = environment; return calculateTimestampDurations(r4, r5); } if (end > value) { return calculateTimestampDurations(end, value); } if ('id' in a0) { defaultImport = importDefault(21) /* metro dependency 21: SnowflakeUtils */; r5 = defaultImport.extractTimestamp(a0.id); } else { r5 = a0.start; } if (end == null) { r4 = value; } else if (r0) { r4 = value; } else { value = global.Math.min(end, value); r4 = value; } value = environment; } else { if ('id' in a0) { defaultImport = importDefault(21) /* metro dependency 21: SnowflakeUtils */; r5 = defaultImport.extractTimestamp(a0.id); } else { r5 = a0.start; } if (end == null) { r4 = value; } else if (r0) { r4 = value; } else { value = global.Math.min(end, value); r4 = value; } } return calculateTimestampDurations(r4, r5); } function formatActiveTimestamp(a0, a1) { // fn#66666, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:710, offset: 0x01c050f6, size: 143 bytes, params: 3, frame: 20 const closure = function(a0) { return (0, global.String)(a0).padStart(2, '0'); }; let value = calculateActiveTimestampDurations(a0, a1); const seconds = value.seconds; const minutes = value.minutes; const hours = value.hours; const r5 = hours > 0 ? closure(minutes) : minutes; value = closure(seconds); return hours > 0 ? '' + hours + ':' + r5 + ':' + value : '' + r5 + ':' + value; } function formatTimestampToA11yLabel({hours, minutes, seconds}) { // fn#66668, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:960, offset: 0x01c051ae, size: 267 bytes, params: 2, frame: 21 const intl = (require(1244) /* metro dependency 1244: indexNative */).intl; const t = (require(1244) /* metro dependency 1244: indexNative */).t; const items2 = []; if (hours > 0) { items2.push(intl.formatToPlainString(t.xCjYxK, {hours: hours})); } items2.push(intl.formatToPlainString(t.iXLF9W, {minutes: minutes})); items2.push(intl.formatToPlainString(t.geSp4K, {seconds: seconds})); return items2.join(', '); } function formatEndedTimestamp({id}, a1, a2) { // fn#66681, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:2156, offset: 0x01c05631, size: 661 bytes, params: 4, frame: 19 const value = a3; const formatSet = (value !== undefined ? value : {}).formatSet; const r2 = formatSet !== undefined ? formatSet : env0_7; const value2 = (importDefault(3738) /* metro dependency 3738 */)(a2); const defaultImport2 = importDefault(3738) /* metro dependency 3738 */; const defaultImport3 = importDefault(21) /* metro dependency 21: SnowflakeUtils */; const value4 = value2.diff(defaultImport2(defaultImport3.extractTimestamp(id)), 's'); let Math = global.Math; const value5 = Math.abs(value4); let Seconds = (importDefault(672) /* metro dependency 672: Durations */).Seconds; const MINUTE = Seconds.MINUTE; if (value5 < MINUTE) { return r2.secondsAgo(value4); } Seconds = (importDefault(672) /* metro dependency 672: Durations */).Seconds; let HOUR = Seconds.HOUR; if (value5 < HOUR) { Math = global.Math; return r2.minutesAgo(Math.round(value4 / (importDefault(672) /* metro dependency 672: Durations */).Seconds.MINUTE)); } Seconds = (importDefault(672) /* metro dependency 672: Durations */).Seconds; HOUR = Seconds.HOUR; if (value5 < 12 * HOUR) { Math = global.Math; return r2.hoursAgo(Math.round(value4 / (importDefault(672) /* metro dependency 672: Durations */).Seconds.HOUR)); } Seconds = (importDefault(672) /* metro dependency 672: Durations */).Seconds; const DAY = Seconds.DAY; if (value5 < 9 * DAY) { Math = global.Math; return r2.daysAgo(Math.round(value4 / (importDefault(672) /* metro dependency 672: Durations */).Seconds.DAY)); } Seconds = (importDefault(672) /* metro dependency 672: Durations */).Seconds; const WEEK = Seconds.WEEK; if (value5 < 4 * WEEK) { Math = global.Math; return r2.weeksAgo(Math.round(value4 / (7 * (importDefault(672) /* metro dependency 672: Durations */).Seconds.DAY))); } Math = global.Math; const round = Math.round; Seconds = (importDefault(672) /* metro dependency 672: Durations */).Seconds; const DAYS_30 = Seconds.DAYS_30; return r2.monthsAgo(Reflect.apply(round, Math, [value4 / DAYS_30])); } function formatEntryTimestamp(a0, a1) { // fn#66683, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:3884, offset: 0x01c05909, size: 88 bytes, params: 3, frame: 18 const value = a2; const value2 = a3; const r3 = value !== undefined ? value : global.Date.now(); return isEntryActive(a0) ? formatActiveTimestamp(a0, r3) : formatEndedTimestamp(a0, 0, r3, value2 !== undefined ? value2 : {}); } function isEntryNew(a0) { // fn#66684, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:4046, offset: 0x01c05961, size: 79 bytes, params: 2, frame: 13 const getTraitBinding = getTrait; const value = undefined; const ContentInventoryTraitType = (require(8376) /* metro dependency 8376: ContentInventoryTraitType */).ContentInventoryTraitType; const FIRST_TIME = ContentInventoryTraitType.FIRST_TIME; const traitBinding = getTraitBinding(a0, FIRST_TIME); const first_time = traitBinding == null ? value : traitBinding.first_time; return first_time != null && first_time; } function isEntryRecent({id}) { // fn#66685, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:4201, offset: 0x01c059b0, size: 80 bytes, params: 2, frame: 14 let value = importDefault(21) /* metro dependency 21: SnowflakeUtils */; value = value.age(id); const Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis; const HOUR = Millis.HOUR; return value / HOUR < 48; } function isEntryLive(a0) { // fn#66686, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:4322, offset: 0x01c05a00, size: 34 bytes, params: 2, frame: 13 return isEntryActive(a0) && !isEntryExpired(a0); } function getAggregateRange(a0) { // fn#66687, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:4447, offset: 0x01c05a22, size: 67 bytes, params: 2, frame: 13 const getTraitBinding = getTrait; const value = undefined; const ContentInventoryTraitType = (require(8376) /* metro dependency 8376: ContentInventoryTraitType */).ContentInventoryTraitType; const AGGREGATE_RANGE = ContentInventoryTraitType.AGGREGATE_RANGE; const traitBinding = getTraitBinding(a0, AGGREGATE_RANGE); return traitBinding == null ? value : traitBinding.range; } function isEntryMarathon(a0) { // fn#66688, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:4596, offset: 0x01c05a65, size: 69 bytes, params: 2, frame: 13 const getTraitBinding = getTrait; const value = undefined; const ContentInventoryTraitType = (require(8376) /* metro dependency 8376: ContentInventoryTraitType */).ContentInventoryTraitType; const MARATHON = ContentInventoryTraitType.MARATHON; const traitBinding = getTraitBinding(a0, MARATHON); return traitBinding == null ? value : traitBinding.marathon; } function getResurrectedEntryLastPlayTime(a0) { // fn#66689, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:4755, offset: 0x01c05aaa, size: 112 bytes, params: 2, frame: 14 const getTraitBinding = getTrait; const value = undefined; const ContentInventoryTraitType = (require(8376) /* metro dependency 8376: ContentInventoryTraitType */).ContentInventoryTraitType; const RESURRECTED = ContentInventoryTraitType.RESURRECTED; const traitBinding = getTraitBinding(a0, RESURRECTED); return (traitBinding == null ? value : traitBinding.resurrected_last_played) != null ? new global.Date(traitBinding.resurrected_last_played) : value; } function getFullResurrectedBadgeText(a0) { // fn#66690, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:4993, offset: 0x01c05b1a, size: 234 bytes, params: 2, frame: 19 var object2; const moduleValue = require(3381) /* metro dependency 3381 */; const intervalToDuration = moduleValue.intervalToDuration; const Date = global.Date; const value2 = Object.create(Date.prototype, {constructor: {value: Date}}); const date = new Date(); const value4 = Reflect.apply(intervalToDuration, moduleValue, [{start: a0, end: date instanceof Object ? date : value2}]); const months = value4.months; const value5 = 0; let r4 = months === undefined ? value5 : months; const weeks = value4.weeks; const r6 = weeks === undefined ? value5 : weeks; const days = value4.days; const r5 = days === undefined ? value5 : days; const intl = (require(1244) /* metro dependency 1244: indexNative */).intl; const formatToPlainString = intl.formatToPlainString; const NXBtjF = (require(1244) /* metro dependency 1244: indexNative */).t.NXBtjF; object2 = {months: r4}; object2.weeks = r4 > value5 ? value5 : r6; r4 = r4 > value5 || r6 > value5 ? value5 : r5; object2.days = r4; return Reflect.apply(formatToPlainString, intl, [NXBtjF, object2]); } function getEpisodeBadgeText(a0) { // fn#66691, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:5295, offset: 0x01c05c04, size: 142 bytes, params: 2, frame: 18 var r1; var intl; const value = null; if (value == a0) { return value; } if (a0 === '') { return value; } const value2 = RegExp('\\w+ (\\d+), \\w+ (\\d+)', '').exec(a0); if (value == value2) { r1 = value; } else { intl = (require(1244) /* metro dependency 1244: indexNative */).intl; r1 = intl.formatToPlainString((require(1244) /* metro dependency 1244: indexNative */).t.ijVm6y, {seasonNum: value2[1], episodeNum: value2[2]}); } return r1; } function getRichGameStateBadgeText(a0, a1) { // fn#66692, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:5528, offset: 0x01c05c92, size: 333 bytes, params: 3, frame: 22 const intl = (require(1244) /* metro dependency 1244: indexNative */).intl; const t = (require(1244) /* metro dependency 1244: indexNative */).t; const value = a0; const value2 = undefined; const r8 = (a1 == null || a1.size == null ? value2 : a1.size[0]) ?? value2; const r7 = (a1 == null || a1.size == null ? value2 : a1.size[1]) ?? value2; const r5 = r8 == null || r7 == null ? r8 != null && r8 > 0 ? intl.formatToPlainString(t.UTYMsa, {count: r8}) : value2 : r8 > 0 && r7 > 0 ? intl.formatToPlainString(t.wmUSiy, {count: r8, max: r7}) : r8 != null && r8 > 0 ? intl.formatToPlainString(t.UTYMsa, {count: r8}) : value2; return r5 == null ? value ?? r5 : value != null ? '' + value + ' (' + r5 + ')' : value ?? r5; } function isValidStreak(a0) { // fn#66694, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:6086, offset: 0x01c05e13, size: 134 bytes, params: 2, frame: 14 var value; const streakCount = getStreakCount(a0); if (streakCount == null) { return false; } if (streakCount < 3) { return false; } value = Reflect.apply((importDefault(21) /* metro dependency 21: SnowflakeUtils */).extractTimestamp, value, [a0.id]); const Date = global.Date; value = Date.now() - value; const Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis; const HOUR = Millis.HOUR; return !(value > 48 * HOUR); } function getMarathonDescription(a0) { // fn#66695, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:6280, offset: 0x01c05e99, size: 250 bytes, params: 2, frame: 20 var r0; var object2; const intl = (require(1244) /* metro dependency 1244: indexNative */).intl; const t = (require(1244) /* metro dependency 1244: indexNative */).t; const entryDuration = getEntryDuration(a0); if (entryDuration == null) { return {'text': null, 'tooltipText': null}; } const Math = global.Math; const round = Math.round; const Seconds = (importDefault(672) /* metro dependency 672: Durations */).Seconds; const HOUR = Seconds.HOUR; const value3 = Reflect.apply(round, Math, [entryDuration / HOUR]); if (value3 <= 0) { r0 = {'text': null, 'tooltipText': null}; } else { object2 = {}; object2.text = intl.formatToPlainString(t.vZaMem, {hours: value3}); object2.tooltipText = intl.formatToPlainString(t.S5F485, {hours: value3}); r0 = object2; } return r0; } function getTrendingType(a0) { // fn#66696, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8560:6629, offset: 0x01c05f93, size: 69 bytes, params: 2, frame: 13 const getTraitBinding = getTrait; const value = undefined; const ContentInventoryTraitType = (require(8376) /* metro dependency 8376: ContentInventoryTraitType */).ContentInventoryTraitType; const TRENDING_CONTENT = ContentInventoryTraitType.TRENDING_CONTENT; const traitBinding = getTraitBinding(a0, TRENDING_CONTENT); return traitBinding == null ? value : traitBinding.trending; }