package com.discord.widgets.botuikit; import c.d.b.a.a; import com.discord.api.botuikit.ActionComponent; import com.discord.api.botuikit.ActionRowComponent; import com.discord.api.botuikit.ButtonComponent; import com.discord.api.botuikit.Component; import com.discord.api.botuikit.ComponentUtils; import com.discord.api.botuikit.LayoutComponent; import com.discord.api.botuikit.SelectComponent; import com.discord.models.botuikit.ActionInteractionComponentState; import com.discord.models.botuikit.ActionRowMessageComponentKt; import com.discord.models.botuikit.ButtonMessageComponentKt; import com.discord.models.botuikit.MessageComponent; import com.discord.models.botuikit.SelectMessageComponentKt; import com.discord.stores.StoreApplicationInteractions; import com.discord.widgets.botuikit.ComponentChatListState; import d0.t.k; import d0.z.d.m; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.Stack; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Ref$ObjectRef; /* compiled from: ComponentStateMapper.kt */ public final class ComponentStateMapper { public static final ComponentStateMapper INSTANCE = new ComponentStateMapper(); /* compiled from: ComponentStateMapper.kt */ public static final class ChildComponents { private final MessageComponent[] components; private int currentComponentInsertionIndex; private final int layoutComponentIndex; private final LayoutComponent parentLayoutComponent; private final int total; public ChildComponents(int i, LayoutComponent layoutComponent, int i2, int i3) { this.layoutComponentIndex = i; this.parentLayoutComponent = layoutComponent; this.currentComponentInsertionIndex = i2; this.total = i3; MessageComponent[] messageComponentArr = new MessageComponent[i3]; for (int i4 = 0; i4 < i3; i4++) { messageComponentArr[i4] = null; } this.components = messageComponentArr; } /* JADX INFO: this call moved to the top of the method (can break code semantics) */ public /* synthetic */ ChildComponents(int i, LayoutComponent layoutComponent, int i2, int i3, int i4, DefaultConstructorMarker defaultConstructorMarker) { this(i, (i4 & 2) != 0 ? null : layoutComponent, (i4 & 4) != 0 ? 0 : i2, i3); } public static /* synthetic */ ChildComponents copy$default(ChildComponents childComponents, int i, LayoutComponent layoutComponent, int i2, int i3, int i4, Object obj) { if ((i4 & 1) != 0) { i = childComponents.layoutComponentIndex; } if ((i4 & 2) != 0) { layoutComponent = childComponents.parentLayoutComponent; } if ((i4 & 4) != 0) { i2 = childComponents.currentComponentInsertionIndex; } if ((i4 & 8) != 0) { i3 = childComponents.total; } return childComponents.copy(i, layoutComponent, i2, i3); } public final int component1() { return this.layoutComponentIndex; } public final LayoutComponent component2() { return this.parentLayoutComponent; } public final int component3() { return this.currentComponentInsertionIndex; } public final int component4() { return this.total; } public final ChildComponents copy(int i, LayoutComponent layoutComponent, int i2, int i3) { return new ChildComponents(i, layoutComponent, i2, i3); } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof ChildComponents)) { return false; } ChildComponents childComponents = (ChildComponents) obj; return this.layoutComponentIndex == childComponents.layoutComponentIndex && m.areEqual(this.parentLayoutComponent, childComponents.parentLayoutComponent) && this.currentComponentInsertionIndex == childComponents.currentComponentInsertionIndex && this.total == childComponents.total; } public final MessageComponent[] getComponents() { return this.components; } public final int getCurrentComponentInsertionIndex() { return this.currentComponentInsertionIndex; } public final int getLayoutComponentIndex() { return this.layoutComponentIndex; } public final LayoutComponent getParentLayoutComponent() { return this.parentLayoutComponent; } public final int getTotal() { return this.total; } public int hashCode() { int i = this.layoutComponentIndex * 31; LayoutComponent layoutComponent = this.parentLayoutComponent; return ((((i + (layoutComponent != null ? layoutComponent.hashCode() : 0)) * 31) + this.currentComponentInsertionIndex) * 31) + this.total; } public final void setCurrentComponentInsertionIndex(int i) { this.currentComponentInsertionIndex = i; } public String toString() { StringBuilder O = a.O("ChildComponents(layoutComponentIndex="); O.append(this.layoutComponentIndex); O.append(", parentLayoutComponent="); O.append(this.parentLayoutComponent); O.append(", currentComponentInsertionIndex="); O.append(this.currentComponentInsertionIndex); O.append(", total="); return a.z(O, this.total, ")"); } } private ComponentStateMapper() { } /* JADX WARNING: Removed duplicated region for block: B:19:0x0054 */ /* JADX WARNING: Removed duplicated region for block: B:20:0x005f */ /* JADX WARNING: Removed duplicated region for block: B:23:0x0064 */ /* JADX WARNING: Removed duplicated region for block: B:34:0x0080 */ /* JADX WARNING: Removed duplicated region for block: B:35:0x008a */ /* JADX WARNING: Removed duplicated region for block: B:38:0x0090 */ /* JADX WARNING: Removed duplicated region for block: B:39:0x0097 */ public final MessageComponent createActionMessageComponent(ActionComponent actionComponent, int i, ComponentChatListState.ComponentStoreState componentStoreState, ComponentExperiments componentExperiments) { Integer num; StoreApplicationInteractions.InteractionSendState interactionSendState; Set> entrySet; Object obj; m.checkNotNullParameter(actionComponent, "component"); m.checkNotNullParameter(componentStoreState, "storeState"); m.checkNotNullParameter(componentExperiments, "experimentController"); if (!componentExperiments.isEnabled(actionComponent.getType())) { return null; } Map interactionState = componentStoreState.getInteractionState(); if (!(interactionState == null || (entrySet = interactionState.entrySet()) == null)) { Iterator it = entrySet.iterator(); while (true) { if (!it.hasNext()) { obj = null; break; } obj = it.next(); if (((Map.Entry) obj).getValue() instanceof StoreApplicationInteractions.InteractionSendState.Loading) { break; } } Map.Entry entry = (Map.Entry) obj; if (entry != null) { num = (Integer) entry.getKey(); Map interactionState2 = componentStoreState.getInteractionState(); interactionSendState = interactionState2 == null ? interactionState2.get(Integer.valueOf(i)) : null; if (!(interactionSendState instanceof StoreApplicationInteractions.InteractionSendState.Failed)) { interactionSendState = null; } StoreApplicationInteractions.InteractionSendState.Failed failed = (StoreApplicationInteractions.InteractionSendState.Failed) interactionSendState; ActionInteractionComponentState failed2 = (num != null && i == num.intValue()) ? ActionInteractionComponentState.Loading.INSTANCE : (num != null || num.intValue() == i) ? failed == null ? new ActionInteractionComponentState.Failed(failed.getErrorMessage()) : ActionInteractionComponentState.Enabled.INSTANCE : ActionInteractionComponentState.Disabled.INSTANCE; if (actionComponent instanceof ButtonComponent) { return ButtonMessageComponentKt.mergeToMessageComponent((ButtonComponent) actionComponent, i, failed2, componentStoreState); } if (actionComponent instanceof SelectComponent) { return SelectMessageComponentKt.mergeToMessageComponent((SelectComponent) actionComponent, i, failed2, componentStoreState); } return null; } } num = null; Map interactionState2 = componentStoreState.getInteractionState(); if (interactionState2 == null) { } if (!(interactionSendState instanceof StoreApplicationInteractions.InteractionSendState.Failed)) { } StoreApplicationInteractions.InteractionSendState.Failed failed = (StoreApplicationInteractions.InteractionSendState.Failed) interactionSendState; if (num != null) { if (actionComponent instanceof ButtonComponent) { } } if (actionComponent instanceof ButtonComponent) { } } /* JADX WARNING: Unknown variable types count: 1 */ public final List processComponentsToMessageComponents(List list, ComponentChatListState.ComponentStoreState componentStoreState, ComponentExperiments componentExperiments, boolean z2) { m.checkNotNullParameter(list, "apiComponents"); m.checkNotNullParameter(componentExperiments, "componentExperiments"); if (componentStoreState == null) { componentStoreState = new ComponentChatListState.ComponentStoreState(null, null, z2, 3, null); } Ref$ObjectRef ref$ObjectRef = new Ref$ObjectRef(); ref$ObjectRef.element = new ChildComponents(-1, null, 0, list.size()); Stack stack = new Stack(); ComponentUtils componentUtils = ComponentUtils.INSTANCE; ComponentStateMapper$processComponentsToMessageComponents$1 componentStateMapper$processComponentsToMessageComponents$1 = new ComponentStateMapper$processComponentsToMessageComponents$1(componentStoreState, componentExperiments, ref$ObjectRef, stack); Objects.requireNonNull(componentUtils); m.checkNotNullParameter(list, "$this$forEachComponentIndexed"); m.checkNotNullParameter(componentStateMapper$processComponentsToMessageComponents$1, "action"); componentUtils.a(list, 0, componentStateMapper$processComponentsToMessageComponents$1); return k.filterNotNull(ref$ObjectRef.element.getComponents()); } public final MessageComponent toMessageLayoutComponent(LayoutComponent layoutComponent, int i, List list, ComponentExperiments componentExperiments) { m.checkNotNullParameter(layoutComponent, "component"); m.checkNotNullParameter(list, "children"); m.checkNotNullParameter(componentExperiments, "experimentController"); ActionRowComponent actionRowComponent = (ActionRowComponent) layoutComponent; if (!componentExperiments.isEnabled(actionRowComponent.getType())) { return null; } return ActionRowMessageComponentKt.mergeToMessageComponent(actionRowComponent, i, list); } }