package com.discord.widgets.user.search; import android.annotation.SuppressLint; import c.d.b.a.a; import com.airbnb.lottie.parser.AnimatableValueParser; import com.discord.api.channel.Channel; import com.discord.models.guild.Guild; import com.discord.models.user.User; import com.discord.utilities.search.SearchUtils; import com.discord.widgets.user.search.WidgetGlobalSearchModel; import d0.z.d.m; import d0.z.d.o; import java.util.Locale; import java.util.Objects; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function2; /* compiled from: WidgetGlobalSearchModel.kt */ public final class WidgetGlobalSearchModel$Companion$create$4 extends o implements Function2 { public final /* synthetic */ WidgetGlobalSearchModel.ChannelContext $channelContext; public final /* synthetic */ WidgetGlobalSearchModel.SearchContext $searchContext; public final /* synthetic */ WidgetGlobalSearchModel$Companion$create$2 $toItemUser$2; /* compiled from: WidgetGlobalSearchModel.kt */ /* renamed from: com.discord.widgets.user.search.WidgetGlobalSearchModel$Companion$create$4$1 reason: invalid class name */ public static final class AnonymousClass1 extends o implements Function0 { public final /* synthetic */ String $channelFilter; public final /* synthetic */ Channel $this_toItemChannel; public final /* synthetic */ WidgetGlobalSearchModel$Companion$create$4 this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public AnonymousClass1(WidgetGlobalSearchModel$Companion$create$4 widgetGlobalSearchModel$Companion$create$4, Channel channel, String str) { super(0); this.this$0 = widgetGlobalSearchModel$Companion$create$4; this.$this_toItemChannel = channel; this.$channelFilter = str; } @Override // kotlin.jvm.functions.Function0 @SuppressLint({"DefaultLocale"}) /* renamed from: invoke */ public final WidgetGlobalSearchModel.MatchedResult mo1invoke() { String str; Guild guild = (Guild) a.n0(this.$this_toItemChannel, this.this$0.$channelContext.getGuilds()); String str2 = ""; if (guild == null || (str = guild.getName()) == null) { str = str2; } Channel channel = this.this$0.$channelContext.getChannels().get(Long.valueOf(this.$this_toItemChannel.r())); if (channel != null) { str2 = AnimatableValueParser.y0(channel); } SearchUtils searchUtils = SearchUtils.INSTANCE; String str3 = this.$channelFilter; Locale locale = Locale.ROOT; m.checkNotNullExpressionValue(locale, "Locale.ROOT"); Objects.requireNonNull(str3, "null cannot be cast to non-null type java.lang.String"); String lowerCase = str3.toLowerCase(locale); m.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase(locale)"); String str4 = AnimatableValueParser.y0(this.$this_toItemChannel) + ' ' + str2 + ' ' + str; m.checkNotNullExpressionValue(locale, "Locale.ROOT"); Objects.requireNonNull(str4, "null cannot be cast to non-null type java.lang.String"); String lowerCase2 = str4.toLowerCase(locale); m.checkNotNullExpressionValue(lowerCase2, "(this as java.lang.String).toLowerCase(locale)"); if (searchUtils.fuzzyMatch(lowerCase, lowerCase2)) { return new WidgetGlobalSearchModel.MatchedResult(AnimatableValueParser.y0(this.$this_toItemChannel), -1, this.$channelFilter.length()); } return null; } } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public WidgetGlobalSearchModel$Companion$create$4(WidgetGlobalSearchModel.ChannelContext channelContext, WidgetGlobalSearchModel$Companion$create$2 widgetGlobalSearchModel$Companion$create$2, WidgetGlobalSearchModel.SearchContext searchContext) { super(2); this.$channelContext = channelContext; this.$toItemUser$2 = widgetGlobalSearchModel$Companion$create$2; this.$searchContext = searchContext; } public final WidgetGlobalSearchModel.ItemDataPayload invoke(Channel channel, String str) { m.checkNotNullParameter(channel, "$this$toItemChannel"); m.checkNotNullParameter(str, "channelFilter"); AnonymousClass1 r0 = new AnonymousClass1(this, channel, str); if (channel.A() != 1) { WidgetGlobalSearchModel.MatchedResult matchedResult = WidgetGlobalSearchModel.Companion.toMatchedResult(AnimatableValueParser.y0(channel), str); if (matchedResult == null) { matchedResult = r0.mo1invoke(); } if (matchedResult == null) { return null; } Channel channel2 = this.$channelContext.getChannels().get(Long.valueOf(channel.r())); Guild guild = (Guild) a.n0(channel, this.$channelContext.getGuilds()); Integer num = (Integer) a.o0(channel, this.$searchContext.getMentionCounts()); return new WidgetGlobalSearchModel.ItemChannel(matchedResult, channel, channel2, guild, num != null ? num.intValue() : 0, this.$channelContext.getUnreadChannelIds().contains(Long.valueOf(channel.h()))); } User v0 = AnimatableValueParser.v0(channel); if (v0 != null) { return this.$toItemUser$2.invoke(v0, str, channel); } return null; } }