package com.discord.widgets.channels; import a0.a.a.b; import android.content.Context; import c.d.b.a.a; import com.airbnb.lottie.parser.AnimatableValueParser; import com.discord.api.channel.Channel; import com.discord.app.AppViewModel; import com.discord.models.domain.ModelNotificationSettings; import com.discord.stores.StoreChannelsSelected; import com.discord.stores.StoreGuildsNsfw; import com.discord.stores.StoreNavigation; import com.discord.stores.StoreStream; import com.discord.stores.StoreUser; import com.discord.stores.StoreUserGuildSettings; import com.discord.utilities.rx.ObservableExtensionsKt; import d0.z.d.m; import d0.z.d.o; import java.util.Iterator; import java.util.List; import kotlin.NoWhenBranchMatchedException; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.DefaultConstructorMarker; import rx.Observable; /* compiled from: WidgetChannelSidebarActionsViewModel.kt */ public final class WidgetChannelSidebarActionsViewModel extends AppViewModel { public static final Companion Companion = new Companion(null); /* compiled from: WidgetChannelSidebarActionsViewModel.kt */ /* renamed from: com.discord.widgets.channels.WidgetChannelSidebarActionsViewModel$1 reason: invalid class name */ public static final class AnonymousClass1 extends o implements Function1 { public final /* synthetic */ WidgetChannelSidebarActionsViewModel this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public AnonymousClass1(WidgetChannelSidebarActionsViewModel widgetChannelSidebarActionsViewModel) { super(1); this.this$0 = widgetChannelSidebarActionsViewModel; } /* Return type fixed from 'java.lang.Object' to match base method */ /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(StoreState storeState) { invoke(storeState); return Unit.a; } public final void invoke(StoreState storeState) { m.checkNotNullParameter(storeState, "storeState"); WidgetChannelSidebarActionsViewModel.access$handleStoreState(this.this$0, storeState); } } /* compiled from: WidgetChannelSidebarActionsViewModel.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } private final Observable observeStoreState(StoreNavigation storeNavigation, StoreChannelsSelected storeChannelsSelected, StoreUserGuildSettings storeUserGuildSettings, StoreGuildsNsfw storeGuildsNsfw, StoreUser storeUser) { Observable Y = storeNavigation.observeRightPanelState().Y(new WidgetChannelSidebarActionsViewModel$Companion$observeStoreState$1(storeChannelsSelected, storeUserGuildSettings, storeUser, storeGuildsNsfw)); m.checkNotNullExpressionValue(Y, "storeNavigation\n … }\n }"); return Y; } public static /* synthetic */ Observable observeStoreState$default(Companion companion, StoreNavigation storeNavigation, StoreChannelsSelected storeChannelsSelected, StoreUserGuildSettings storeUserGuildSettings, StoreGuildsNsfw storeGuildsNsfw, StoreUser storeUser, int i, Object obj) { if ((i & 1) != 0) { storeNavigation = StoreStream.Companion.getNavigation(); } if ((i & 2) != 0) { storeChannelsSelected = StoreStream.Companion.getChannelsSelected(); } if ((i & 4) != 0) { storeUserGuildSettings = StoreStream.Companion.getUserGuildSettings(); } if ((i & 8) != 0) { storeGuildsNsfw = StoreStream.Companion.getGuildsNsfw(); } if ((i & 16) != 0) { storeUser = StoreStream.Companion.getUsers(); } return companion.observeStoreState(storeNavigation, storeChannelsSelected, storeUserGuildSettings, storeGuildsNsfw, storeUser); } } /* compiled from: WidgetChannelSidebarActionsViewModel.kt */ public static abstract class StoreState { /* compiled from: WidgetChannelSidebarActionsViewModel.kt */ public static final class ChannelFound extends StoreState { private final Channel channel; private final boolean disablePins; private final ModelNotificationSettings guildNotificationSettings; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public ChannelFound(Channel channel, ModelNotificationSettings modelNotificationSettings, boolean z2) { super(null); m.checkNotNullParameter(channel, "channel"); this.channel = channel; this.guildNotificationSettings = modelNotificationSettings; this.disablePins = z2; } public static /* synthetic */ ChannelFound copy$default(ChannelFound channelFound, Channel channel, ModelNotificationSettings modelNotificationSettings, boolean z2, int i, Object obj) { if ((i & 1) != 0) { channel = channelFound.channel; } if ((i & 2) != 0) { modelNotificationSettings = channelFound.guildNotificationSettings; } if ((i & 4) != 0) { z2 = channelFound.disablePins; } return channelFound.copy(channel, modelNotificationSettings, z2); } public final Channel component1() { return this.channel; } public final ModelNotificationSettings component2() { return this.guildNotificationSettings; } public final boolean component3() { return this.disablePins; } public final ChannelFound copy(Channel channel, ModelNotificationSettings modelNotificationSettings, boolean z2) { m.checkNotNullParameter(channel, "channel"); return new ChannelFound(channel, modelNotificationSettings, z2); } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof ChannelFound)) { return false; } ChannelFound channelFound = (ChannelFound) obj; return m.areEqual(this.channel, channelFound.channel) && m.areEqual(this.guildNotificationSettings, channelFound.guildNotificationSettings) && this.disablePins == channelFound.disablePins; } public final Channel getChannel() { return this.channel; } public final boolean getDisablePins() { return this.disablePins; } public final ModelNotificationSettings getGuildNotificationSettings() { return this.guildNotificationSettings; } public int hashCode() { Channel channel = this.channel; int i = 0; int hashCode = (channel != null ? channel.hashCode() : 0) * 31; ModelNotificationSettings modelNotificationSettings = this.guildNotificationSettings; if (modelNotificationSettings != null) { i = modelNotificationSettings.hashCode(); } int i2 = (hashCode + i) * 31; boolean z2 = this.disablePins; if (z2) { z2 = true; } int i3 = z2 ? 1 : 0; int i4 = z2 ? 1 : 0; int i5 = z2 ? 1 : 0; return i2 + i3; } public String toString() { StringBuilder K = a.K("ChannelFound(channel="); K.append(this.channel); K.append(", guildNotificationSettings="); K.append(this.guildNotificationSettings); K.append(", disablePins="); return a.F(K, this.disablePins, ")"); } } /* compiled from: WidgetChannelSidebarActionsViewModel.kt */ public static final class ChannelNotFound extends StoreState { public static final ChannelNotFound INSTANCE = new ChannelNotFound(); private ChannelNotFound() { super(null); } } private StoreState() { } public /* synthetic */ StoreState(DefaultConstructorMarker defaultConstructorMarker) { this(); } } /* compiled from: WidgetChannelSidebarActionsViewModel.kt */ public static abstract class ViewState { /* compiled from: WidgetChannelSidebarActionsViewModel.kt */ public static final class Guild extends ViewState { private final long channelId; private final boolean disablePins; private final long guildId; private final boolean hasUnreadPins; private final boolean isMuted; private final boolean isThread; private final boolean shouldHideChannelSidebar; public Guild(long j, long j2, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6) { super(null); this.channelId = j; this.guildId = j2; this.isMuted = z2; this.hasUnreadPins = z3; this.disablePins = z4; this.isThread = z5; this.shouldHideChannelSidebar = z6; } public static /* synthetic */ Guild copy$default(Guild guild, long j, long j2, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, int i, Object obj) { return guild.copy((i & 1) != 0 ? guild.channelId : j, (i & 2) != 0 ? guild.guildId : j2, (i & 4) != 0 ? guild.isMuted : z2, (i & 8) != 0 ? guild.hasUnreadPins : z3, (i & 16) != 0 ? guild.disablePins : z4, (i & 32) != 0 ? guild.isThread : z5, (i & 64) != 0 ? guild.shouldHideChannelSidebar : z6); } public final long component1() { return this.channelId; } public final long component2() { return this.guildId; } public final boolean component3() { return this.isMuted; } public final boolean component4() { return this.hasUnreadPins; } public final boolean component5() { return this.disablePins; } public final boolean component6() { return this.isThread; } public final boolean component7() { return this.shouldHideChannelSidebar; } public final Guild copy(long j, long j2, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6) { return new Guild(j, j2, z2, z3, z4, z5, z6); } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Guild)) { return false; } Guild guild = (Guild) obj; return this.channelId == guild.channelId && this.guildId == guild.guildId && this.isMuted == guild.isMuted && this.hasUnreadPins == guild.hasUnreadPins && this.disablePins == guild.disablePins && this.isThread == guild.isThread && this.shouldHideChannelSidebar == guild.shouldHideChannelSidebar; } public final long getChannelId() { return this.channelId; } public final boolean getDisablePins() { return this.disablePins; } public final long getGuildId() { return this.guildId; } public final boolean getHasUnreadPins() { return this.hasUnreadPins; } public final boolean getShouldHideChannelSidebar() { return this.shouldHideChannelSidebar; } public int hashCode() { int a = (b.a(this.guildId) + (b.a(this.channelId) * 31)) * 31; boolean z2 = this.isMuted; int i = 1; if (z2) { z2 = true; } int i2 = z2 ? 1 : 0; int i3 = z2 ? 1 : 0; int i4 = z2 ? 1 : 0; int i5 = (a + i2) * 31; boolean z3 = this.hasUnreadPins; if (z3) { z3 = true; } int i6 = z3 ? 1 : 0; int i7 = z3 ? 1 : 0; int i8 = z3 ? 1 : 0; int i9 = (i5 + i6) * 31; boolean z4 = this.disablePins; if (z4) { z4 = true; } int i10 = z4 ? 1 : 0; int i11 = z4 ? 1 : 0; int i12 = z4 ? 1 : 0; int i13 = (i9 + i10) * 31; boolean z5 = this.isThread; if (z5) { z5 = true; } int i14 = z5 ? 1 : 0; int i15 = z5 ? 1 : 0; int i16 = z5 ? 1 : 0; int i17 = (i13 + i14) * 31; boolean z6 = this.shouldHideChannelSidebar; if (!z6) { i = z6 ? 1 : 0; } return i17 + i; } public final boolean isMuted() { return this.isMuted; } public final boolean isThread() { return this.isThread; } public String toString() { StringBuilder K = a.K("Guild(channelId="); K.append(this.channelId); K.append(", guildId="); K.append(this.guildId); K.append(", isMuted="); K.append(this.isMuted); K.append(", hasUnreadPins="); K.append(this.hasUnreadPins); K.append(", disablePins="); K.append(this.disablePins); K.append(", isThread="); K.append(this.isThread); K.append(", shouldHideChannelSidebar="); return a.F(K, this.shouldHideChannelSidebar, ")"); } } /* compiled from: WidgetChannelSidebarActionsViewModel.kt */ public static final class Private extends ViewState { private final long channelId; private final boolean isMuted; public Private(long j, boolean z2) { super(null); this.channelId = j; this.isMuted = z2; } public static /* synthetic */ Private copy$default(Private r0, long j, boolean z2, int i, Object obj) { if ((i & 1) != 0) { j = r0.channelId; } if ((i & 2) != 0) { z2 = r0.isMuted; } return r0.copy(j, z2); } public final long component1() { return this.channelId; } public final boolean component2() { return this.isMuted; } public final Private copy(long j, boolean z2) { return new Private(j, z2); } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Private)) { return false; } Private r6 = (Private) obj; return this.channelId == r6.channelId && this.isMuted == r6.isMuted; } public final long getChannelId() { return this.channelId; } public int hashCode() { int a = b.a(this.channelId) * 31; boolean z2 = this.isMuted; if (z2) { z2 = true; } int i = z2 ? 1 : 0; int i2 = z2 ? 1 : 0; int i3 = z2 ? 1 : 0; return a + i; } public final boolean isMuted() { return this.isMuted; } public String toString() { StringBuilder K = a.K("Private(channelId="); K.append(this.channelId); K.append(", isMuted="); return a.F(K, this.isMuted, ")"); } } /* compiled from: WidgetChannelSidebarActionsViewModel.kt */ public static final class Uninitialized extends ViewState { public static final Uninitialized INSTANCE = new Uninitialized(); private Uninitialized() { super(null); } } private ViewState() { } public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) { this(); } } public WidgetChannelSidebarActionsViewModel() { this(null, 1, null); } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public WidgetChannelSidebarActionsViewModel(Observable observable) { super(ViewState.Uninitialized.INSTANCE); m.checkNotNullParameter(observable, "storeStateObservable"); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(observable, this, null, 2, null), WidgetChannelSidebarActionsViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null); } /* JADX INFO: this call moved to the top of the method (can break code semantics) */ public /* synthetic */ WidgetChannelSidebarActionsViewModel(Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) { this((i & 1) != 0 ? Companion.observeStoreState$default(Companion, null, null, null, null, null, 31, null) : observable); } public static final /* synthetic */ void access$handleStoreState(WidgetChannelSidebarActionsViewModel widgetChannelSidebarActionsViewModel, StoreState storeState) { widgetChannelSidebarActionsViewModel.handleStoreState(storeState); } private final void handleStoreState(StoreState storeState) { ModelNotificationSettings.ChannelOverride channelOverride; List channelOverrides; Object obj; boolean z2; if (m.areEqual(storeState, StoreState.ChannelNotFound.INSTANCE)) { updateViewState(ViewState.Uninitialized.INSTANCE); } else if (storeState instanceof StoreState.ChannelFound) { StoreState.ChannelFound channelFound = (StoreState.ChannelFound) storeState; boolean z3 = false; if (AnimatableValueParser.t1(channelFound.getChannel())) { ModelNotificationSettings guildNotificationSettings = channelFound.getGuildNotificationSettings(); long h = channelFound.getChannel().h(); if (!(guildNotificationSettings == null || (channelOverrides = guildNotificationSettings.getChannelOverrides()) == null)) { Iterator it = channelOverrides.iterator(); while (true) { if (!it.hasNext()) { obj = null; break; } obj = it.next(); ModelNotificationSettings.ChannelOverride channelOverride2 = (ModelNotificationSettings.ChannelOverride) obj; m.checkNotNullExpressionValue(channelOverride2, "channelOverride"); if (channelOverride2.getChannelId() == h) { z2 = true; continue; } else { z2 = false; continue; } if (z2) { break; } } ModelNotificationSettings.ChannelOverride channelOverride3 = (ModelNotificationSettings.ChannelOverride) obj; if (channelOverride3 != null && channelOverride3.isMuted()) { z3 = true; } } updateViewState(new ViewState.Private(channelFound.getChannel().h(), z3)); return; } long h2 = channelFound.getChannel().h(); long f = channelFound.getChannel().f(); ModelNotificationSettings guildNotificationSettings2 = channelFound.getGuildNotificationSettings(); updateViewState(new ViewState.Guild(h2, f, (guildNotificationSettings2 == null || (channelOverride = guildNotificationSettings2.getChannelOverride(h2)) == null || !channelOverride.isMuted()) ? false : true, false, channelFound.getDisablePins(), AnimatableValueParser.A1(channelFound.getChannel()), AnimatableValueParser.i1(channelFound.getChannel()))); } else { throw new NoWhenBranchMatchedException(); } } }