2026-07-23 10:11:24 +00:00
// Module ID: 7089
// Function ID: 56783
2026-07-20 16:05:17 +00:00
// Name: _createForOfIteratorHelperLoose
2026-07-23 10:11:24 +00:00
// Dependencies: [5, 7090, 1348, 3758, 1849, 7107, 653, 4140, 7094, 7105, 1212, 1327, 22, 2]
2026-07-20 16:05:17 +00:00
// Exports: default, destinationKey, formatResultsWithHeaders, getDestinationIdFromChannelId, getOrResolveChannelIdFromDestinationId
2026-07-23 10:11:24 +00:00
// Module 7089 (_createForOfIteratorHelperLoose)
import ALLOWED_TYPES from "ALLOWED_TYPES" ;
import _isNativeReflectConstruct from "_isNativeReflectConstruct" ;
2026-07-20 16:05:17 +00:00
import closure_5 from "_isNativeReflectConstruct" ;
import closure_6 from "_isNativeReflectConstruct" ;
import closure_7 from "_isNativeReflectConstruct" ;
2026-07-23 10:11:24 +00:00
import { isAllowedType } from "ALLOWED_TYPES" ;
import ME from "ME" ;
2026-07-20 16:05:17 +00:00
2026-07-23 10:11:24 +00:00
let closure_10 ;
let closure_9 ;
const require = arg1 ;
function _createForOfIteratorHelperLoose ( iterable ) {
let closure_0 = iterable ;
iterable = "undefined" !== typeof Symbol ;
if ( iterable ) {
2026-07-20 16:05:17 +00:00
const _Symbol = Symbol ;
2026-07-23 10:11:24 +00:00
iterable = iterable [ Symbol . iterator ] ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
if ( ! iterable ) {
iterable = iterable [ Symbol . iterator ] ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
if ( iterable ) {
const iter = iterable . call ( iterable ) ;
2026-07-20 16:05:17 +00:00
const next = iter . next ;
return next . bind ( iter ) ;
} else {
const _Array = Array ;
2026-07-23 10:11:24 +00:00
let tmp = iterable ;
if ( ! Array . isArray ( iterable ) ) {
2026-07-20 16:05:17 +00:00
let tmp2 ;
2026-07-23 10:11:24 +00:00
if ( iterable ) {
if ( "string" === typeof iterable ) {
tmp2 = _arrayLikeToArray ( iterable , undefined ) ;
2026-07-20 16:05:17 +00:00
} else {
const toString = { } . toString ;
2026-07-23 10:11:24 +00:00
const substr = toString . call ( iterable ) . slice ( 8 , - 1 ) ;
2026-07-20 16:05:17 +00:00
let name = substr ;
if ( tmp3 ) {
2026-07-23 10:11:24 +00:00
name = iterable . constructor . name ;
2026-07-20 16:05:17 +00:00
}
if ( "Map" !== name ) {
if ( "Set" !== name ) {
if ( "Arguments" === name ) {
2026-07-23 10:11:24 +00:00
let arr = _arrayLikeToArray ( iterable , undefined ) ;
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
let obj = /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/ ;
2026-07-20 16:05:17 +00:00
}
}
tmp2 = arr ;
}
const _Array2 = Array ;
2026-07-23 10:11:24 +00:00
arr = Array . from ( iterable ) ;
const callResult = toString . call ( iterable ) ;
tmp3 = "Object" === substr && iterable . constructor ;
2026-07-20 16:05:17 +00:00
}
}
tmp = tmp2 ;
if ( ! tmp2 ) {
const _TypeError = TypeError ;
const typeError = new TypeError ( "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ) ;
throw typeError ;
}
}
if ( tmp ) {
2026-07-23 10:11:24 +00:00
closure_0 = tmp ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
let c1 = 0 ;
2026-07-20 16:05:17 +00:00
return ( ) = > {
2026-07-23 10:11:24 +00:00
if ( closure_1 >= length . length ) {
2026-07-20 16:05:17 +00:00
let obj = { done : true } ;
} else {
obj = { done : false } ;
closure_1 = tmp3 + 1 ;
2026-07-23 10:11:24 +00:00
obj . value = length [ + closure_1 ] ;
2026-07-20 16:05:17 +00:00
}
return obj ;
} ;
}
}
function _arrayLikeToArray ( arg0 , arg1 ) {
let length ;
if ( tmp ) {
length = arg0 . length ;
}
const ArrayResult = Array ( length ) ;
for ( let num = 0 ; num < length ; num = num + 1 ) {
ArrayResult [ num ] = arg0 [ num ] ;
}
return ArrayResult ;
}
function getChannelIdFromDestinationId ( type ) {
if ( "channel" === type . type ) {
return type . id ;
} else {
const dMFromUserId = authStore . getDMFromUserId ( type . id ) ;
let tmp4 ;
if ( null != dMFromUserId ) {
tmp4 = dMFromUserId ;
}
return tmp4 ;
}
}
2026-07-23 10:11:24 +00:00
async function _getOrResolveChannelIdFromDestinationId ( arg0 , arg1 ) {
const tmp2 = outer2_13 ( arg0 ) ;
2026-07-20 16:05:17 +00:00
if ( null != tmp2 ) {
return tmp2 ;
} else if ( "user" === tmp . type ) {
2026-07-23 10:11:24 +00:00
return yield outer2_1 ( outer2_2 [ 7 ] ) . getOrEnsurePrivateChannel ( arg0 . id ) ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
tmp = arg0 ;
2026-07-20 16:05:17 +00:00
}
function createAutocompleterResultForDestination ( targetDestination ) {
if ( "user" === targetDestination . type ) {
2026-07-23 10:11:24 +00:00
user = user . getUser ( targetDestination . id ) ;
2026-07-20 16:05:17 +00:00
let tmp5 = null ;
if ( null != user ) {
2026-07-23 10:11:24 +00:00
const obj = { type : require ( 7094 ) /* sortByMatchScore */ . AutocompleterResultTypes . USER , record : user , score : 0 } ;
2026-07-20 16:05:17 +00:00
tmp5 = obj ;
}
return tmp5 ;
} else {
2026-07-23 10:11:24 +00:00
return importDefault ( 7105 ) ( targetDestination . id ) ;
2026-07-20 16:05:17 +00:00
}
}
function canShareToChannel ( type ) {
let tmp = arg1 ;
2026-07-23 10:11:24 +00:00
if ( type . type === require ( 7094 ) /* sortByMatchScore */ . AutocompleterResultTypes . USER ) {
2026-07-20 16:05:17 +00:00
if ( ! tmp ) {
tmp = null != authStore . getDMChannelFromUserId ( type . record . id ) ;
}
let tmp10 = tmp ;
} else {
2026-07-23 10:11:24 +00:00
tmp10 = type . type === require ( 7094 ) /* sortByMatchScore */ . AutocompleterResultTypes . GROUP_DM ;
2026-07-20 16:05:17 +00:00
if ( ! tmp10 ) {
let tmp3 = type . record . type !== constants2 . GUILD_FORUM ;
if ( tmp3 ) {
tmp3 = type . record . type !== constants2 . GUILD_MEDIA ;
}
if ( tmp3 ) {
let canResult = closure_6 . can ( constants . VIEW_CHANNEL , type . record ) ;
if ( canResult ) {
canResult = closure_6 . can ( constants . SEND_MESSAGES , type . record ) ;
}
tmp3 = canResult ;
}
tmp10 = tmp3 ;
}
}
return tmp10 ;
}
function mergeAndDedupeResultsWithHeaders ( tmp4Result , items1 ) {
let done ;
let iter5 ;
const set = new Set ( ) ;
if ( null != items1 ) {
const tmp2 = _createForOfIteratorHelperLoose ( items1 ) ;
let iter = tmp2 ( ) ;
if ( ! iter . done ) {
do {
let addResult = set . add ( iter . value ) ;
let iter2 = tmp2 ( ) ;
iter = iter2 ;
done = iter2 . done ;
} while ( ! done ) ;
}
}
const items = [ ] ;
const tmp4 = _createForOfIteratorHelperLoose ( tmp4Result ) ;
const iter3 = tmp4 ( ) ;
let iter4 = iter3 ;
if ( ! iter3 . done ) {
do {
let value = iter4 . value ;
let tmp7 = tmp5 ;
let tmp8 = tmp6 ;
if ( null != value ) {
2026-07-23 10:11:24 +00:00
let tmp9 = require ;
let tmp10 = dependencyMap ;
2026-07-20 16:05:17 +00:00
tmp7 = value ;
tmp8 = tmp6 ;
2026-07-23 10:11:24 +00:00
if ( value . type !== require ( 7094 ) /* sortByMatchScore */ . AutocompleterResultTypes . HEADER ) {
2026-07-20 16:05:17 +00:00
let id = value . record . id ;
tmp7 = tmp5 ;
tmp8 = id ;
if ( ! set . has ( id ) ) {
let addResult1 = set . add ( id ) ;
let tmp12 = tmp5 ;
if ( null != tmp5 ) {
let arr = items . push ( tmp5 ) ;
}
arr = items . push ( value ) ;
tmp7 = tmp12 ;
tmp8 = id ;
}
}
}
iter5 = tmp4 ( ) ;
2026-07-23 10:11:24 +00:00
tmp5 = tmp7 ;
tmp6 = tmp8 ;
2026-07-20 16:05:17 +00:00
iter4 = iter5 ;
} while ( ! iter5 . done ) ;
}
return items ;
}
function getLastChannelResult ( selectedChannelId ) {
if ( null == selectedChannelId ) {
return null ;
} else {
2026-07-23 10:11:24 +00:00
const tmp11 = importDefault ( 7105 ) ( selectedChannelId ) ;
2026-07-20 16:05:17 +00:00
let tmp8 = null ;
if ( null != tmp11 ) {
let tmp2 = null ;
if ( isAllowedType ( tmp11 ) ) {
2026-07-23 10:11:24 +00:00
let canResult = tmp11 . type === require ( 7094 ) /* sortByMatchScore */ . AutocompleterResultTypes . USER ;
2026-07-20 16:05:17 +00:00
if ( ! canResult ) {
canResult = closure_6 . can ( constants . VIEW_CHANNEL , tmp11 . record ) ;
}
tmp2 = null ;
if ( canResult ) {
tmp2 = tmp11 ;
}
}
tmp8 = tmp2 ;
}
return tmp8 ;
}
}
function filterResults ( arr , includeMissingDMs , channelFilter ) {
let tmp = channelFilter ;
2026-07-23 10:11:24 +00:00
let closure_0 = includeMissingDMs ;
2026-07-20 16:05:17 +00:00
if ( channelFilter === undefined ) {
tmp = canShareToChannel ;
}
const importDefault = tmp ;
return arr . filter ( ( type ) = > {
2026-07-23 10:11:24 +00:00
let isNotNullishResult = includeMissingDMs ( outer1_2 [ 11 ] ) . isNotNullish ( type ) ;
2026-07-20 16:05:17 +00:00
if ( isNotNullishResult ) {
2026-07-23 10:11:24 +00:00
let tmp4 = type . type === includeMissingDMs ( outer1_2 [ 8 ] ) . AutocompleterResultTypes . HEADER ;
2026-07-20 16:05:17 +00:00
if ( ! tmp4 ) {
2026-07-23 10:11:24 +00:00
let tmp6 = outer1_8 ( type ) ;
2026-07-20 16:05:17 +00:00
if ( tmp6 ) {
2026-07-23 10:11:24 +00:00
tmp6 = tmp ( type , includeMissingDMs ) ;
2026-07-20 16:05:17 +00:00
}
tmp4 = tmp6 ;
}
isNotNullishResult = tmp4 ;
}
return isNotNullishResult ;
} ) ;
}
2026-07-23 10:11:24 +00:00
( { Permissions : closure_9 , ChannelTypes : closure_10 } = ME ) ;
const result = require ( "_isNativeReflectConstruct" ) . fileFinishedImporting ( "modules/share/formatResults.tsx" ) ;
2026-07-20 16:05:17 +00:00
export default function formatResults ( queryMode ) {
let channelFilter ;
let frequentChannels ;
let includeMissingDMs ;
let originDestination ;
let pinnedDestinations ;
let selectedDestinations ;
let targetDestination ;
queryMode = queryMode . queryMode ;
( { frequentChannels , targetDestination , selectedDestinations , pinnedDestinations , originDestination } = queryMode ) ;
( { channelFilter , includeMissingDMs } = queryMode ) ;
if ( queryMode . hasQuery ) {
return mergeAndDedupeResultsWithHeaders ( filterResults ( tmp , includeMissingDMs , channelFilter ) ) ;
} else {
if ( null != pinnedDestinations ) {
if ( pinnedDestinations . length > 0 ) {
2026-07-23 10:11:24 +00:00
let mapped = pinnedDestinations . map ( ( arg0 ) = > outer1_15 ( arg0 ) ) ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
channelHistory = channelHistory . getChannelHistory ( ) ;
2026-07-20 16:05:17 +00:00
if ( channelHistory . length > 0 ) {
2026-07-23 10:11:24 +00:00
let mapped1 = channelHistory . map ( ( arg0 ) = > originDestination ( outer1_2 [ 9 ] ) ( arg0 ) ) ;
2026-07-20 16:05:17 +00:00
} else {
mapped1 = [ ] ;
}
if ( frequentChannels . length > 0 ) {
2026-07-23 10:11:24 +00:00
let mapped2 = frequentChannels . map ( ( id ) = > originDestination ( outer1_2 [ 9 ] ) ( id . id ) ) ;
2026-07-20 16:05:17 +00:00
} else {
mapped2 = [ ] ;
}
const items = [ ] ;
let arraySpreadResult = HermesBuiltin . arraySpread ( mapped , 0 ) ;
let tmp8 = null ;
if ( null != targetDestination ) {
tmp8 = createAutocompleterResultForDestination ( targetDestination ) ;
}
items [ arraySpreadResult ] = tmp8 ;
arraySpreadResult = HermesBuiltin . arraySpread ( mapped2 , HermesBuiltin . arraySpread ( mapped1 , arraySpreadResult + 1 ) ) ;
const tmp4Result = filterResults ( items , includeMissingDMs , channelFilter ) ;
if ( null != selectedDestinations ) {
2026-07-23 10:11:24 +00:00
const found = selectedDestinations . find ( ( arg0 ) = > queryMode ( outer1_2 [ 12 ] ) . isEqual ( arg0 , originDestination ) ) ;
2026-07-20 16:05:17 +00:00
}
if ( null != originDestination ) {
if ( null == found ) {
let items1 = [ originDestination . id ] ;
}
if ( null != queryMode ) {
let substr = mergeAndDedupeResultsWithHeaders ( tmp4Result . filter ( ( type ) = > type . type === queryMode ) , items1 ) ;
} else {
substr = mergeAndDedupeResultsWithHeaders ( tmp4Result , items1 ) . slice ( 0 , 15 ) ;
const arr8 = mergeAndDedupeResultsWithHeaders ( tmp4Result , items1 ) ;
}
return substr ;
}
items1 = [ ] ;
const tmp4 = filterResults ;
}
mapped = [ ] ;
}
} ;
export const getDestinationIdFromChannelId = function getDestinationIdFromChannelId ( channel_id ) {
const channel = authStore . getChannel ( channel_id ) ;
let type ;
if ( null != channel ) {
type = channel . type ;
}
if ( type === constants2 . DM ) {
let obj = { type : "user" , id : channel.recipients [ 0 ] } ;
} else {
obj = { type : "channel" , id : channel_id } ;
}
return obj ;
} ;
export const destinationKey = function destinationKey ( type ) {
return "" + type . type + "-" + type . id ;
} ;
export { getChannelIdFromDestinationId } ;
export const getOrResolveChannelIdFromDestinationId = function getOrResolveChannelIdFromDestinationId() {
return _getOrResolveChannelIdFromDestinationId ( . . . arguments ) ;
} ;
export const formatResultsWithHeaders = function formatResultsWithHeaders ( frequentChannels ) {
let hasNonEmptyQuery ;
let queryMode ;
let results ;
let selectedChannelId ;
let selectedResult ;
( { results , selectedResult , queryMode } = frequentChannels ) ;
frequentChannels = frequentChannels . frequentChannels ;
( { hasNonEmptyQuery , selectedChannelId } = frequentChannels ) ;
if ( null != selectedResult ) {
const items = [ selectedResult . record . id ] ;
let items1 = items ;
} else {
items1 = [ ] ;
}
2026-07-23 10:11:24 +00:00
const intl = queryMode ( 1212 ) . intl ;
const headerResult = queryMode ( 7094 ) . createHeaderResult ( intl . string ( queryMode ( 1212 ) . t . qm9dSj ) ) ;
2026-07-20 16:05:17 +00:00
if ( hasNonEmptyQuery ) {
const items2 = [ headerResult ] ;
HermesBuiltin . arraySpread ( mergeAndDedupeResultsWithHeaders ( results . filter ( isAllowedType ) , items1 ) , 1 ) ;
return items2 ;
} else {
2026-07-23 10:11:24 +00:00
const mapped = frequentChannels . map ( ( id ) = > outer1_1 ( outer1_2 [ 9 ] ) ( id . id ) ) ;
const found = mapped . filter ( queryMode ( 1327 ) . isNotNullish ) ;
2026-07-20 16:05:17 +00:00
const found1 = found . filter ( isAllowedType ) ;
if ( null != queryMode ) {
const items3 = [ headerResult ] ;
HermesBuiltin . arraySpread ( found1 . filter ( ( type ) = > type . type === queryMode ) , 1 ) ;
let items4 = items3 ;
} else {
2026-07-23 10:11:24 +00:00
const intl2 = queryMode ( 1212 ) . intl ;
items4 = [ queryMode ( 7094 ) . createHeaderResult ( intl2 . string ( queryMode ( 1212 ) . t [ "80lOZ1" ] ) ) , getLastChannelResult ( selectedChannelId ) , headerResult ] ;
2026-07-20 16:05:17 +00:00
HermesBuiltin . arraySpread ( found1 , 3 ) ;
2026-07-23 10:11:24 +00:00
const obj2 = queryMode ( 7094 ) ;
2026-07-20 16:05:17 +00:00
}
return mergeAndDedupeResultsWithHeaders ( items4 , items1 ) ;
}
2026-07-23 10:11:24 +00:00
const obj = queryMode ( 7094 ) ;
2026-07-20 16:05:17 +00:00
} ;