/* Metro module 7149; source: modules/polls/PollsUtils.tsx; dependencies: [1379, 7150, 4814, 3784, 3793, 7217, 661, 491, 566, 5225, 672, 1862, 4634, 1244, 7152, 22, 4617, 2] */ function _fun57179(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#57179, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:6, offset: 0x013de7bf, size: 490 bytes, params: 8, frame: 24 let env0_0 = require; const _arrayLikeToArray_57182 = function(a0, a1) { var r0; var r1; var r2; var value3; var length; var value5; var value = undefined; var value2 = value == null; reducibleJoin2: while (true) { if (value2) { r0 = value2; break reducibleJoin2; } value3 = value > a0.length; r0 = value3; break reducibleJoin2; } reducibleJoin4: while (true) { if (r0) { length = a0.length; r1 = length; break reducibleJoin4; } r1 = value; break reducibleJoin4; } value = (0, global.Array)(r1); var value4 = 0; if (value4 < r1) { r2 = value4; reducibleLoop5: while (true) { value[r2] = a0[r2]; value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1; if (value5 < r1) { r2 = value5; continue reducibleLoop5; } break reducibleLoop5; } } return value; }; const closure = generateLocalCreationAnswerId; const closure2 = function({text}) { var r1; r1 = text?.trim(); return r1 != null && r1.length > 0; }; const closure3 = function(a0) { var Date = global.Date; var Date2 = global.Date; var value = Date2.now(); var HOUR = importDefault(dependencyMap[10]).Millis.HOUR; value += a0 * HOUR; value = new Date(value); return value.toISOString(); }; const closure4 = getSampleOfVoterUsernamesForAnswer; const closure5 = formatVoterTooltipText; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const channelStore = importDefault(1379) /* metro dependency 1379: ChannelStore */; const messageReactionsStore = importDefault(7150) /* metro dependency 7150: MessageReactionsStore */; const messageStore = importDefault(4814) /* metro dependency 4814: MessageStore */; const permissionStore = importDefault(3784) /* metro dependency 3784: PermissionStore */; const relationshipStore = importDefault(3793) /* metro dependency 3793: RelationshipStore */; let value = require(7217) /* metro dependency 7217: PollsConstants */; const env0_8 = value.POLL_RESULT_MESSAGE_POLL_TITLE_MAX_VISIBLE_CHARS; const env0_9 = value.VOTES_TOOLTIP_MAX_USERS; value = require(661) /* metro dependency 661: Constants */; const env0_10 = value.ChannelTypesSets; const env0_11 = value.Permissions; (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/polls/PollsUtils.tsx'); exports.generateEmptyPollAnswer = function() { var object = {text: undefined, image: undefined}; object.localCreationAnswerId = generateLocalCreationAnswerId(); return object; }; exports.generateLocalCreationAnswerId = closure; exports.filterOutUUID = function(a0) { return a0.replace(RegExp('\\b[a-f\\d]{8}-(?:[a-f\\d]{4}-){3}[a-f\\d]{12}-\\b', 'i'), ''); }; exports.hasNonVoteReactions = hasNonVoteReactions; exports.useCanPostPollsInChannel = function(a0) { var env0_0 = a0; return require(dependencyMap[8]).useStateFromStores([PermissionStore], _fun57196); }; exports.isPollCreationEmpty = function(a0, a1) { var r0; var value = a0.length === 0; if (value) { value = a1.find(_fun57198); value = value == null; r0 = value; } else { r0 = value; } return r0; }; exports.isAnswerFilled = closure2; exports.isIncompleteAnswer = function(a0) { var r2; r2 = a0.text?.trim(); return a0.image != null && (r2 == null || r2.length === 0); }; exports.createPollExpiryTimestamp = closure3; exports.createPollServerDataFromCreateRequest = createPollServerDataFromCreateRequest; exports.getPollReplyPreview = function({poll}) { return (poll == null || poll.question == null ? undefined : poll.question.text) ?? ''; }; exports.getPollResultsReplyPreview = getPollResultsReplyPreview; exports.getPollResultsReplyPreviewMobile = getPollResultsReplyPreviewMobile; exports.getTotalVotes = function(a0) { return a0.reduce(_fun57206, 0); }; exports.getSampleOfVoterUsernamesForAnswer = closure4; exports.formatVoterTooltipText = closure5; exports.getPollAnswerVotesTooltipText = getPollAnswerVotesTooltipText; exports.formatPollResultNotificationCenterText = formatPollResultNotificationCenterText; } function _createForOfIteratorHelperLoose_57180(a0, a1) { // fn#57180, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:290, offset: 0x013de9a9, size: 370 bytes, params: 3, frame: 20 var r6; var r9; var r5; var value3; var regexp; const env0_0 = a0; const Symbol = global.Symbol; let value = typeof Symbol !== 'undefined'; let r1 = value && a0[global.Symbol.iterator]; r1 = !r1 ? a0['@@iterator'] : r1; if (r1) { value = r1.call(a0); return value.next.bind(value); } const Array = global.Array; if (Array.isArray(a0)) { if (r1) { } return _fun57181; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_57182(a0, value); r5 = value; } else { value3 = ({}).toString.call(a0).slice(8, -1); r6 = value3 === 'Object' && a0.constructor; r9 = r6 ? a0.constructor.name : value3; if (r9 === 'Map') { r6 = global.Array.from(a0); } else if (r9 === 'Set') { r6 = global.Array.from(a0); } else if (r9 === 'Arguments') { value = _arrayLikeToArray_57182(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_57182(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun57181; } const TypeError = global.TypeError; throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); } function generateLocalCreationAnswerId() { // fn#57183, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:1200, offset: 0x013deb1b, size: 37 bytes, params: 1, frame: 11 return (require(491) /* metro dependency 491 */).v4(); } function getPollResultsPollName({embeds}, a1) { // fn#57186, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:1460, offset: 0x013debd8, size: 137 bytes, params: 3, frame: 16 var rawValue; var r0; var fields; var value2; const property = embeds[0]; let value = undefined; if (property == null) { rawValue = value; } else { fields = property.fields; if (fields == null) { rawValue = value; } else { value2 = fields.find(function(a0) { return a0.rawName === 'poll_question_text'; }); rawValue = value2 == null ? value : value2.rawValue; } } const r3 = rawValue ?? ''; if (a1 == null) { r0 = r3; } else { value = require(1862) /* metro dependency 1862: StringUtils */; value = value.truncateText(r3, a1); r0 = value; } return r0; } function getSampleOfVoterUsernamesForAnswer(a0, a1) { // fn#57188, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:1684, offset: 0x013dec76, size: 291 bytes, params: 3, frame: 23 var r2; let value = a0.getChannelId(); const getReactions = MessageReactionsStore.getReactions; const id = a0.id; const value3 = undefined; const ReactionTypes = (require(7152) /* metro dependency 7152: MessageReactionsTypes */).ReactionTypes; const VOTE = ReactionTypes.VOTE; const value4 = Reflect.apply(getReactions, MessageReactionsStore, [value, id, {'id': null, 'name': '', 'animated': false, id: a1}, VOTES_TOOLTIP_MAX_USERS, VOTE]); value = ChannelStore.getChannel(value); const value5 = null; if (value5 == value) { r2 = value5; } else if (value.isPrivate()) { r2 = value5; } else { value = value.getGuildId(); r2 = value; } value = importDefault(22) /* metro dependency 22 */; const Array = global.Array; const from = Array.from; r2 = value5 == value4 ? value3 : value4.values(); r2 = value5 == r2 ? [] : r2; value = value(Reflect.apply(from, Array, [r2])); value = value.reject(function(a0) { return RelationshipStore.isBlockedOrIgnored(a0.id); }); value = value.take(VOTES_TOOLTIP_MAX_USERS); value = value.map(_fun57190); return value.value(); } function formatVoterTooltipText(a0, a1) { // fn#57191, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:2082, offset: 0x013dedfd, size: 625 bytes, params: 3, frame: 22 const intl = (require(1244) /* metro dependency 1244: indexNative */).intl; const t = (require(1244) /* metro dependency 1244: indexNative */).t; const Math = global.Math; const value = Math.max(0, a1 - a0.length); return a0.length === 1 ? value > 0 ? intl.formatToPlainString(t['SV/iZn'], {a: a0[0], n: value}) : a0[0] : a0.length === 2 ? value > 0 ? intl.formatToPlainString(t.YBnZK0, {a: a0[0], b: a0[1], n: value}) : intl.formatToPlainString(t['O5+f5c'], {a: a0[0], b: a0[1]}) : a0.length === 3 ? value > 0 ? intl.formatToPlainString(t['ThXp+N'], {a: a0[0], b: a0[1], c: a0[2], n: value}) : intl.formatToPlainString(t['0UzBM3'], {a: a0[0], b: a0[1], c: a0[2]}) : intl.formatToPlainString(t.yVX6kE, {n: value}); } function hasNonVoteReactions({reactions}) { // fn#57194, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:3072, offset: 0x013df0af, size: 77 bytes, params: 2, frame: 14 var value3; var me_vote; var value4; const value = _createForOfIteratorHelperLoose_57180(reactions); const value2 = value(); let done = value2.done; if (done) { return false; } let r1 = value2; loopExit1: while (true) { value3 = r1.value; me_vote = value3.me_vote; if (me_vote == null) { break loopExit1; } value4 = value(); done = value4.done; if (done) { return false; } r1 = value4; continue; } return true; } function useCanPostPollsInChannel(a0) { // fn#57195, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:3249, offset: 0x013df0fc, size: 64 bytes, params: 2, frame: 14 const env0_0 = a0; return (require(566) /* metro dependency 566: flux */).useStateFromStores([PermissionStore], _fun57196); } function isPollCreationEmpty({length}, a1) { // fn#57197, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:3510, offset: 0x013df208, size: 46 bytes, params: 3, frame: 12 var r0; let value = length === 0; if (value) { value = a1.find(function(a0) { return isAnswerFilled(a0); }); value = value == null; r0 = value; } else { r0 = value; } return r0; } function createPollServerDataFromCreateRequest(a0) { // fn#57200, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:3873, offset: 0x013df277, size: 132 bytes, params: 2, frame: 16 var r6; var r2; var r3; var value; var answers; var object2; if (a0 != null) { value = undefined; if (a0 == null) { r2 = value; } else { answers = a0.answers; if (answers == null) { r2 = value; r6 = answers; } else { r2 = answers.map(_fun57201); r6 = answers; } } r3 = (a0 == null ? value : a0.duration) != null ? createPollExpiryTimestamp(a0.duration) : '0'; object2 = {}; copyDataProperties(object2, a0, r6); object2['expiry'] = r3; object2['answers'] = r2; return object2; } } function getPollResultsReplyPreview(a0) { // fn#57203, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:4448, offset: 0x013df3bd, size: 120 bytes, params: 2, frame: 17 const messageAuthor = (require(4634) /* metro dependency 4634: useMessageAuthor */).getMessageAuthor(a0); const pollResultsPollName = getPollResultsPollName(a0, POLL_RESULT_MESSAGE_POLL_TITLE_MAX_VISIBLE_CHARS); const intl = (require(1244) /* metro dependency 1244: indexNative */).intl; const format = intl.format; const Vn97Ka = (require(1244) /* metro dependency 1244: indexNative */).t.Vn97Ka; return Reflect.apply(format, intl, [Vn97Ka, {username: messageAuthor.nick, title: pollResultsPollName}]); } function getPollResultsReplyPreviewMobile(a0) { // fn#57204, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:4665, offset: 0x013df435, size: 136 bytes, params: 2, frame: 17 var pollResultsPollName; var messageAuthor; var intl; if ('author' in a0) { messageAuthor = (require(4634) /* metro dependency 4634: useMessageAuthor */).getMessageAuthor(a0); pollResultsPollName = getPollResultsPollName(a0, POLL_RESULT_MESSAGE_POLL_TITLE_MAX_VISIBLE_CHARS); intl = (require(1244) /* metro dependency 1244: indexNative */).intl; return intl.formatToParts((require(1244) /* metro dependency 1244: indexNative */).t.Vn97Ka, {username: messageAuthor.nick, title: pollResultsPollName}); } return null; } function getTotalVotes(a0) { // fn#57205, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:4907, offset: 0x013df4bd, size: 26 bytes, params: 2, frame: 13 return a0.reduce(function(a0, {count_details}) { return a0 + (count_details?.vote ?? 0); }, 0); } function getPollAnswerVotesTooltipText(a0, a1, a2) { // fn#57207, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:5192, offset: 0x013df506, size: 154 bytes, params: 4, frame: 18 const message = MessageStore.getMessage(a1, a0); if (message == null) { return ''; } const value3 = ''; const reaction = message.getReaction({'id': null, 'name': '', 'animated': false, id: a2}); const vote = reaction == null || reaction.count_details == null ? undefined : reaction.count_details.vote; const value6 = 0; const r3 = vote ?? value6; const sampleOfVoterUsernamesForAnswer = getSampleOfVoterUsernamesForAnswer(message, a2); return value6 === sampleOfVoterUsernamesForAnswer.length ? value3 : formatVoterTooltipText(sampleOfVoterUsernamesForAnswer, r3); } function formatPollResultNotificationCenterText(a0) { // fn#57208, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:5535, offset: 0x013df5a0, size: 377 bytes, params: 2, frame: 19 const intl = (require(1244) /* metro dependency 1244: indexNative */).intl; const t = (require(1244) /* metro dependency 1244: indexNative */).t; const questionText = a0.questionText; const victorAnswerText = a0.victorAnswerText; const victorAnswerVotes = a0.victorAnswerVotes; const victorAnswerId = a0.victorAnswerId; const totalVotes = a0.totalVotes; const totalVotes2 = a0.totalVotes; const value = 0; const r9 = totalVotes2 > value ? global.Math.round(victorAnswerVotes / totalVotes * 100) : value; return value === totalVotes ? intl.formatToPlainString(t['8anM0l'], {questionText: questionText}) : victorAnswerId != null ? intl.formatToPlainString(t['8yEgvE'], {questionText: questionText, victorAnswerText: victorAnswerText, percentage: '' + r9 + '%'}) : intl.formatToPlainString(t.XVk6Zv, {questionText: questionText, percentage: '' + r9 + '%'}); } function _fun57190(a0) { // fn#57190, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:2027, offset: 0x013dedb5, size: 72 bytes, params: 2, frame: 17 const value = environment.__proto__; return (importDefault(4617) /* metro dependency 4617: NicknameUtils */).getName(env0_1, env0_0?.id, a0); } function _fun57196() { // fn#57196, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:3326, offset: 0x013df13c, size: 204 bytes, params: 1, frame: 18 var r1; var value5; var POLLS; var value6; var isPrivate2; let r0 = env0_0 != null && env0_0.id !== (require(5225) /* metro dependency 5225: FakePlaceholderPrivateChannel */).FAKE_PLACEHOLDER_PRIVATE_CHANNEL_ID; if (r0) { value5 = environment.__proto__; POLLS = ChannelTypesSets.POLLS; value6 = POLLS.has(env0_0.type); if (value6) { isPrivate2 = env0_0.isPrivate(); r1 = isPrivate2 ? !!isPrivate2 : PermissionStore.can(Permissions.SEND_MESSAGES, env0_0) && PermissionStore.can(Permissions.SEND_POLLS, env0_0); } else { r1 = !!value6; } r0 = r1; } return r0; } function _fun57201(a0, a1) { // fn#57201, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7327:3990, offset: 0x013df2fb, size: 138 bytes, params: 3, frame: 16 var r6; var r3; var name; const poll_media = a0.poll_media; let value = undefined; const emoji = poll_media == null ? value : poll_media.emoji; const object2 = {}; copyDataProperties(object2, a0.poll_media, r6); if (emoji != null) { name = emoji.name; value = name != null; r3 = {id: emoji.id, name: value ? name : ''}; r6 = value; } else { r3 = value; } object2['emoji'] = r3; const object4 = {}; copyDataProperties(object4, a0, r6); object4['answer_id'] = a1 + 1; object4['poll_media'] = object2; return object4; }