discord-jadx/app/src/main/java/com/discord/widgets/chat/input/applicationcommands/WidgetChatInputApplicationC...

581 lines
33 KiB
Java

package com.discord.widgets.chat.input.applicationcommands;
import android.content.Context;
import android.content.res.Resources;
import android.text.Editable;
import android.text.Spannable;
import android.widget.TextView;
import androidx.annotation.MainThread;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import c.d.b.a.a;
import com.discord.api.commands.ApplicationCommandType;
import com.discord.app.AppFragment;
import com.discord.databinding.WidgetChatInputApplicationCommandsBinding;
import com.discord.models.commands.Application;
import com.discord.models.commands.ApplicationCommand;
import com.discord.models.commands.ApplicationCommandOption;
import com.discord.models.commands.ApplicationSubCommand;
import com.discord.stores.StoreApplicationCommands;
import com.discord.stores.StoreApplicationCommandsKt;
import com.discord.stores.StoreStream;
import com.discord.utilities.accessibility.AccessibilityUtils;
import com.discord.utilities.color.ColorCompat;
import com.discord.utilities.dimen.DimenUtils;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.textprocessing.SimpleRoundedBackgroundSpan;
import com.discord.widgets.chat.input.UserAndSelectedGuildRoles;
import com.discord.widgets.chat.input.WidgetChatInputEditText;
import com.discord.widgets.chat.input.models.ApplicationCommandData;
import com.discord.widgets.chat.input.models.AutocompleteApplicationCommands;
import com.discord.widgets.chat.input.models.AutocompleteInputCommandContext;
import com.discord.widgets.chat.input.models.AutocompleteInputSelectionModel;
import com.discord.widgets.chat.input.models.InputCommandOptions;
import com.discord.widgets.chat.input.models.InputSelectionModel;
import com.discord.widgets.chat.input.models.OptionRange;
import com.discord.widgets.chat.input.models.VerifiedCommandMentionInputModel;
import com.lytefast.flexinput.widget.FlexEditText;
import d0.d0.f;
import d0.g0.s;
import d0.g0.t;
import d0.g0.w;
import d0.t.u;
import d0.z.d.m;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.ranges.IntRange;
import kotlin.text.MatchResult;
import kotlin.text.Regex;
import rx.Observable;
/* compiled from: WidgetChatInputApplicationCommands.kt */
public final class WidgetChatInputApplicationCommands {
private final SelectedApplicationCommandAdapter applicationCommandsParamAdapter;
private final WidgetChatInputApplicationCommandsBinding binding;
private final Context context;
private boolean discoverMenuOpened;
private Long dmApplicationId;
private final FlexEditText editText;
private Long guildId;
private String input;
private ApplicationCommandOption invalidOptionHighlightedFromSend;
private AutocompleteInputSelectionModel lastModelChat;
private String lastQuery;
private boolean pendingShowNextOption;
private ApplicationCommand selectedCommand;
private boolean showCommandUi;
public final /* synthetic */ class WhenMappings {
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
public static final /* synthetic */ int[] $EnumSwitchMapping$1;
static {
ApplicationCommandType.values();
int[] iArr = new int[10];
$EnumSwitchMapping$0 = iArr;
ApplicationCommandType applicationCommandType = ApplicationCommandType.USER;
iArr[applicationCommandType.ordinal()] = 1;
ApplicationCommandType applicationCommandType2 = ApplicationCommandType.CHANNEL;
iArr[applicationCommandType2.ordinal()] = 2;
ApplicationCommandType applicationCommandType3 = ApplicationCommandType.ROLE;
iArr[applicationCommandType3.ordinal()] = 3;
ApplicationCommandType applicationCommandType4 = ApplicationCommandType.MENTIONABLE;
iArr[applicationCommandType4.ordinal()] = 4;
ApplicationCommandType.values();
int[] iArr2 = new int[10];
$EnumSwitchMapping$1 = iArr2;
iArr2[applicationCommandType.ordinal()] = 1;
iArr2[applicationCommandType2.ordinal()] = 2;
iArr2[applicationCommandType3.ordinal()] = 3;
iArr2[applicationCommandType4.ordinal()] = 4;
}
}
public WidgetChatInputApplicationCommands(FlexEditText flexEditText, WidgetChatInputApplicationCommandsBinding widgetChatInputApplicationCommandsBinding) {
m.checkNotNullParameter(flexEditText, "editText");
m.checkNotNullParameter(widgetChatInputApplicationCommandsBinding, "binding");
this.editText = flexEditText;
this.binding = widgetChatInputApplicationCommandsBinding;
RecyclerView recyclerView = widgetChatInputApplicationCommandsBinding.f1724c;
m.checkNotNullExpressionValue(recyclerView, "binding.chatInputApplicationCommandsRecycler");
SelectedApplicationCommandAdapter selectedApplicationCommandAdapter = new SelectedApplicationCommandAdapter(recyclerView, new WidgetChatInputApplicationCommands$applicationCommandsParamAdapter$1(this));
this.applicationCommandsParamAdapter = selectedApplicationCommandAdapter;
ConstraintLayout constraintLayout = widgetChatInputApplicationCommandsBinding.a;
m.checkNotNullExpressionValue(constraintLayout, "binding.root");
Context context = constraintLayout.getContext();
this.context = context;
RecyclerView recyclerView2 = widgetChatInputApplicationCommandsBinding.f1724c;
m.checkNotNullExpressionValue(recyclerView2, "binding.chatInputApplicationCommandsRecycler");
recyclerView2.setLayoutManager(new LinearLayoutManager(context, 0, false));
RecyclerView recyclerView3 = widgetChatInputApplicationCommandsBinding.f1724c;
m.checkNotNullExpressionValue(recyclerView3, "binding.chatInputApplicationCommandsRecycler");
recyclerView3.setAdapter(selectedApplicationCommandAdapter);
selectedApplicationCommandAdapter.getRecycler().setItemAnimator(null);
}
public static final /* synthetic */ String access$getCommandPrefix(WidgetChatInputApplicationCommands widgetChatInputApplicationCommands, String str) {
return widgetChatInputApplicationCommands.getCommandPrefix(str);
}
public static final /* synthetic */ void access$handleCommandToken(WidgetChatInputApplicationCommands widgetChatInputApplicationCommands, String str, Long l, Long l2, boolean z2) {
widgetChatInputApplicationCommands.handleCommandToken(str, l, l2, z2);
}
/* JADX WARNING: Code restructure failed: missing block: B:12:0x0049, code lost:
if (r6 != 8) goto L_0x0050;
*/
/* JADX WARNING: Removed duplicated region for block: B:17:0x0056 */
/* JADX WARNING: Removed duplicated region for block: B:18:0x005b */
@MainThread
private final void appendParam(ApplicationCommandOption applicationCommandOption, Integer num) {
String obj = this.editText.getEditableText().toString();
obj.length();
String str = "";
StringBuilder L = a.L((w.endsWith$default(obj, ' ', false, 2, null) || num != null) ? str : " ");
L.append(applicationCommandOption.getName());
L.append(':');
String sb = L.toString();
int ordinal = applicationCommandOption.getType().ordinal();
if (ordinal != 5) {
if (ordinal == 6) {
str = "#";
} else if (ordinal != 7) {
}
String t = a.t(sb, str);
int intValue = num == null ? num.intValue() : obj.length();
WidgetChatInputEditText.Companion companion = WidgetChatInputEditText.Companion;
Editable editableText = this.editText.getEditableText();
m.checkNotNullExpressionValue(editableText, "editText.editableText");
companion.insert(editableText, t, intValue, intValue);
this.editText.setSelection(t.length() + obj.length());
}
str = "@";
String t = a.t(sb, str);
if (num == null) {
}
WidgetChatInputEditText.Companion companion = WidgetChatInputEditText.Companion;
Editable editableText = this.editText.getEditableText();
m.checkNotNullExpressionValue(editableText, "editText.editableText");
companion.insert(editableText, t, intValue, intValue);
this.editText.setSelection(t.length() + obj.length());
}
public static /* synthetic */ void appendParam$default(WidgetChatInputApplicationCommands widgetChatInputApplicationCommands, ApplicationCommandOption applicationCommandOption, Integer num, int i, Object obj) {
if ((i & 2) != 0) {
num = null;
}
widgetChatInputApplicationCommands.appendParam(applicationCommandOption, num);
}
private final String getCommandPrefix(String str) {
List<String> groupValues;
String str2;
MatchResult find$default = Regex.find$default(new Regex("^(/[^\\s]*)+"), str, 0, 2, null);
return (find$default == null || (groupValues = find$default.getGroupValues()) == null || (str2 = (String) u.getOrNull(groupValues, 1)) == null) ? "" : str2;
}
private final void handleCommandToken(String str, Long l, Long l2, boolean z2) {
if (str.length() <= 1 && this.dmApplicationId == null) {
StoreStream.Companion.getApplicationCommands().clearQueryCommands();
this.lastQuery = null;
}
if (str.length() == 1) {
StoreStream.Companion.getApplicationCommands().requestInitialApplicationCommands(l, l2);
this.lastQuery = null;
} else if (str.length() > 1 && this.dmApplicationId == null) {
if ((!m.areEqual(this.lastQuery, str)) || z2) {
StoreApplicationCommands applicationCommands = StoreStream.Companion.getApplicationCommands();
String substring = str.substring(1);
m.checkNotNullExpressionValue(substring, "(this as java.lang.String).substring(startIndex)");
applicationCommands.requestApplicationCommandsQuery(l, substring);
this.lastQuery = str;
}
}
}
private final void onApplicationOptionClicked(ApplicationCommandOption applicationCommandOption, boolean z2) {
Map<ApplicationCommandOption, OptionRange> inputRanges;
OptionRange optionRange;
IntRange value;
InputSelectionModel inputSelectionModel;
VerifiedCommandMentionInputModel inputModel;
AutocompleteInputSelectionModel autocompleteInputSelectionModel = this.lastModelChat;
InputCommandOptions inputCommandOptions = (autocompleteInputSelectionModel == null || (inputSelectionModel = autocompleteInputSelectionModel.getInputSelectionModel()) == null || (inputModel = inputSelectionModel.getInputModel()) == null) ? null : inputModel.getInputCommandOptions();
if (inputCommandOptions == null || (inputRanges = inputCommandOptions.getInputRanges()) == null || (optionRange = inputRanges.get(applicationCommandOption)) == null || (value = optionRange.getValue()) == null) {
appendParam$default(this, applicationCommandOption, null, 2, null);
} else if (z2) {
int ordinal = applicationCommandOption.getType().ordinal();
int i = 1;
if (!(ordinal == 5 || ordinal == 6 || ordinal == 7 || ordinal == 8)) {
i = 0;
}
this.editText.setSelection(f.coerceAtMost(value.getFirst() + i, this.editText.getEditableText().length()), Math.min(this.editText.getEditableText().length(), value.getLast()));
}
}
public static /* synthetic */ void onApplicationOptionClicked$default(WidgetChatInputApplicationCommands widgetChatInputApplicationCommands, ApplicationCommandOption applicationCommandOption, boolean z2, int i, Object obj) {
if ((i & 2) != 0) {
z2 = true;
}
widgetChatInputApplicationCommands.onApplicationOptionClicked(applicationCommandOption, z2);
}
private final void showApplicationCommandsUi(boolean z2) {
ConstraintLayout constraintLayout = this.binding.a;
m.checkNotNullExpressionValue(constraintLayout, "binding.root");
constraintLayout.setVisibility(z2 ? 0 : 8);
}
public static /* synthetic */ void showNextOption$default(WidgetChatInputApplicationCommands widgetChatInputApplicationCommands, ApplicationCommand applicationCommand, ApplicationCommandOption applicationCommandOption, boolean z2, int i, Object obj) {
if ((i & 4) != 0) {
z2 = true;
}
widgetChatInputApplicationCommands.showNextOption(applicationCommand, applicationCommandOption, z2);
}
@MainThread
public final boolean appendTextForCommandForInput(VerifiedCommandMentionInputModel verifiedCommandMentionInputModel) {
m.checkNotNullParameter(verifiedCommandMentionInputModel, "model");
ApplicationCommand selectedCommand = verifiedCommandMentionInputModel.getInputCommandContext().getSelectedCommand();
if (selectedCommand != null && selectedCommand.getOptions().size() == 1) {
StringBuilder J = a.J('/');
J.append(selectedCommand.getName());
J.append(' ');
String sb = J.toString();
if (!verifiedCommandMentionInputModel.getInputCommandOptions().getInputRanges().containsKey(selectedCommand.getOptions().get(0)) && verifiedCommandMentionInputModel.getInput().length() > sb.length()) {
appendParam(selectedCommand.getOptions().get(0), Integer.valueOf(sb.length()));
return true;
}
}
return false;
}
public final void applyParamSpan(Spannable spannable, int i, int i2, boolean z2) {
m.checkNotNullParameter(spannable, "spannable");
spannable.setSpan(new SimpleRoundedBackgroundSpan(i, i2, DimenUtils.dpToPixels(4), DimenUtils.dpToPixels(4), ColorCompat.getThemedColor(this.editText, 2130968894), (float) DimenUtils.dpToPixels(4), !z2 ? Integer.valueOf(ColorCompat.getColor(this.editText, 2131100324)) : null, false, WidgetChatInputApplicationCommands$applyParamSpan$1.INSTANCE, 128, null), i, i2, 33);
}
public final void configureObservables(AppFragment appFragment) {
m.checkNotNullParameter(appFragment, "appFragment");
StoreStream.Companion companion = StoreStream.Companion;
Observable r = Observable.j(companion.getGuildSelected().observeSelectedGuildId().r(), companion.getChannelsSelected().observeSelectedChannel().r(), WidgetChatInputApplicationCommands$configureObservables$1.INSTANCE).r();
m.checkNotNullExpressionValue(r, "Observable.combineLatest… .distinctUntilChanged()");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(r, appFragment, null, 2, null), WidgetChatInputApplicationCommands.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatInputApplicationCommands$configureObservables$2(this), 62, (Object) null);
}
public final void configureUi(AutocompleteInputSelectionModel autocompleteInputSelectionModel, boolean z2) {
String str;
InputSelectionModel inputSelectionModel;
VerifiedCommandMentionInputModel inputModel;
InputSelectionModel inputSelectionModel2;
VerifiedCommandMentionInputModel inputModel2;
AutocompleteInputCommandContext inputCommandContext;
m.checkNotNullParameter(autocompleteInputSelectionModel, "model");
if (z2) {
this.applicationCommandsParamAdapter.clear();
return;
}
showApplicationCommandsUi(autocompleteInputSelectionModel.getInputSelectionModel().getInputModel().getInputCommandContext().isCommand());
ApplicationCommand selectedCommand = autocompleteInputSelectionModel.getInputSelectionModel().getInputModel().getInputCommandContext().getSelectedCommand();
AutocompleteInputSelectionModel autocompleteInputSelectionModel2 = this.lastModelChat;
boolean z3 = !m.areEqual(selectedCommand, (autocompleteInputSelectionModel2 == null || (inputSelectionModel2 = autocompleteInputSelectionModel2.getInputSelectionModel()) == null || (inputModel2 = inputSelectionModel2.getInputModel()) == null || (inputCommandContext = inputModel2.getInputCommandContext()) == null) ? null : inputCommandContext.getSelectedCommand());
AutocompleteInputSelectionModel autocompleteInputSelectionModel3 = this.lastModelChat;
boolean areEqual = m.areEqual((autocompleteInputSelectionModel3 == null || (inputSelectionModel = autocompleteInputSelectionModel3.getInputSelectionModel()) == null || (inputModel = inputSelectionModel.getInputModel()) == null) ? null : inputModel.getInput(), "/");
if (areEqual && !this.discoverMenuOpened) {
AccessibilityUtils accessibilityUtils = AccessibilityUtils.INSTANCE;
Context context = this.editText.getContext();
m.checkNotNullExpressionValue(context, "editText.context");
accessibilityUtils.sendAnnouncement(context, 2131887429);
StoreStream.Companion companion = StoreStream.Companion;
companion.getAnalytics().trackApplicationCommandBrowserOpened(companion.getChannelsSelected().getId());
}
this.discoverMenuOpened = areEqual;
this.lastModelChat = autocompleteInputSelectionModel;
Application selectedApplication = autocompleteInputSelectionModel.getInputSelectionModel().getInputModel().getInputCommandContext().getSelectedApplication();
ApplicationCommandOption selectedCommandOption = autocompleteInputSelectionModel.getInputSelectionModel().getSelectedCommandOption();
TextView textView = this.binding.b;
m.checkNotNullExpressionValue(textView, "binding.chatInputApplica…CommandsOptionDescription");
if (selectedCommand != null) {
Context context2 = this.context;
m.checkNotNullExpressionValue(context2, "context");
Resources resources = context2.getResources();
m.checkNotNullExpressionValue(resources, "context.resources");
str = StoreApplicationCommandsKt.getDescriptionText(selectedCommand, resources);
} else {
str = null;
}
textView.setText(str);
if (selectedCommand == null || selectedApplication == null) {
this.applicationCommandsParamAdapter.clear();
} else {
this.applicationCommandsParamAdapter.setApplicationCommand(selectedCommand, selectedApplication);
if (selectedCommandOption != null) {
if (!m.areEqual(this.invalidOptionHighlightedFromSend, selectedCommandOption)) {
this.invalidOptionHighlightedFromSend = null;
}
if (autocompleteInputSelectionModel.getShowErrorsForOptions().contains(selectedCommandOption) || m.areEqual(this.invalidOptionHighlightedFromSend, selectedCommandOption)) {
TextView textView2 = this.binding.b;
m.checkNotNullExpressionValue(textView2, "binding.chatInputApplica…CommandsOptionDescription");
Context context3 = this.context;
m.checkNotNullExpressionValue(context3, "context");
Resources resources2 = context3.getResources();
m.checkNotNullExpressionValue(resources2, "context.resources");
textView2.setText(StoreApplicationCommandsKt.getErrorText(selectedCommandOption, resources2));
WidgetChatInputApplicationCommandsBinding widgetChatInputApplicationCommandsBinding = this.binding;
TextView textView3 = widgetChatInputApplicationCommandsBinding.b;
ConstraintLayout constraintLayout = widgetChatInputApplicationCommandsBinding.a;
m.checkNotNullExpressionValue(constraintLayout, "binding.root");
textView3.setTextColor(ColorCompat.getColor(constraintLayout.getContext(), 2131100324));
} else {
TextView textView4 = this.binding.b;
m.checkNotNullExpressionValue(textView4, "binding.chatInputApplica…CommandsOptionDescription");
Context context4 = this.context;
m.checkNotNullExpressionValue(context4, "context");
Resources resources3 = context4.getResources();
m.checkNotNullExpressionValue(resources3, "context.resources");
textView4.setText(StoreApplicationCommandsKt.getDescriptionText(selectedCommandOption, resources3));
this.binding.b.setTextColor(ColorCompat.getThemedColor(this.context, 2130968989));
}
this.applicationCommandsParamAdapter.highlightOption(selectedCommandOption);
} else {
this.binding.b.setTextColor(ColorCompat.getThemedColor(this.context, 2130968989));
TextView textView5 = this.binding.b;
m.checkNotNullExpressionValue(textView5, "binding.chatInputApplica…CommandsOptionDescription");
Context context5 = this.context;
m.checkNotNullExpressionValue(context5, "context");
Resources resources4 = context5.getResources();
m.checkNotNullExpressionValue(resources4, "context.resources");
textView5.setText(StoreApplicationCommandsKt.getDescriptionText(selectedCommand, resources4));
this.applicationCommandsParamAdapter.clearParamOptionHighlight();
}
this.applicationCommandsParamAdapter.setVerified(autocompleteInputSelectionModel.getInputSelectionModel().getInputModel().getInputCommandOptions().getCommandOptionValidity(), autocompleteInputSelectionModel.getShowErrorsForOptions());
}
if (selectedCommand == null) {
return;
}
if (z3) {
this.pendingShowNextOption = false;
showNextOption$default(this, selectedCommand, null, false, 4, null);
Long longOrNull = selectedCommand instanceof ApplicationSubCommand ? s.toLongOrNull(((ApplicationSubCommand) selectedCommand).getRootCommand().getId()) : s.toLongOrNull(selectedCommand.getId());
if (longOrNull != null) {
StoreStream.Companion companion2 = StoreStream.Companion;
companion2.getAnalytics().trackApplicationCommandSelected(companion2.getChannelsSelected().getId(), selectedCommand.getApplicationId(), longOrNull.longValue());
}
} else if (this.pendingShowNextOption) {
showNextOption$default(this, selectedCommand, autocompleteInputSelectionModel.getInputSelectionModel().getSelectedCommandOption(), false, 4, null);
this.pendingShowNextOption = false;
}
}
public final ApplicationCommandData getApplicationSendData(List<? extends ApplicationCommand> list) {
m.checkNotNullParameter(list, "queryCommands");
return WidgetChatInputModelMappingFunctions.INSTANCE.getApplicationSendData(this.lastModelChat, list);
}
public final boolean getDiscoverMenuOpened() {
return this.discoverMenuOpened;
}
public final Long getDmApplicationId() {
return this.dmApplicationId;
}
public final Long getGuildId() {
return this.guildId;
}
public final String getInput() {
return this.input;
}
/* JADX WARNING: Code restructure failed: missing block: B:21:0x006b, code lost:
if ((!d0.z.d.m.areEqual(r0, r3 != null ? r3.getName() : null)) != false) goto L_0x006d;
*/
public final AutocompleteInputCommandContext getInputCommandContext(String str, AutocompleteApplicationCommands autocompleteApplicationCommands, UserAndSelectedGuildRoles userAndSelectedGuildRoles) {
String str2;
InputSelectionModel inputSelectionModel;
VerifiedCommandMentionInputModel inputModel;
m.checkNotNullParameter(str, "input");
m.checkNotNullParameter(autocompleteApplicationCommands, "applicationCommands");
m.checkNotNullParameter(userAndSelectedGuildRoles, "userAndRoles");
this.input = str;
Long l = this.guildId;
Long l2 = this.dmApplicationId;
String commandPrefix = getCommandPrefix(str);
AutocompleteInputSelectionModel autocompleteInputSelectionModel = this.lastModelChat;
if (autocompleteInputSelectionModel == null || (inputSelectionModel = autocompleteInputSelectionModel.getInputSelectionModel()) == null || (inputModel = inputSelectionModel.getInputModel()) == null || (str2 = inputModel.getInput()) == null) {
str2 = "";
}
if (!m.areEqual(commandPrefix, getCommandPrefix(str2))) {
handleCommandToken(commandPrefix, l, l2, false);
}
Long l3 = null;
if (!(!t.isBlank(commandPrefix))) {
return new AutocompleteInputCommandContext(null, null, 3, null);
}
if (this.selectedCommand != null) {
Objects.requireNonNull(commandPrefix, "null cannot be cast to non-null type java.lang.String");
String substring = commandPrefix.substring(1);
m.checkNotNullExpressionValue(substring, "(this as java.lang.String).substring(startIndex)");
ApplicationCommand applicationCommand = this.selectedCommand;
}
this.selectedCommand = WidgetChatInputModelMappingFunctions.INSTANCE.getSelectedCommand(autocompleteApplicationCommands.getQueryCommands(), commandPrefix, str, userAndSelectedGuildRoles);
Map<Long, Application> applicationMap = StoreStream.Companion.getApplicationCommands().getApplicationMap();
ApplicationCommand applicationCommand2 = this.selectedCommand;
if (applicationCommand2 != null) {
l3 = Long.valueOf(applicationCommand2.getApplicationId());
}
return new AutocompleteInputCommandContext(applicationMap.get(l3), this.selectedCommand);
}
public final ApplicationCommandOption getInvalidOptionHighlightedFromSend() {
return this.invalidOptionHighlightedFromSend;
}
public final AutocompleteInputSelectionModel getLastModelChat() {
return this.lastModelChat;
}
public final ApplicationCommand getSelectedCommand() {
return this.selectedCommand;
}
public final void highlightFirstInvalidCommandOption() {
InputSelectionModel inputSelectionModel;
VerifiedCommandMentionInputModel inputModel;
InputCommandOptions inputCommandOptions;
Map<ApplicationCommandOption, Boolean> commandOptionValidity;
AutocompleteInputSelectionModel autocompleteInputSelectionModel = this.lastModelChat;
if (!(autocompleteInputSelectionModel == null || (inputSelectionModel = autocompleteInputSelectionModel.getInputSelectionModel()) == null || (inputModel = inputSelectionModel.getInputModel()) == null || (inputCommandOptions = inputModel.getInputCommandOptions()) == null || (commandOptionValidity = inputCommandOptions.getCommandOptionValidity()) == null)) {
for (ApplicationCommandOption applicationCommandOption : commandOptionValidity.keySet()) {
if (m.areEqual(commandOptionValidity.get(applicationCommandOption), Boolean.FALSE)) {
this.invalidOptionHighlightedFromSend = applicationCommandOption;
onApplicationOptionClicked$default(this, applicationCommandOption, false, 2, null);
return;
}
}
}
}
public final void onApplicationCommandSendError() {
InputSelectionModel inputSelectionModel;
VerifiedCommandMentionInputModel inputModel;
AutocompleteInputCommandContext inputCommandContext;
ApplicationCommand selectedCommand;
AutocompleteInputSelectionModel autocompleteInputSelectionModel;
InputSelectionModel inputSelectionModel2;
VerifiedCommandMentionInputModel inputModel2;
InputCommandOptions inputCommandOptions;
Map<ApplicationCommandOption, Boolean> commandOptionValidity;
ApplicationCommand applicationCommand;
List<ApplicationCommandOption> options;
Object obj;
ApplicationCommand applicationCommand2;
AutocompleteInputSelectionModel autocompleteInputSelectionModel2 = this.lastModelChat;
if (autocompleteInputSelectionModel2 != null && (inputSelectionModel = autocompleteInputSelectionModel2.getInputSelectionModel()) != null && (inputModel = inputSelectionModel.getInputModel()) != null && (inputCommandContext = inputModel.getInputCommandContext()) != null && (selectedCommand = inputCommandContext.getSelectedCommand()) != null && (autocompleteInputSelectionModel = this.lastModelChat) != null && (inputSelectionModel2 = autocompleteInputSelectionModel.getInputSelectionModel()) != null && (inputModel2 = inputSelectionModel2.getInputModel()) != null && (inputCommandOptions = inputModel2.getInputCommandOptions()) != null && (commandOptionValidity = inputCommandOptions.getCommandOptionValidity()) != null && (applicationCommand = this.selectedCommand) != null && (options = applicationCommand.getOptions()) != null) {
Iterator<T> it = options.iterator();
while (true) {
if (!it.hasNext()) {
obj = null;
break;
}
obj = it.next();
if (m.areEqual(commandOptionValidity.get((ApplicationCommandOption) obj), Boolean.FALSE)) {
break;
}
}
ApplicationCommandOption applicationCommandOption = (ApplicationCommandOption) obj;
if (applicationCommandOption != null && (applicationCommand2 = this.selectedCommand) != null) {
long applicationId = applicationCommand2.getApplicationId();
Long longOrNull = selectedCommand instanceof ApplicationSubCommand ? s.toLongOrNull(((ApplicationSubCommand) selectedCommand).getRootCommand().getId()) : s.toLongOrNull(selectedCommand.getId());
if (longOrNull != null) {
StoreStream.Companion.getAnalytics().trackApplicationCommandValidationFailure(applicationId, longOrNull.longValue(), applicationCommandOption.getType().toString(), applicationCommandOption.getRequired());
highlightFirstInvalidCommandOption();
}
}
}
}
public final void selectApplicationCommand(ApplicationCommand applicationCommand) {
m.checkNotNullParameter(applicationCommand, "command");
this.selectedCommand = applicationCommand;
}
public final void setApplicationIdForDm(Long l) {
String str;
this.dmApplicationId = l;
if (l != null && (str = this.input) != null) {
handleCommandToken(getCommandPrefix(str), this.guildId, this.dmApplicationId, true);
}
}
public final void setDiscoverMenuOpened(boolean z2) {
this.discoverMenuOpened = z2;
}
public final void setDmApplicationId(Long l) {
this.dmApplicationId = l;
}
public final void setGuildId(Long l) {
this.guildId = l;
}
public final void setInput(String str) {
this.input = str;
}
public final void setInvalidOptionHighlightedFromSend(ApplicationCommandOption applicationCommandOption) {
this.invalidOptionHighlightedFromSend = applicationCommandOption;
}
public final void setLastModelChat(AutocompleteInputSelectionModel autocompleteInputSelectionModel) {
this.lastModelChat = autocompleteInputSelectionModel;
}
public final void setSelectedCommand(ApplicationCommand applicationCommand) {
this.selectedCommand = applicationCommand;
}
public final void showNextOption(ApplicationCommand applicationCommand, ApplicationCommandOption applicationCommandOption, boolean z2) {
InputSelectionModel inputSelectionModel;
VerifiedCommandMentionInputModel inputModel;
m.checkNotNullParameter(applicationCommand, "command");
Editable editableText = this.editText.getEditableText();
Object obj = null;
String obj2 = editableText != null ? editableText.toString() : null;
AutocompleteInputSelectionModel autocompleteInputSelectionModel = this.lastModelChat;
if (!m.areEqual(obj2, (autocompleteInputSelectionModel == null || (inputSelectionModel = autocompleteInputSelectionModel.getInputSelectionModel()) == null || (inputModel = inputSelectionModel.getInputModel()) == null) ? null : inputModel.getInput())) {
this.pendingShowNextOption = true;
} else if (applicationCommandOption != null) {
ApplicationCommandOption applicationCommandOption2 = (ApplicationCommandOption) u.getOrNull(applicationCommand.getOptions(), applicationCommand.getOptions().indexOf(applicationCommandOption) + 1);
if (applicationCommandOption2 == null) {
return;
}
if (!z2 || applicationCommandOption2.getRequired()) {
onApplicationOptionClicked$default(this, applicationCommandOption2, false, 2, null);
}
} else {
Iterator<T> it = applicationCommand.getOptions().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
Object next = it.next();
if (((ApplicationCommandOption) next).getRequired()) {
obj = next;
break;
}
}
ApplicationCommandOption applicationCommandOption3 = (ApplicationCommandOption) obj;
if (applicationCommandOption3 != null) {
onApplicationOptionClicked(applicationCommandOption3, false);
}
}
}
}