/* Metro module 1936; source: modules/channel/GatedChannelStore.tsx; dependencies: [6, 7, 15, 17, 18, 1937, 1383, 1939, 1379, 1945, 1938, 1867, 1878, 661, 3775, 3776, 3777, 566, 694, 2] */ import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */ import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */ import PossibleConstructorReturn from '../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */ import Module00017 from '../../by-id/module-00017.js'; /* Metro dependency 17 */ import Inherits from '../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */ import Flux from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */ import ChannelStore from '../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */ import GuildStore from '../../stores/GuildStore.tsx'; /* Metro dependency 1867 */ import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */ import ImpersonateStore from '../impersonate/ImpersonateStore.tsx'; /* Metro dependency 1937 */ import GuildRoleStore from '../../stores/GuildRoleStore.tsx'; /* Metro dependency 1938 */ import GuildMemberStore from '../../stores/GuildMemberStore.tsx'; /* Metro dependency 1945 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */ import * as ChannelRecordModule from '../../records/ChannelRecord.tsx'; /* Metro dependency 1383 */ import * as GuildRoleRecordModule from '../../records/GuildRoleRecord.tsx'; /* Metro dependency 1939 */ import * as CreatorMonetizationRestrictionsUtilsModule from '../creator_monetization_review/CreatorMonetizationRestrictionsUtils.tsx'; /* Metro dependency 3777 */ function _fun21461(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#21461, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:6, offset: 0x00ef11cf, size: 625 bytes, params: 8, frame: 24 const env0_0 = require; const _arrayLikeToArray_21467 = 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 CONNECTION_OPEN_214712 = CONNECTION_OPEN_21471; const GUILD_CREATE_214722 = GUILD_CREATE_21472; const GUILD_ROLE_CREATE_214732 = GUILD_ROLE_CREATE_21473; const CHANNEL_CREATE_214742 = CHANNEL_CREATE_21474; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_17 = {}; const Set = global.Set; let set = new Set(); const Store = (Flux).Store; _fun21475(Store).displayName = 'GatedChannelStore'; set = new set(importDefault(694) /* metro dependency 694: Dispatcher */, {CONNECTION_OPEN: CONNECTION_OPEN_214712, OVERLAY_INITIALIZE: CONNECTION_OPEN_214712, CACHE_LOADED_LAZY: CONNECTION_OPEN_214712, GUILD_CREATE: GUILD_CREATE_214722, GUILD_UPDATE: GUILD_CREATE_214722, GUILD_DELETE: GUILD_CREATE_214722, GUILD_ROLE_CREATE: GUILD_ROLE_CREATE_214732, GUILD_ROLE_UPDATE: GUILD_ROLE_CREATE_214732, GUILD_ROLE_DELETE: GUILD_ROLE_CREATE_214732, IMPERSONATE_UPDATE: GUILD_ROLE_CREATE_214732, IMPERSONATE_STOP: GUILD_ROLE_CREATE_214732, CHANNEL_CREATE: CHANNEL_CREATE_214742, CHANNEL_DELETE: CHANNEL_CREATE_214742, CHANNEL_UPDATES: function({channels}) { var r2; var r3; var r9; var r0; var computeForChannelBinding; var guild_id; var value5; var value6; var value2 = _createForOfIteratorHelperLoose_21465(channels); var value3 = value2(); var value4 = false; if (value3.done) { r0 = value4; } else { r2 = value4; r3 = value3; while (true) { channels = r3.value; if (channels.guild_id == null) { r9 = r2; } else { computeForChannelBinding = computeForChannel; guild_id = channels.guild_id; if (!computeForChannelBinding(guild_id, channels.id)) { continue; } value5 = true; r9 = value5; } value6 = value2(); if (value6.done) { r0 = r9; break; } r2 = r9; r3 = value6; continue; } } return r0; }, GUILD_ROLE_SUBSCRIPTIONS_FETCH_RESTRICTIONS_SUCCESS: GUILD_ROLE_SUBSCRIPTIONS_FETCH_RESTRICTIONS_SUCCESS, GUILD_ROLE_SUBSCRIPTIONS_FETCH_RESTRICTIONS_FAILURE: GUILD_ROLE_SUBSCRIPTIONS_FETCH_RESTRICTIONS_FAILURE}); (FileImportTrackerModule).fileFinishedImporting('modules/channel/GatedChannelStore.tsx'); exports.default = set; function _isNativeReflectConstruct_21462() { // fn#21462, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:316, offset: 0x00ef1440, size: 94 bytes, params: 1, frame: 18 var Boolean; var prototype; var valueOf; var call; var Reflect; var construct; var closure; var value; var error; try { Boolean = global.Boolean; prototype = Boolean.prototype; valueOf = prototype.valueOf; call = valueOf.call; Reflect = global.Reflect; construct = Reflect.construct; Boolean = global.Boolean; closure = function() { }; value = Reflect.apply(construct, Reflect, [Boolean, [], closure]); value = Reflect.apply(call, valueOf, [value]); var result = !value; } catch (error) { } return (_isNativeReflectConstruct_21462_isNativeReflectConstruct = function() { return !!result; })(); } function _createForOfIteratorHelperLoose_21465(a0, a1) { // fn#21465, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:509, offset: 0x00ef149e, 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 _fun21466; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_21467(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_21467(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_21467(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun21466; } 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 _fun21466() { // fn#21466, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:1080, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5 return env0_1 >= env0_0.length ? {done: true} : {done: false, value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]}; } } function isSubscriptionGated({guildId, role, isPreviewingRoles}) { // fn#21468, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:1438, offset: 0x00ef1610, size: 228 bytes, params: 2, frame: 20 var r2; var r3; var r1; var r0; var moduleValue2; var isSubscriptionRoleAvailableForPurchase; var isSubscriptionRoleAvailableForPurchase2; var value6; var currentUser; const isSubscriptionRole2 = (require(3775) /* metro dependency 3775: PremiumRoleUtils */).isSubscriptionRole(role); if (isSubscriptionRole2) { if (isPreviewingRoles) { r1 = !!isPreviewingRoles; } else { moduleValue2 = require(3775) /* metro dependency 3775: PremiumRoleUtils */; isSubscriptionRoleAvailableForPurchase = moduleValue2.isSubscriptionRoleAvailableForPurchase; r2 = role ?? undefined; isSubscriptionRoleAvailableForPurchase2 = Reflect.apply(isSubscriptionRoleAvailableForPurchase, moduleValue2, [r2]); if (isSubscriptionRoleAvailableForPurchase2) { r2 = !!isSubscriptionRoleAvailableForPurchase2; } else { value6 = false; if (role == null) { r3 = value6; } else { currentUser = UserStore.getCurrentUser(); r3 = currentUser == null ? value6 : GuildMemberStore.getMember(guildId, currentUser.id) != null && GuildMemberStore.getMember(guildId, currentUser.id).roles.includes(role.id); } r2 = !!r3; } r1 = r2; } r0 = r1; } else { r0 = !!isSubscriptionRole2; } return r0; } function isChannelSubscriptionGatedInGuild(a0, a1) { // fn#21469, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:1798, offset: 0x00ef16f4, size: 482 bytes, params: 3, frame: 22 var r1; var property; var guildRoleStoreBinding; var getRole; var value4; var isSubscriptionGatedBinding; var object; var moduleValue; var isChannelAccessGrantedBy; var value5; var _createForOfIteratorHelperLoose_21465Binding; var getSortedRoles; var value7; var value8; var done; var value9; var moduleValue3; var hasViewChannelPermission; var value10; let features = a1.features; const has = features.has; const CREATOR_MONETIZABLE = GuildFeatures.CREATOR_MONETIZABLE; if (!Reflect.apply(has, features, [CREATOR_MONETIZABLE])) { features = a1.features; reducibleJoin3: while (true) { if (!features.has(GuildFeatures.CREATOR_MONETIZABLE_PROVISIONAL)) { return false; } break reducibleJoin3; } } const impersonateStoreBinding = ImpersonateStore; const isViewingServerShop = impersonateStoreBinding.isViewingServerShop; let id = a1.id; const isViewingServerShop2 = Reflect.apply(isViewingServerShop, impersonateStoreBinding, [id]); const Object = global.Object; const keys = Object.keys; let permissionOverwrites = a0.permissionOverwrites; const value2 = Reflect.apply(keys, Object, [permissionOverwrites]); let length = value2.length; const value3 = 0; if (value3 < length) { r1 = value3; reducibleLoop4: while (true) { property = value2[r1]; guildRoleStoreBinding = GuildRoleStore; getRole = guildRoleStoreBinding.getRole; id = a1.id; value4 = Reflect.apply(getRole, guildRoleStoreBinding, [id, property]); isSubscriptionGatedBinding = isSubscriptionGated; object = {}; id = a1.id; object.guildId = id; object.role = value4; object.isPreviewingRoles = isViewingServerShop2; if (isSubscriptionGatedBinding(object)) { permissionOverwrites = a0.permissionOverwrites; property = permissionOverwrites[property]; moduleValue = require(3776) /* metro dependency 3776: RolePermissionUtils */; isChannelAccessGrantedBy = moduleValue.isChannelAccessGrantedBy; reducibleJoin6: while (true) { if (Reflect.apply(isChannelAccessGrantedBy, moduleValue, [a0, property])) { return true; } break reducibleJoin6; } } value5 = typeof r1 === 'bigint' ? r1 + 1n : +r1 + 1; length = value2.length; if (value5 < length) { r1 = value5; continue reducibleLoop4; } break reducibleLoop4; } } const everyoneRole = GuildRoleStore.getEveryoneRole(a1); const hasPermissionBinding = hasPermission; const VIEW_CHANNEL = Permissions.VIEW_CHANNEL; const hasPermission2 = hasPermissionBinding(everyoneRole, VIEW_CHANNEL); const rolePermissionUtilsModule = require(3776) /* metro dependency 3776: RolePermissionUtils */; if (!hasPermission2) { reducibleJoin14: while (true) { if (rolePermissionUtilsModule.isChannelAccessDeniedBy(a0, a0.permissionOverwrites[a1.id])) { break reducibleJoin14; } _createForOfIteratorHelperLoose_21465Binding = _createForOfIteratorHelperLoose_21465; guildRoleStoreBinding = GuildRoleStore; getSortedRoles = guildRoleStoreBinding.getSortedRoles; id = a1.id; value7 = _createForOfIteratorHelperLoose_21465Binding(Reflect.apply(getSortedRoles, guildRoleStoreBinding, [id])); value8 = value7(); done = value8.done; if (done) { break reducibleJoin14; } r1 = value8; reducibleLoop10: while (true) { value9 = r1.value; isSubscriptionGatedBinding = isSubscriptionGated; object = {}; id = a1.id; object.guildId = id; object.role = value9; object.isPreviewingRoles = isViewingServerShop2; if (isSubscriptionGatedBinding(object)) { moduleValue3 = rolePermissionUtilsModule; hasViewChannelPermission = moduleValue3.hasViewChannelPermission; reducibleJoin12: while (true) { if (Reflect.apply(hasViewChannelPermission, moduleValue3, [value9])) { return true; } break reducibleJoin12; } } value10 = value7(); done = value10.done; if (done) { break reducibleJoin14; } r1 = value10; continue reducibleLoop10; } } } return false; } function computeForChannel(a0, a1) { // fn#21470, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:2576, offset: 0x00ef18d6, size: 142 bytes, params: 3, frame: 17 var r0; const property = env0_17[a0]; if (property == null) { return false; } const channel = ChannelStore.getChannel(a1); if (channel == null) { return false; } const guildStoreBinding = GuildStore; const getGuild = guildStoreBinding.getGuild; const getGuildId = channel.getGuildId; const value3 = Reflect.apply(getGuild, guildStoreBinding, [Reflect.apply(getGuildId, channel, [])]); if (value3 == null) { return false; } const value4 = property.has(a1); const isChannelSubscriptionGatedInGuild2 = isChannelSubscriptionGatedInGuild(channel, value3); const value5 = value4 !== isChannelSubscriptionGatedInGuild2; if (value5) { if (isChannelSubscriptionGatedInGuild2) { property.add(a1); r0 = true; } else { property.delete(a1); r0 = true; } } else { r0 = value5; } return r0; } function CACHE_LOADED_LAZY_21471() { // fn#21471, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:2832, offset: 0x00ef1964, size: 27 bytes, params: 1, frame: 9 env0_17 = {}; env0_18.clear(); } function GUILD_CREATE_21472({guild}) { // fn#21472, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:2875, offset: 0x00ef197f, size: 28 bytes, params: 2, frame: 2 delete env0_17[guild.id]; } function GUILD_ROLE_CREATE_21473({guildId}) { // fn#21473, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:2928, offset: 0x00ef199b, size: 23 bytes, params: 2, frame: 2 delete env0_17[guildId]; } function CHANNEL_CREATE_21474({channel}) { // fn#21474, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:2984, offset: 0x00ef19b2, size: 49 bytes, params: 2, frame: 14 return channel.guild_id != null && computeForChannel(channel.guild_id, channel.id); } function _fun21475(a0) { // fn#21475, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:3092, offset: 0x00ef19e3, size: 137 bytes, params: 2, frame: 16 const GatedChannelStore2 = GatedChannelStore; Inherits(GatedChannelStore2, a0); return CreateClass(GatedChannelStore2, [{key: 'initialize', value: function() { this.waitFor(ChannelStore, GuildMemberStore, GuildRoleStore, GuildStore, ImpersonateStore, UserStore); }}, {key: 'isChannelGated', value: value_21478}, {key: 'isChannelGatedAndVisible', value: value_21479}, {key: 'isChannelOrThreadParentGated', value: value_21480}]); function GatedChannelStore() { // fn#21476, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:3104, offset: 0x00ef1a6c, size: 113 bytes, params: 1, frame: 20 const value = environment.__proto__; env1_2(this, GatedChannelStore); const value3 = env1_5(GatedChannelStore); return env1_4(this, _isNativeReflectConstruct_21462() ? global.Reflect.construct(value3, arguments, env1_5(this).constructor) : value3.apply(this, arguments)); } function value_21478(a0, a1) { // fn#21478, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:3474, offset: 0x00ef1b0c, size: 225 bytes, params: 3, frame: 24 var r7; var r3; var guild; var binding; var set; var features; var mutableGuildChannelsForGuild; var propertyName; var propertyName2; var add; var id; if (a0 == null) { return false; } const value = environment.__proto__; let property = env1_17[a0]; if (property != null) { r3 = property; } else { guild = GuildStore.getGuild(a0); if (guild != null) { binding = env1_17; set = new global.Set(); binding[a0] = set; features = guild.features; if (features.has(GuildFeatures.ROLE_SUBSCRIPTIONS_ENABLED)) { mutableGuildChannelsForGuild = ChannelStore.getMutableGuildChannelsForGuild(a0); for (propertyName in mutableGuildChannelsForGuild) { property = mutableGuildChannelsForGuild[propertyName]; if (!isChannelSubscriptionGatedInGuild(property, guild)) { r7 = propertyName2; continue; } add = set.add; id = property.id; Reflect.apply(add, set, [id]); r7 = propertyName2; } } } property = env1_17[a0]; r3 = property; } return r3 != null && r3.has(a1); } function value_21479(a0, a1) { // fn#21479, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:3860, offset: 0x00ef1bed, size: 58 bytes, params: 3, frame: 14 var r1; var r0; var binding; let value = a0 != null; if (value) { value = this.isChannelGated(a0, a1); if (value) { value = environment.__proto__; binding = env1_18; value = !binding.has(a0); r1 = value; } else { r1 = value; } r0 = r1; } else { r0 = value; } return r0; } function value_21480(a0, a1) { // fn#21480, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:3972, offset: 0x00ef1c27, size: 132 bytes, params: 3, frame: 17 var has; if (a0 == null) { return false; } if (this.isChannelGated(a0, a1)) { return true; } let value = environment.__proto__; const channel = ChannelStore.getChannel(a1); let r2 = channel == null || channel.parent_id == null; if (!r2) { has = THREAD_CHANNEL_TYPES.has; value = undefined; value = !Reflect.apply(has, THREAD_CHANNEL_TYPES, [channel == null ? value : channel.type]); r2 = value; } return !r2 && this.isChannelOrThreadParentGated(a0, channel.parent_id); } } function GUILD_ROLE_SUBSCRIPTIONS_FETCH_RESTRICTIONS_SUCCESS({guildId, restrictions}) { // fn#21482, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:4993, offset: 0x00ef1d1b, size: 81 bytes, params: 2, frame: 14 const isRestrictedFromShowingGuildPurchaseEntryPoints2 = (CreatorMonetizationRestrictionsUtilsModule).isRestrictedFromShowingGuildPurchaseEntryPoints(restrictions); const binding = env0_18; if (isRestrictedFromShowingGuildPurchaseEntryPoints2) { binding.add(guildId); } else { binding.delete(guildId); } } function GUILD_ROLE_SUBSCRIPTIONS_FETCH_RESTRICTIONS_FAILURE({guildId}) { // fn#21483, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2063:5207, offset: 0x00ef1d6c, size: 29 bytes, params: 2, frame: 11 env0_18.add(guildId); } } global.__d(_fun21461, 1936, [6, 7, 15, 17, 18, 1937, 1383, 1939, 1379, 1945, 1938, 1867, 1878, 661, 3775, 3776, 3777, 566, 694, 2]) /* metro module 1936, dependencies: [6, 7, 15, 17, 18, 1937, 1383, 1939, 1379, 1945, 1938, 1867, 1878, 661, 3775, 3776, 3777, 566, 694, 2] */;