949 lines
50 KiB
Java
949 lines
50 KiB
Java
package com.discord.widgets.chat.input.applicationcommands;
|
|
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.discord.api.commands.ApplicationCommandType;
|
|
import com.discord.api.commands.CommandChoice;
|
|
import com.discord.api.sticker.Sticker;
|
|
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.utilities.dsti.StickerUtils;
|
|
import com.discord.utilities.string.StringUtilsKt;
|
|
import com.discord.widgets.chat.input.MentionUtilsKt;
|
|
import com.discord.widgets.chat.input.UserAndSelectedGuildRoles;
|
|
import com.discord.widgets.chat.input.autocomplete.ApplicationCommandAutocompletable;
|
|
import com.discord.widgets.chat.input.autocomplete.ApplicationCommandChoiceAutocompletable;
|
|
import com.discord.widgets.chat.input.autocomplete.Autocompletable;
|
|
import com.discord.widgets.chat.input.autocomplete.ChannelAutocompletable;
|
|
import com.discord.widgets.chat.input.autocomplete.LeadingIdentifier;
|
|
import com.discord.widgets.chat.input.autocomplete.RoleAutocompletable;
|
|
import com.discord.widgets.chat.input.autocomplete.UserAutocompletable;
|
|
import com.discord.widgets.chat.input.autocomplete.sources.ApplicationCommandsAutocompletableSource;
|
|
import com.discord.widgets.chat.input.models.ApplicationCommandData;
|
|
import com.discord.widgets.chat.input.models.ApplicationCommandValue;
|
|
import com.discord.widgets.chat.input.models.AutocompleteInputSelectionModel;
|
|
import com.discord.widgets.chat.input.models.BooleanOptionValue;
|
|
import com.discord.widgets.chat.input.models.ChannelOptionValue;
|
|
import com.discord.widgets.chat.input.models.ChatInputMentionsMap;
|
|
import com.discord.widgets.chat.input.models.CommandOptionValue;
|
|
import com.discord.widgets.chat.input.models.InputCommandOptions;
|
|
import com.discord.widgets.chat.input.models.InputSelectionModel;
|
|
import com.discord.widgets.chat.input.models.IntegerOptionValue;
|
|
import com.discord.widgets.chat.input.models.MentionToken;
|
|
import com.discord.widgets.chat.input.models.OptionRange;
|
|
import com.discord.widgets.chat.input.models.RawOptionValue;
|
|
import com.discord.widgets.chat.input.models.RoleOptionValue;
|
|
import com.discord.widgets.chat.input.models.SnowflakeOptionValue;
|
|
import com.discord.widgets.chat.input.models.StringOptionValue;
|
|
import com.discord.widgets.chat.input.models.UserOptionValue;
|
|
import com.discord.widgets.chat.input.models.VerifiedCommandMentionInputModel;
|
|
import com.discord.widgets.chat.input.sticker.StickerPickerFeatureFlag;
|
|
import d0.g0.s;
|
|
import d0.g0.t;
|
|
import d0.g0.w;
|
|
import d0.t.g0;
|
|
import d0.t.h0;
|
|
import d0.t.n;
|
|
import d0.t.n0;
|
|
import d0.t.o;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.Set;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.Pair;
|
|
import kotlin.ranges.IntRange;
|
|
/* compiled from: WidgetChatInputModelMappingFunctions.kt */
|
|
public final class WidgetChatInputModelMappingFunctions {
|
|
public static final WidgetChatInputModelMappingFunctions INSTANCE = new WidgetChatInputModelMappingFunctions();
|
|
private static final Pattern TAG_SYMBOLS_PATTERN;
|
|
private static final int TAG_SYMBOLS_PERF_LIMIT = 2000;
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$1;
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$2;
|
|
|
|
static {
|
|
ApplicationCommandType.values();
|
|
int[] iArr = new int[10];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
ApplicationCommandType applicationCommandType = ApplicationCommandType.CHANNEL;
|
|
iArr[applicationCommandType.ordinal()] = 1;
|
|
ApplicationCommandType applicationCommandType2 = ApplicationCommandType.USER;
|
|
iArr[applicationCommandType2.ordinal()] = 2;
|
|
ApplicationCommandType applicationCommandType3 = ApplicationCommandType.ROLE;
|
|
iArr[applicationCommandType3.ordinal()] = 3;
|
|
ApplicationCommandType applicationCommandType4 = ApplicationCommandType.MENTIONABLE;
|
|
iArr[applicationCommandType4.ordinal()] = 4;
|
|
ApplicationCommandType applicationCommandType5 = ApplicationCommandType.BOOLEAN;
|
|
iArr[applicationCommandType5.ordinal()] = 5;
|
|
ApplicationCommandType.values();
|
|
int[] iArr2 = new int[10];
|
|
$EnumSwitchMapping$1 = iArr2;
|
|
ApplicationCommandType applicationCommandType6 = ApplicationCommandType.STRING;
|
|
iArr2[applicationCommandType6.ordinal()] = 1;
|
|
ApplicationCommandType applicationCommandType7 = ApplicationCommandType.INTEGER;
|
|
iArr2[applicationCommandType7.ordinal()] = 2;
|
|
iArr2[applicationCommandType5.ordinal()] = 3;
|
|
iArr2[applicationCommandType2.ordinal()] = 4;
|
|
iArr2[applicationCommandType.ordinal()] = 5;
|
|
iArr2[applicationCommandType3.ordinal()] = 6;
|
|
iArr2[applicationCommandType4.ordinal()] = 7;
|
|
ApplicationCommandType.values();
|
|
int[] iArr3 = new int[10];
|
|
$EnumSwitchMapping$2 = iArr3;
|
|
iArr3[ApplicationCommandType.SUBCOMMAND.ordinal()] = 1;
|
|
iArr3[ApplicationCommandType.SUBCOMMAND_GROUP.ordinal()] = 2;
|
|
iArr3[applicationCommandType6.ordinal()] = 3;
|
|
iArr3[applicationCommandType7.ordinal()] = 4;
|
|
iArr3[applicationCommandType5.ordinal()] = 5;
|
|
iArr3[applicationCommandType2.ordinal()] = 6;
|
|
iArr3[applicationCommandType.ordinal()] = 7;
|
|
iArr3[applicationCommandType3.ordinal()] = 8;
|
|
iArr3[applicationCommandType4.ordinal()] = 9;
|
|
iArr3[ApplicationCommandType.UNKNOWN.ordinal()] = 10;
|
|
}
|
|
}
|
|
|
|
static {
|
|
Pattern compile = Pattern.compile(".*(?:^|\\s)*[@#:/](.|\\n)*");
|
|
m.checkNotNullExpressionValue(compile, "Pattern.compile(\".*(?:^|\\\\s)*[@#:/](.|\\\\n)*\")");
|
|
TAG_SYMBOLS_PATTERN = compile;
|
|
}
|
|
|
|
private WidgetChatInputModelMappingFunctions() {
|
|
}
|
|
|
|
private final MentionToken asMentionToken(String str, int i, boolean z2) {
|
|
if (str != null) {
|
|
boolean z3 = true;
|
|
Character valueOf = (!(t.isBlank(str) ^ true) || !MentionUtilsKt.getDEFAULT_LEADING_IDENTIFIERS().contains(Character.valueOf(str.charAt(0)))) ? null : Character.valueOf(str.charAt(0));
|
|
if (valueOf != null || z2) {
|
|
LeadingIdentifier fromChar = LeadingIdentifier.Companion.fromChar(valueOf);
|
|
if (i != 0) {
|
|
z3 = false;
|
|
}
|
|
return new MentionToken(fromChar, str, z3);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static /* synthetic */ MentionToken asMentionToken$default(WidgetChatInputModelMappingFunctions widgetChatInputModelMappingFunctions, String str, int i, boolean z2, int i2, Object obj) {
|
|
if ((i2 & 2) != 0) {
|
|
z2 = false;
|
|
}
|
|
return widgetChatInputModelMappingFunctions.asMentionToken(str, i, z2);
|
|
}
|
|
|
|
private final boolean isBoolean(String str) {
|
|
String str2;
|
|
if (str != null) {
|
|
Locale locale = Locale.getDefault();
|
|
m.checkNotNullExpressionValue(locale, "Locale.getDefault()");
|
|
str2 = str.toLowerCase(locale);
|
|
m.checkNotNullExpressionValue(str2, "(this as java.lang.String).toLowerCase(locale)");
|
|
} else {
|
|
str2 = null;
|
|
}
|
|
return m.areEqual(str2, "true") || m.areEqual(str2, "false");
|
|
}
|
|
|
|
private final boolean isSubRangeOf(IntRange intRange, IntRange intRange2) {
|
|
return !intRange.equals(intRange2) && intRange2.contains(intRange.getFirst()) && intRange2.contains(intRange.getLast());
|
|
}
|
|
|
|
private final boolean lowerCaseContains(String str, String str2) {
|
|
Locale locale = Locale.getDefault();
|
|
m.checkNotNullExpressionValue(locale, "Locale.getDefault()");
|
|
Objects.requireNonNull(str, "null cannot be cast to non-null type java.lang.String");
|
|
String lowerCase = str.toLowerCase(locale);
|
|
m.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase(locale)");
|
|
Locale locale2 = Locale.getDefault();
|
|
m.checkNotNullExpressionValue(locale2, "Locale.getDefault()");
|
|
Objects.requireNonNull(str2, "null cannot be cast to non-null type java.lang.String");
|
|
String lowerCase2 = str2.toLowerCase(locale2);
|
|
m.checkNotNullExpressionValue(lowerCase2, "(this as java.lang.String).toLowerCase(locale)");
|
|
return w.contains$default((CharSequence) lowerCase, (CharSequence) lowerCase2, false, 2, (Object) null);
|
|
}
|
|
|
|
public final Map<LeadingIdentifier, List<Autocompletable>> filterMentionsForCommandContext(InputSelectionModel inputSelectionModel) {
|
|
List list;
|
|
m.checkNotNullParameter(inputSelectionModel, "modelChat");
|
|
List flatten = o.flatten(inputSelectionModel.getInputModel().getAutocompletables().values());
|
|
if (inputSelectionModel.getInputModel().getInputCommandContext().isCommand()) {
|
|
ApplicationCommandOption selectedCommandOption = inputSelectionModel.getSelectedCommandOption();
|
|
if (selectedCommandOption != null) {
|
|
List<CommandChoice> choices = selectedCommandOption.getChoices();
|
|
if (choices == null || !(!choices.isEmpty())) {
|
|
switch (selectedCommandOption.getType().ordinal()) {
|
|
case 4:
|
|
list = ApplicationCommandsAutocompletableSource.Companion.createFromCommandOption(selectedCommandOption);
|
|
break;
|
|
case 5:
|
|
list = new ArrayList();
|
|
for (Object obj : flatten) {
|
|
if (obj instanceof UserAutocompletable) {
|
|
list.add(obj);
|
|
}
|
|
}
|
|
break;
|
|
case 6:
|
|
list = new ArrayList();
|
|
for (Object obj2 : flatten) {
|
|
if (obj2 instanceof ChannelAutocompletable) {
|
|
list.add(obj2);
|
|
}
|
|
}
|
|
break;
|
|
case 7:
|
|
list = new ArrayList();
|
|
for (Object obj3 : flatten) {
|
|
if (obj3 instanceof RoleAutocompletable) {
|
|
list.add(obj3);
|
|
}
|
|
}
|
|
break;
|
|
case 8:
|
|
list = new ArrayList();
|
|
for (Object obj4 : flatten) {
|
|
Autocompletable autocompletable = (Autocompletable) obj4;
|
|
if ((autocompletable instanceof UserAutocompletable) || (autocompletable instanceof RoleAutocompletable)) {
|
|
list.add(obj4);
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
List plus = u.plus((Collection) ApplicationCommandsAutocompletableSource.Companion.createFromCommandOption(selectedCommandOption), (Iterable) flatten);
|
|
List arrayList = new ArrayList();
|
|
for (Object obj5 : plus) {
|
|
Autocompletable autocompletable2 = (Autocompletable) obj5;
|
|
if (autocompletable2 instanceof ChannelAutocompletable ? AnimatableValueParser.k1(((ChannelAutocompletable) autocompletable2).getChannel()) : autocompletable2 instanceof UserAutocompletable ? ((UserAutocompletable) autocompletable2).getCanUserReadChannel() : !(autocompletable2 instanceof ApplicationCommandAutocompletable)) {
|
|
arrayList.add(obj5);
|
|
}
|
|
}
|
|
list = arrayList;
|
|
break;
|
|
}
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
|
for (Object obj6 : list) {
|
|
LeadingIdentifier leadingIdentifier = ((Autocompletable) obj6).leadingIdentifier();
|
|
Object obj7 = linkedHashMap.get(leadingIdentifier);
|
|
if (obj7 == null) {
|
|
obj7 = new ArrayList();
|
|
linkedHashMap.put(leadingIdentifier, obj7);
|
|
}
|
|
((List) obj7).add(obj6);
|
|
}
|
|
return linkedHashMap;
|
|
}
|
|
List<Autocompletable> createFromCommandOption = ApplicationCommandsAutocompletableSource.Companion.createFromCommandOption(selectedCommandOption);
|
|
LinkedHashMap linkedHashMap2 = new LinkedHashMap();
|
|
for (Object obj8 : createFromCommandOption) {
|
|
LeadingIdentifier leadingIdentifier2 = ((Autocompletable) obj8).leadingIdentifier();
|
|
Object obj9 = linkedHashMap2.get(leadingIdentifier2);
|
|
if (obj9 == null) {
|
|
obj9 = new ArrayList();
|
|
linkedHashMap2.put(leadingIdentifier2, obj9);
|
|
}
|
|
((List) obj9).add(obj8);
|
|
}
|
|
return linkedHashMap2;
|
|
}
|
|
ArrayList arrayList2 = new ArrayList();
|
|
for (Object obj10 : flatten) {
|
|
if (!(((Autocompletable) obj10) instanceof ApplicationCommandAutocompletable)) {
|
|
arrayList2.add(obj10);
|
|
}
|
|
}
|
|
LinkedHashMap linkedHashMap3 = new LinkedHashMap();
|
|
for (Object obj11 : arrayList2) {
|
|
LeadingIdentifier leadingIdentifier3 = ((Autocompletable) obj11).leadingIdentifier();
|
|
Object obj12 = linkedHashMap3.get(leadingIdentifier3);
|
|
if (obj12 == null) {
|
|
obj12 = new ArrayList();
|
|
linkedHashMap3.put(leadingIdentifier3, obj12);
|
|
}
|
|
((List) obj12).add(obj11);
|
|
}
|
|
return linkedHashMap3;
|
|
}
|
|
ArrayList arrayList3 = new ArrayList();
|
|
for (Object obj13 : flatten) {
|
|
Autocompletable autocompletable3 = (Autocompletable) obj13;
|
|
if (autocompletable3 instanceof ChannelAutocompletable ? AnimatableValueParser.k1(((ChannelAutocompletable) autocompletable3).getChannel()) : autocompletable3 instanceof UserAutocompletable ? ((UserAutocompletable) autocompletable3).getCanUserReadChannel() : true) {
|
|
arrayList3.add(obj13);
|
|
}
|
|
}
|
|
LinkedHashMap linkedHashMap4 = new LinkedHashMap();
|
|
for (Object obj14 : arrayList3) {
|
|
LeadingIdentifier leadingIdentifier4 = ((Autocompletable) obj14).leadingIdentifier();
|
|
Object obj15 = linkedHashMap4.get(leadingIdentifier4);
|
|
if (obj15 == null) {
|
|
obj15 = new ArrayList();
|
|
linkedHashMap4.put(leadingIdentifier4, obj15);
|
|
}
|
|
((List) obj15).add(obj14);
|
|
}
|
|
return linkedHashMap4;
|
|
}
|
|
|
|
public final List<Autocompletable> filterMentionsFromToken(MentionToken mentionToken, InputSelectionModel inputSelectionModel, Map<LeadingIdentifier, ? extends List<? extends Autocompletable>> map) {
|
|
ArrayList arrayList;
|
|
m.checkNotNullParameter(mentionToken, "token");
|
|
m.checkNotNullParameter(inputSelectionModel, "inputSelectionModel");
|
|
m.checkNotNullParameter(map, "mentions");
|
|
boolean z2 = t.isBlank(mentionToken.getFormattedToken()) && mentionToken.getLeadingIdentifier() == LeadingIdentifier.NONE;
|
|
String formattedToken = mentionToken.getFormattedToken();
|
|
Locale locale = Locale.getDefault();
|
|
m.checkNotNullExpressionValue(locale, "Locale.getDefault()");
|
|
Objects.requireNonNull(formattedToken, "null cannot be cast to non-null type java.lang.String");
|
|
String lowerCase = formattedToken.toLowerCase(locale);
|
|
m.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase(locale)");
|
|
String replace$default = t.replace$default(StringUtilsKt.stripAccents(lowerCase), " ", "", false, 4, (Object) null);
|
|
if (z2 && inputSelectionModel.hasSelectedOptionWithChoices()) {
|
|
List list = (List) map.get(LeadingIdentifier.NONE);
|
|
if (list != null) {
|
|
arrayList = new ArrayList();
|
|
for (Object obj : list) {
|
|
if (obj instanceof ApplicationCommandChoiceAutocompletable) {
|
|
arrayList.add(obj);
|
|
}
|
|
}
|
|
} else {
|
|
arrayList = null;
|
|
}
|
|
return arrayList != null ? arrayList : n.emptyList();
|
|
} else if (z2) {
|
|
return n.emptyList();
|
|
} else {
|
|
ArrayList arrayList2 = new ArrayList();
|
|
List<Autocompletable> list2 = (List) map.get(mentionToken.getLeadingIdentifier());
|
|
if (list2 != null) {
|
|
for (Autocompletable autocompletable : list2) {
|
|
Iterator<String> iterateAutocompleteMatchers = autocompletable.iterateAutocompleteMatchers();
|
|
while (true) {
|
|
if (!iterateAutocompleteMatchers.hasNext()) {
|
|
break;
|
|
}
|
|
String next = iterateAutocompleteMatchers.next();
|
|
Locale locale2 = Locale.getDefault();
|
|
m.checkNotNullExpressionValue(locale2, "Locale.getDefault()");
|
|
Objects.requireNonNull(next, "null cannot be cast to non-null type java.lang.String");
|
|
String lowerCase2 = next.toLowerCase(locale2);
|
|
m.checkNotNullExpressionValue(lowerCase2, "(this as java.lang.String).toLowerCase(locale)");
|
|
if (INSTANCE.lowerCaseContains(t.replace$default(StringUtilsKt.stripAccents(lowerCase2), " ", "", false, 4, (Object) null), replace$default)) {
|
|
arrayList2.add(autocompletable);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return arrayList2;
|
|
}
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:103:0x006e A[EDGE_INSN: B:103:0x006e->B:21:0x006e ?: BREAK , SYNTHETIC] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:74:0x020a */
|
|
public final ApplicationCommandData getApplicationSendData(AutocompleteInputSelectionModel autocompleteInputSelectionModel, List<? extends ApplicationCommand> list) {
|
|
InputSelectionModel inputSelectionModel;
|
|
VerifiedCommandMentionInputModel inputModel;
|
|
Object obj;
|
|
OptionRange optionRange;
|
|
IntRange value;
|
|
boolean z2;
|
|
Object obj2;
|
|
boolean z3;
|
|
m.checkNotNullParameter(list, "queryCommands");
|
|
if (autocompleteInputSelectionModel == null || (inputSelectionModel = autocompleteInputSelectionModel.getInputSelectionModel()) == null || (inputModel = inputSelectionModel.getInputModel()) == null) {
|
|
return null;
|
|
}
|
|
ApplicationCommand selectedCommand = inputModel.getInputCommandContext().getSelectedCommand();
|
|
if (selectedCommand == null) {
|
|
Iterator<T> it = list.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
obj2 = null;
|
|
break;
|
|
}
|
|
obj2 = it.next();
|
|
ApplicationCommand applicationCommand = (ApplicationCommand) obj2;
|
|
String input = autocompleteInputSelectionModel.getInputSelectionModel().getInputModel().getInput();
|
|
if (!t.isBlank(input)) {
|
|
String name = applicationCommand.getName();
|
|
Objects.requireNonNull(input, "null cannot be cast to non-null type java.lang.String");
|
|
String substring = input.substring(1);
|
|
m.checkNotNullExpressionValue(substring, "(this as java.lang.String).substring(startIndex)");
|
|
if (m.areEqual(name, substring) && input.charAt(0) == '/') {
|
|
z3 = true;
|
|
continue;
|
|
if (z3) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
z3 = false;
|
|
continue;
|
|
if (z3) {
|
|
}
|
|
}
|
|
selectedCommand = (ApplicationCommand) obj2;
|
|
}
|
|
if (selectedCommand == null) {
|
|
return null;
|
|
}
|
|
Iterator<T> it2 = inputModel.getCommands().getApplications().iterator();
|
|
while (true) {
|
|
if (!it2.hasNext()) {
|
|
obj = null;
|
|
break;
|
|
}
|
|
obj = it2.next();
|
|
if (((Application) obj).getId() == selectedCommand.getApplicationId()) {
|
|
z2 = true;
|
|
continue;
|
|
} else {
|
|
z2 = false;
|
|
continue;
|
|
}
|
|
if (z2) {
|
|
break;
|
|
}
|
|
}
|
|
Application application = (Application) obj;
|
|
if (application == null) {
|
|
return null;
|
|
}
|
|
Map<ApplicationCommandOption, CommandOptionValue> values = inputModel.getInputCommandOptions().getValues();
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap(g0.mapCapacity(values.size()));
|
|
Iterator<T> it3 = values.entrySet().iterator();
|
|
while (it3.hasNext()) {
|
|
linkedHashMap.put(((Map.Entry) it3.next()).getKey(), "");
|
|
}
|
|
Map<ApplicationCommandOption, CommandOptionValue> values2 = inputModel.getInputCommandOptions().getValues();
|
|
LinkedHashMap linkedHashMap2 = new LinkedHashMap(g0.mapCapacity(values2.size()));
|
|
Iterator<T> it4 = values2.entrySet().iterator();
|
|
while (it4.hasNext()) {
|
|
Map.Entry entry = (Map.Entry) it4.next();
|
|
Object key = entry.getKey();
|
|
Object value2 = ((CommandOptionValue) entry.getValue()).getValue();
|
|
if (entry.getValue() instanceof StringOptionValue) {
|
|
List<CommandChoice> choices = ((ApplicationCommandOption) entry.getKey()).getChoices();
|
|
if (!(!(choices == null || choices.isEmpty()) || (optionRange = inputModel.getInputCommandOptions().getInputRanges().get(entry.getKey())) == null || (value = optionRange.getValue()) == null)) {
|
|
int first = value.getFirst();
|
|
String obj3 = ((CommandOptionValue) entry.getValue()).getValue().toString();
|
|
Map<IntRange, Autocompletable> inputMentionsMap = inputModel.getInputMentionsMap();
|
|
LinkedHashMap linkedHashMap3 = new LinkedHashMap(g0.mapCapacity(inputMentionsMap.size()));
|
|
Iterator<T> it5 = inputMentionsMap.entrySet().iterator();
|
|
while (it5.hasNext()) {
|
|
Map.Entry entry2 = (Map.Entry) it5.next();
|
|
linkedHashMap3.put(new IntRange(((IntRange) entry2.getKey()).getFirst() - first, ((IntRange) entry2.getKey()).getLast() - first), entry2.getValue());
|
|
}
|
|
LinkedHashMap linkedHashMap4 = new LinkedHashMap();
|
|
for (Map.Entry entry3 : linkedHashMap3.entrySet()) {
|
|
if (((IntRange) entry3.getKey()).getFirst() >= 0 && ((IntRange) entry3.getKey()).getLast() <= obj3.length()) {
|
|
linkedHashMap4.put(entry3.getKey(), entry3.getValue());
|
|
}
|
|
}
|
|
value2 = INSTANCE.replaceAutocompleteDataWithServerValues(obj3, linkedHashMap4);
|
|
}
|
|
}
|
|
linkedHashMap2.put(key, value2);
|
|
}
|
|
Map<ApplicationCommandOption, Boolean> commandOptionValidity = inputModel.getInputCommandOptions().getCommandOptionValidity();
|
|
for (ApplicationCommandOption applicationCommandOption : selectedCommand.getOptions()) {
|
|
if ((applicationCommandOption.getRequired() && linkedHashMap2.get(applicationCommandOption) == null) || m.areEqual(commandOptionValidity.get(applicationCommandOption), Boolean.FALSE)) {
|
|
return new ApplicationCommandData(application, selectedCommand, n.emptyList(), false);
|
|
}
|
|
while (r2.hasNext()) {
|
|
}
|
|
}
|
|
if (selectedCommand instanceof ApplicationSubCommand) {
|
|
Set<ApplicationCommandOption> keySet = linkedHashMap2.keySet();
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(keySet, 10));
|
|
for (ApplicationCommandOption applicationCommandOption2 : keySet) {
|
|
Object obj4 = linkedHashMap2.get(applicationCommandOption2);
|
|
if (obj4 == null) {
|
|
return null;
|
|
}
|
|
arrayList.add(new ApplicationCommandValue(applicationCommandOption2.getName(), obj4, applicationCommandOption2.getType().getType(), null, 8, null));
|
|
}
|
|
ApplicationSubCommand applicationSubCommand = (ApplicationSubCommand) selectedCommand;
|
|
ApplicationCommandValue applicationCommandValue = new ApplicationCommandValue(applicationSubCommand.getSubCommandName(), null, ApplicationCommandType.SUBCOMMAND.getType(), arrayList, 2, null);
|
|
return applicationSubCommand.getParentGroupName() != null ? new ApplicationCommandData(application, applicationSubCommand.getRootCommand(), d0.t.m.listOf(new ApplicationCommandValue(applicationSubCommand.getParentGroupName(), null, ApplicationCommandType.SUBCOMMAND_GROUP.getType(), d0.t.m.listOf(applicationCommandValue), 2, null)), true) : new ApplicationCommandData(application, applicationSubCommand.getRootCommand(), d0.t.m.listOf(applicationCommandValue), true);
|
|
}
|
|
Set<ApplicationCommandOption> keySet2 = linkedHashMap2.keySet();
|
|
ArrayList arrayList2 = new ArrayList(o.collectionSizeOrDefault(keySet2, 10));
|
|
for (ApplicationCommandOption applicationCommandOption3 : keySet2) {
|
|
Object obj5 = linkedHashMap2.get(applicationCommandOption3);
|
|
if (obj5 == null) {
|
|
return null;
|
|
}
|
|
arrayList2.add(new ApplicationCommandValue(applicationCommandOption3.getName(), obj5, applicationCommandOption3.getType().getType(), null, 8, null));
|
|
}
|
|
return new ApplicationCommandData(application, selectedCommand, arrayList2, true);
|
|
}
|
|
|
|
public final Set<ApplicationCommandOption> getErrorsToShowForCommandParameters(ApplicationCommand applicationCommand, ApplicationCommandOption applicationCommandOption, ApplicationCommandOption applicationCommandOption2, Map<ApplicationCommandOption, Boolean> map, Map<ApplicationCommandOption, ? extends CommandOptionValue> map2) {
|
|
m.checkNotNullParameter(map, "validMap");
|
|
m.checkNotNullParameter(map2, "parsedCommandOptions");
|
|
LinkedHashSet linkedHashSet = new LinkedHashSet();
|
|
if (applicationCommand == null) {
|
|
return n0.emptySet();
|
|
}
|
|
for (ApplicationCommandOption applicationCommandOption3 : applicationCommand.getOptions()) {
|
|
if (map2.containsKey(applicationCommandOption3)) {
|
|
CommandOptionValue commandOptionValue = (CommandOptionValue) map2.get(applicationCommandOption3);
|
|
String valueOf = String.valueOf(commandOptionValue != null ? commandOptionValue.getValue() : null);
|
|
boolean z2 = false;
|
|
boolean z3 = t.isBlank(valueOf) || (valueOf.length() == 1 && MentionUtilsKt.getDEFAULT_LEADING_IDENTIFIERS().contains(Character.valueOf(valueOf.charAt(0))));
|
|
boolean areEqual = m.areEqual(applicationCommandOption, applicationCommandOption3);
|
|
boolean z4 = applicationCommandOption2 != null && m.areEqual(applicationCommandOption2, applicationCommandOption3);
|
|
boolean containsKey = map2.containsKey(applicationCommandOption3);
|
|
boolean z5 = (areEqual && z4) || (areEqual && z3);
|
|
if (m.areEqual(map.get(applicationCommandOption3), Boolean.FALSE) && !z5 && containsKey) {
|
|
z2 = true;
|
|
}
|
|
if (z2) {
|
|
linkedHashSet.add(applicationCommandOption3);
|
|
}
|
|
}
|
|
}
|
|
return linkedHashSet;
|
|
}
|
|
|
|
/* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */
|
|
/* JADX WARNING: Code restructure failed: missing block: B:28:0x008a, code lost:
|
|
if ((r2 instanceof com.discord.widgets.chat.input.models.SnowflakeOptionValue) == false) goto L_0x00c2;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:32:0x0093, code lost:
|
|
if ((r2 instanceof com.discord.widgets.chat.input.models.SnowflakeOptionValue) == false) goto L_0x00c2;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:36:0x009c, code lost:
|
|
if ((r2 instanceof com.discord.widgets.chat.input.models.SnowflakeOptionValue) == false) goto L_0x00c2;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:40:0x00a5, code lost:
|
|
if ((r2 instanceof com.discord.widgets.chat.input.models.SnowflakeOptionValue) == false) goto L_0x00c2;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:46:0x00bf, code lost:
|
|
if ((!d0.g0.t.isBlank(r2.getValue().toString())) != false) goto L_0x007e;
|
|
*/
|
|
public final Map<ApplicationCommandOption, Boolean> getInputValidity(ApplicationCommand applicationCommand, Map<ApplicationCommandOption, ? extends CommandOptionValue> map) {
|
|
m.checkNotNullParameter(applicationCommand, "selectedCommand");
|
|
m.checkNotNullParameter(map, "parsedCommandOptions");
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
|
for (ApplicationCommandOption applicationCommandOption : applicationCommand.getOptions()) {
|
|
CommandOptionValue commandOptionValue = (CommandOptionValue) map.get(applicationCommandOption);
|
|
if (commandOptionValue != null) {
|
|
List<CommandChoice> choices = applicationCommandOption.getChoices();
|
|
boolean z2 = false;
|
|
if (choices == null || !(!choices.isEmpty())) {
|
|
switch (applicationCommandOption.getType().ordinal()) {
|
|
case 0:
|
|
case 1:
|
|
break;
|
|
case 2:
|
|
if (commandOptionValue instanceof StringOptionValue) {
|
|
break;
|
|
}
|
|
break;
|
|
case 3:
|
|
z2 = commandOptionValue instanceof IntegerOptionValue;
|
|
break;
|
|
case 4:
|
|
z2 = commandOptionValue instanceof BooleanOptionValue;
|
|
break;
|
|
case 5:
|
|
if (!(commandOptionValue instanceof UserOptionValue)) {
|
|
break;
|
|
}
|
|
break;
|
|
case 6:
|
|
if (!(commandOptionValue instanceof ChannelOptionValue)) {
|
|
break;
|
|
}
|
|
break;
|
|
case 7:
|
|
if (!(commandOptionValue instanceof RoleOptionValue)) {
|
|
break;
|
|
}
|
|
break;
|
|
case 8:
|
|
if (!(commandOptionValue instanceof UserOptionValue)) {
|
|
if (!(commandOptionValue instanceof RoleOptionValue)) {
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
case 9:
|
|
break;
|
|
default:
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
linkedHashMap.put(applicationCommandOption, Boolean.valueOf(z2));
|
|
} else {
|
|
List<CommandChoice> choices2 = applicationCommandOption.getChoices();
|
|
if (!(choices2 instanceof Collection) || !choices2.isEmpty()) {
|
|
Iterator<T> it = choices2.iterator();
|
|
while (true) {
|
|
if (it.hasNext()) {
|
|
if (m.areEqual(((CommandChoice) it.next()).b(), commandOptionValue.getValue().toString())) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
linkedHashMap.put(applicationCommandOption, Boolean.valueOf(z2));
|
|
}
|
|
z2 = true;
|
|
linkedHashMap.put(applicationCommandOption, Boolean.valueOf(z2));
|
|
} else if (applicationCommandOption.getRequired()) {
|
|
linkedHashMap.put(applicationCommandOption, Boolean.FALSE);
|
|
}
|
|
}
|
|
return linkedHashMap;
|
|
}
|
|
|
|
public final MentionToken getMentionAutoCompleteToken(String str, IntRange intRange, ApplicationCommandOption applicationCommandOption, boolean z2, InputCommandOptions inputCommandOptions) {
|
|
int i;
|
|
String str2;
|
|
m.checkNotNullParameter(str, "input");
|
|
m.checkNotNullParameter(intRange, "selection");
|
|
m.checkNotNullParameter(inputCommandOptions, "inputCommandOptions");
|
|
Pair<String, Integer> selectedToken = MentionUtilsKt.getSelectedToken(str, intRange.getFirst());
|
|
String component1 = selectedToken.component1();
|
|
int intValue = selectedToken.component2().intValue();
|
|
if (applicationCommandOption != null) {
|
|
IntRange intRange2 = null;
|
|
if (component1 != null) {
|
|
component1 = w.removePrefix(component1, applicationCommandOption.getName() + ":");
|
|
} else {
|
|
component1 = null;
|
|
}
|
|
if (!z2) {
|
|
OptionRange optionRange = inputCommandOptions.getInputRanges().get(applicationCommandOption);
|
|
if (optionRange != null) {
|
|
intRange2 = optionRange.getValue();
|
|
}
|
|
CommandOptionValue commandOptionValue = inputCommandOptions.getValues().get(applicationCommandOption);
|
|
if (!(intRange2 == null || commandOptionValue == null || intRange.getFirst() <= intRange2.getFirst())) {
|
|
String obj = commandOptionValue.getValue().toString();
|
|
int min = Math.min(intRange.getFirst() - intRange2.getFirst(), commandOptionValue.getValue().toString().length());
|
|
Objects.requireNonNull(obj, "null cannot be cast to non-null type java.lang.String");
|
|
component1 = obj.substring(0, min);
|
|
m.checkNotNullExpressionValue(component1, "(this as java.lang.Strin…ing(startIndex, endIndex)");
|
|
}
|
|
WidgetChatInputModelMappingFunctions widgetChatInputModelMappingFunctions = INSTANCE;
|
|
if (component1 == null) {
|
|
component1 = "";
|
|
}
|
|
return widgetChatInputModelMappingFunctions.asMentionToken(component1, intValue, true);
|
|
}
|
|
MentionToken asMentionToken$default = asMentionToken$default(INSTANCE, component1, intValue, false, 2, null);
|
|
if (asMentionToken$default != null) {
|
|
return asMentionToken$default;
|
|
}
|
|
}
|
|
Pattern compile = Pattern.compile("^(/([a-zA-Z0-9_-]+\\s*){1,3})(.|\\n)*");
|
|
m.checkNotNullExpressionValue(compile, "Pattern.compile(\"^(/([a-…_-]+\\\\s*){1,3})(.|\\\\n)*\")");
|
|
Matcher matcher = compile.matcher(str);
|
|
if (matcher.matches()) {
|
|
str2 = matcher.group(0);
|
|
i = 0;
|
|
} else {
|
|
i = intValue;
|
|
str2 = component1;
|
|
}
|
|
return asMentionToken$default(this, str2, i, false, 2, null);
|
|
}
|
|
|
|
public final ApplicationCommand getSelectedCommand(List<? extends ApplicationCommand> list, String str, String str2, UserAndSelectedGuildRoles userAndSelectedGuildRoles) {
|
|
boolean z2;
|
|
m.checkNotNullParameter(list, "commands");
|
|
m.checkNotNullParameter(str, "prefix");
|
|
m.checkNotNullParameter(str2, "input");
|
|
m.checkNotNullParameter(userAndSelectedGuildRoles, "userAndRoles");
|
|
Object obj = null;
|
|
if (!(str.length() > 0)) {
|
|
return null;
|
|
}
|
|
Iterator<T> it = list.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
Object next = it.next();
|
|
ApplicationCommand applicationCommand = (ApplicationCommand) next;
|
|
StringBuilder sb = new StringBuilder();
|
|
String name = applicationCommand.getName();
|
|
sb.append(String.valueOf('/') + name);
|
|
sb.append(' ');
|
|
if (!t.startsWith$default(str2, sb.toString(), false, 2, null) || !WidgetChatInputModelMappingFunctionsKt.hasPermission(applicationCommand, userAndSelectedGuildRoles)) {
|
|
z2 = false;
|
|
continue;
|
|
} else {
|
|
z2 = true;
|
|
continue;
|
|
}
|
|
if (z2) {
|
|
obj = next;
|
|
break;
|
|
}
|
|
}
|
|
return (ApplicationCommand) obj;
|
|
}
|
|
|
|
public final ApplicationCommandOption getSelectedOption(int i, Map<ApplicationCommandOption, OptionRange> map) {
|
|
Set<ApplicationCommandOption> keySet;
|
|
if (map == null || (keySet = map.keySet()) == null) {
|
|
return null;
|
|
}
|
|
for (ApplicationCommandOption applicationCommandOption : keySet) {
|
|
OptionRange optionRange = map.get(applicationCommandOption);
|
|
if (optionRange != null && optionRange.getParam().getFirst() < i && optionRange.getValue().getLast() >= i) {
|
|
return applicationCommandOption;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public final List<Sticker> getStickerMatches(MentionToken mentionToken) {
|
|
if (StickerPickerFeatureFlag.Companion.getINSTANCE().isEnabled()) {
|
|
if ((mentionToken != null ? mentionToken.getLeadingIdentifier() : null) == LeadingIdentifier.EMOJI_AND_STICKERS) {
|
|
String token = mentionToken.getToken();
|
|
StringBuilder sb = new StringBuilder();
|
|
int length = token.length();
|
|
for (int i = 0; i < length; i++) {
|
|
char charAt = token.charAt(i);
|
|
if (Character.isLetterOrDigit(charAt)) {
|
|
sb.append(charAt);
|
|
}
|
|
}
|
|
String sb2 = sb.toString();
|
|
m.checkNotNullExpressionValue(sb2, "filterTo(StringBuilder(), predicate).toString()");
|
|
if (sb2.length() - 1 >= 3) {
|
|
StickerUtils stickerUtils = StickerUtils.INSTANCE;
|
|
return u.toList(stickerUtils.findStickerMatches(t.replace(mentionToken.getToken(), mentionToken.getLeadingIdentifier().toString(), "", true), StickerUtils.getStickersForAutocomplete$default(stickerUtils, null, null, null, null, null, 31, null), true));
|
|
}
|
|
}
|
|
}
|
|
return n.emptyList();
|
|
}
|
|
|
|
public final ChatInputMentionsMap mapInputToMentions(String str, Map<LeadingIdentifier, ? extends Set<? extends Autocompletable>> map, boolean z2) {
|
|
boolean z3;
|
|
m.checkNotNullParameter(str, "input");
|
|
m.checkNotNullParameter(map, "autocompletables");
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
|
List<Autocompletable> flatten = o.flatten(map.values());
|
|
if (!(map.size() <= 2000 || z2 || TAG_SYMBOLS_PATTERN.matcher(str).matches())) {
|
|
return new ChatInputMentionsMap(str, h0.emptyMap());
|
|
}
|
|
for (Autocompletable autocompletable : flatten) {
|
|
Iterator<String> iterateTextMatchers = autocompletable.iterateTextMatchers();
|
|
while (iterateTextMatchers.hasNext()) {
|
|
String next = iterateTextMatchers.next();
|
|
int indexOf$default = w.indexOf$default((CharSequence) str, next, 0, false, 4, (Object) null);
|
|
while (indexOf$default != -1) {
|
|
IntRange intRange = new IntRange(indexOf$default, next.length() + indexOf$default);
|
|
if (linkedHashMap.isEmpty()) {
|
|
linkedHashMap.put(intRange, autocompletable);
|
|
} else {
|
|
Iterator it = linkedHashMap.entrySet().iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
z3 = true;
|
|
break;
|
|
}
|
|
Map.Entry entry = (Map.Entry) it.next();
|
|
IntRange intRange2 = (IntRange) entry.getKey();
|
|
Autocompletable autocompletable2 = (Autocompletable) entry.getValue();
|
|
if (!m.areEqual(intRange, intRange2) || !(autocompletable instanceof RoleAutocompletable) || (autocompletable2 instanceof RoleAutocompletable)) {
|
|
WidgetChatInputModelMappingFunctions widgetChatInputModelMappingFunctions = INSTANCE;
|
|
if (!widgetChatInputModelMappingFunctions.isSubRangeOf(intRange2, intRange)) {
|
|
if (m.areEqual(intRange, intRange2) || widgetChatInputModelMappingFunctions.isSubRangeOf(intRange, intRange2)) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
it.remove();
|
|
}
|
|
z3 = false;
|
|
if (z3) {
|
|
linkedHashMap.put(intRange, autocompletable);
|
|
}
|
|
}
|
|
indexOf$default = w.indexOf$default((CharSequence) str, next, indexOf$default + 1, false, 4, (Object) null);
|
|
}
|
|
}
|
|
}
|
|
return new ChatInputMentionsMap(str, linkedHashMap);
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:20:0x00b8, code lost:
|
|
if (r3 != null) goto L_0x00bc;
|
|
*/
|
|
public final Map<ApplicationCommandOption, CommandOptionValue> parseCommandOptions(String str, ApplicationCommand applicationCommand, ChatInputMentionsMap chatInputMentionsMap) {
|
|
CommandOptionValue commandOptionValue;
|
|
Object obj;
|
|
String str2;
|
|
CommandOptionValue booleanOptionValue;
|
|
Object obj2;
|
|
m.checkNotNullParameter(str, "input");
|
|
m.checkNotNullParameter(applicationCommand, "command");
|
|
m.checkNotNullParameter(chatInputMentionsMap, "mentionMap");
|
|
Map<ApplicationCommandOption, OptionRange> findOptionRanges = WidgetChatInputApplicationCommandsKt.findOptionRanges(str, applicationCommand);
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
|
for (Map.Entry<ApplicationCommandOption, OptionRange> entry : findOptionRanges.entrySet()) {
|
|
ApplicationCommandOption key = entry.getKey();
|
|
OptionRange value = entry.getValue();
|
|
String substring = str.substring(value.getValue().getFirst(), value.getValue().getLast());
|
|
m.checkNotNullExpressionValue(substring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
|
|
Objects.requireNonNull(substring, "null cannot be cast to non-null type kotlin.CharSequence");
|
|
String obj3 = w.trim(substring).toString();
|
|
Iterator<T> it = chatInputMentionsMap.getMentions().values().iterator();
|
|
while (true) {
|
|
commandOptionValue = null;
|
|
if (it.hasNext()) {
|
|
obj = it.next();
|
|
if (((Autocompletable) obj).matchesText(obj3)) {
|
|
}
|
|
} else {
|
|
obj = null;
|
|
}
|
|
}
|
|
Autocompletable autocompletable = (Autocompletable) obj;
|
|
List<CommandChoice> choices = key.getChoices();
|
|
if (choices != null) {
|
|
Iterator<T> it2 = choices.iterator();
|
|
while (true) {
|
|
if (it2.hasNext()) {
|
|
obj2 = it2.next();
|
|
String a = ((CommandChoice) obj2).a();
|
|
Objects.requireNonNull(a, "null cannot be cast to non-null type kotlin.CharSequence");
|
|
if (m.areEqual(w.trim(a).toString(), obj3)) {
|
|
}
|
|
} else {
|
|
obj2 = null;
|
|
}
|
|
}
|
|
CommandChoice commandChoice = (CommandChoice) obj2;
|
|
if (commandChoice != null) {
|
|
str2 = commandChoice.b();
|
|
}
|
|
}
|
|
str2 = substring;
|
|
switch (key.getType().ordinal()) {
|
|
case 2:
|
|
commandOptionValue = new StringOptionValue(str2);
|
|
break;
|
|
case 3:
|
|
Integer intOrNull = s.toIntOrNull(obj3);
|
|
if (intOrNull != null) {
|
|
commandOptionValue = new IntegerOptionValue(intOrNull.intValue());
|
|
break;
|
|
}
|
|
break;
|
|
case 4:
|
|
if (isBoolean(obj3)) {
|
|
booleanOptionValue = new BooleanOptionValue(Boolean.parseBoolean(obj3));
|
|
commandOptionValue = booleanOptionValue;
|
|
break;
|
|
}
|
|
break;
|
|
case 5:
|
|
if (!(autocompletable instanceof UserAutocompletable)) {
|
|
autocompletable = null;
|
|
}
|
|
UserAutocompletable userAutocompletable = (UserAutocompletable) autocompletable;
|
|
if (userAutocompletable != null) {
|
|
booleanOptionValue = new UserOptionValue(userAutocompletable.getUser());
|
|
commandOptionValue = booleanOptionValue;
|
|
break;
|
|
}
|
|
break;
|
|
case 6:
|
|
if (!(autocompletable instanceof ChannelAutocompletable)) {
|
|
autocompletable = null;
|
|
}
|
|
ChannelAutocompletable channelAutocompletable = (ChannelAutocompletable) autocompletable;
|
|
if (channelAutocompletable != null) {
|
|
booleanOptionValue = new ChannelOptionValue(channelAutocompletable.getChannel());
|
|
commandOptionValue = booleanOptionValue;
|
|
break;
|
|
}
|
|
break;
|
|
case 7:
|
|
if (!(autocompletable instanceof RoleAutocompletable)) {
|
|
autocompletable = null;
|
|
}
|
|
RoleAutocompletable roleAutocompletable = (RoleAutocompletable) autocompletable;
|
|
if (roleAutocompletable != null) {
|
|
booleanOptionValue = new RoleOptionValue(roleAutocompletable.getRole());
|
|
commandOptionValue = booleanOptionValue;
|
|
break;
|
|
}
|
|
break;
|
|
case 8:
|
|
if (!(autocompletable instanceof RoleAutocompletable)) {
|
|
if (autocompletable instanceof UserAutocompletable) {
|
|
commandOptionValue = new UserOptionValue(((UserAutocompletable) autocompletable).getUser());
|
|
break;
|
|
}
|
|
} else {
|
|
commandOptionValue = new RoleOptionValue(((RoleAutocompletable) autocompletable).getRole());
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
if (commandOptionValue != null) {
|
|
linkedHashMap.put(key, commandOptionValue);
|
|
} else {
|
|
Long snowflake = toSnowflake(obj3);
|
|
if (snowflake != null) {
|
|
linkedHashMap.put(key, new SnowflakeOptionValue(snowflake.longValue()));
|
|
} else {
|
|
linkedHashMap.put(key, new RawOptionValue(substring));
|
|
}
|
|
}
|
|
}
|
|
return linkedHashMap;
|
|
}
|
|
|
|
public final String replaceAutocompleteDataWithServerValues(String str, Map<IntRange, ? extends Autocompletable> map) {
|
|
m.checkNotNullParameter(str, "$this$replaceAutocompleteDataWithServerValues");
|
|
m.checkNotNullParameter(map, "inputMentionsMap");
|
|
for (IntRange intRange : u.sortedWith(map.keySet(), new WidgetChatInputModelMappingFunctions$replaceAutocompleteDataWithServerValues$$inlined$sortedByDescending$1())) {
|
|
Autocompletable autocompletable = (Autocompletable) map.get(intRange);
|
|
if (autocompletable != null) {
|
|
int first = intRange.getFirst();
|
|
int last = intRange.getLast();
|
|
String inputReplacement = autocompletable.getInputReplacement();
|
|
Objects.requireNonNull(str, "null cannot be cast to non-null type kotlin.CharSequence");
|
|
str = w.replaceRange(str, first, last, inputReplacement).toString();
|
|
}
|
|
}
|
|
return str;
|
|
}
|
|
|
|
public final Long toSnowflake(String str) {
|
|
m.checkNotNullParameter(str, "text");
|
|
Long longOrNull = s.toLongOrNull(str);
|
|
if (longOrNull == null || longOrNull.longValue() <= 1420070400000L) {
|
|
return null;
|
|
}
|
|
return longOrNull;
|
|
}
|
|
}
|