package com.debridstream.tv;

import A4.d;
import B4.a;
import S4.p;
import V2.A0;
import V2.A3;
import V2.B3;
import V2.C0673i0;
import V2.C0716s;
import V2.C0741y0;
import V2.EnumC0728v;
import V2.R2;
import V2.S2;
import V2.T2;
import V2.U2;
import V2.V2;
import V2.W2;
import V2.X2;
import V2.Y2;
import V2.Z2;
import V2.z3;
import V4.E;
import V4.N;
import Y4.H;
import Y4.O;
import Y4.a0;
import Y4.c0;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.compose.runtime.internal.StabilityInferred;
import androidx.lifecycle.X;
import androidx.lifecycle.b0;
import c5.e;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import kotlin.jvm.internal.o;
import m3.AbstractC2467b;
import n2.AbstractC2612c;
import w4.C3137A;
import w4.n;
import w4.q;
import x4.AbstractC3252r;
import x4.AbstractC3253s;

/* JADX INFO: loaded from: classes.dex */
@StabilityInferred(parameters = 0)
public final class ProfileViewModel extends b0 {
    public static final int $stable = 8;
    private final H _uiState;
    private long nextAutoSelectRequestId;
    private final a0 uiState;
    private final List<String> allProfileKeys = AbstractC3252r.B("main", "kids", "profile1", "profile2", "profile3");
    private final List<String> nonKidsOptionalKeys = AbstractC3252r.B("profile1", "profile2", "profile3");

    public ProfileViewModel() {
        c0 c0VarC = O.c(new T2(AbstractC2612c.q(new R2()), false, false, "", null, false, false, null, false, 0L, null));
        this._uiState = c0VarC;
        this.uiState = c0VarC;
        this.nextAutoSelectRequestId = 1L;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:104:0x01fb  */
    /* JADX WARN: Removed duplicated region for block: B:63:0x0114  */
    /* JADX WARN: Removed duplicated region for block: B:76:0x016c  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x018a  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x001c  */
    /* JADX WARN: Removed duplicated region for block: B:91:0x019e  */
    /* JADX WARN: Removed duplicated region for block: B:99:0x01d2  */
    /* JADX WARN: Type inference failed for: r13v10 */
    /* JADX WARN: Type inference failed for: r13v11 */
    /* JADX WARN: Type inference failed for: r13v12 */
    /* JADX WARN: Type inference failed for: r13v13 */
    /* JADX WARN: Type inference failed for: r13v3 */
    /* JADX WARN: Type inference failed for: r13v4, types: [V2.S2, java.lang.String] */
    /* JADX WARN: Type inference failed for: r13v5 */
    /* JADX WARN: Type inference failed for: r13v9 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object completeProfileEntry(Context context, A0 a02, String str, d dVar) {
        V2 v22;
        V2 v23;
        a aVar;
        String str2;
        ProfileViewModel profileViewModel;
        V2 v24;
        a aVar2;
        ProfileViewModel profileViewModel2;
        B3 b32;
        Object objD;
        String profileKey;
        Throwable thA;
        c0 c0Var;
        Object value;
        T2 t22;
        String message;
        ?? r13;
        int i6;
        Context context2;
        S2 s22;
        EnumC0728v enumC0728v;
        Context context3;
        C0716s c0716s;
        Map map;
        C0673i0 c0673i0;
        Object objD2;
        String str3;
        Throwable thA2;
        c0 c0Var2;
        Object value2;
        c0 c0Var3;
        Object value3;
        T2 t23;
        String message2;
        Context context4 = context;
        boolean z6 = true;
        char c6 = 2;
        if (dVar instanceof V2) {
            v22 = (V2) dVar;
            int i7 = v22.f7592j;
            if ((i7 & Integer.MIN_VALUE) != 0) {
                v22.f7592j = i7 - Integer.MIN_VALUE;
            } else {
                v22 = new V2(this, dVar);
            }
        }
        V2 v25 = v22;
        Object objK = v25.f7590e;
        a aVar3 = a.f492a;
        int i8 = v25.f7592j;
        char c7 = 3;
        Object obj = null;
        if (i8 == 0) {
            AbstractC2467b.l(objK);
            H h5 = this._uiState;
            while (true) {
                c0 c0Var4 = (c0) h5;
                Object value4 = c0Var4.getValue();
                v23 = v25;
                H h6 = h5;
                aVar = aVar3;
                str2 = str;
                if (c0Var4.i(value4, T2.a((T2) value4, null, true, true, "Syncing profile…", str2, false, false, null, false, 0L, null, 33))) {
                    break;
                }
                h5 = h6;
                v25 = v23;
                aVar3 = aVar;
                z6 = true;
                c6 = 2;
                c7 = 3;
                obj = null;
            }
            z3.c(context4, str2);
            try {
                C0741y0 c0741y0 = C0741y0.f8184a;
                try {
                    b32 = new B3(a02.f7249a, a02.f7250b, a02.f7251c, a02.f7252d);
                    profileViewModel = this;
                } catch (Throwable th) {
                    th = th;
                    profileViewModel = this;
                    v24 = v23;
                }
                try {
                    C0673i0 c0673i02 = new C0673i0(profileViewModel, 1);
                    v24 = v23;
                    try {
                        v24.f7586a = profileViewModel;
                        v24.f7587b = context4;
                        v24.f7588c = str2;
                    } catch (Throwable th2) {
                        th = th2;
                    }
                    try {
                        v24.f7592j = 1;
                        objK = c0741y0.k(b32, str2, c0673i02, v24);
                        aVar2 = aVar;
                    } catch (Throwable th3) {
                        th = th3;
                        aVar2 = aVar;
                        profileViewModel2 = profileViewModel;
                        objD = AbstractC2467b.d(th);
                        Context context5 = context4;
                        profileKey = str2;
                        thA = n.a(objD);
                        if (thA != null) {
                        }
                    }
                } catch (Throwable th4) {
                    th = th4;
                    v24 = v23;
                    aVar2 = aVar;
                    profileViewModel2 = profileViewModel;
                    objD = AbstractC2467b.d(th);
                    Context context52 = context4;
                    profileKey = str2;
                    thA = n.a(objD);
                    if (thA != null) {
                    }
                }
            } catch (Throwable th5) {
                th = th5;
                profileViewModel = this;
            }
            if (objK != aVar2) {
                profileViewModel2 = profileViewModel;
                objD = (S2) objK;
                Context context522 = context4;
                profileKey = str2;
                thA = n.a(objD);
                if (thA != null) {
                }
            }
            return aVar2;
        }
        if (i8 == 1) {
            String str4 = v25.f7588c;
            Context context6 = v25.f7587b;
            ProfileViewModel profileViewModel3 = v25.f7586a;
            try {
                AbstractC2467b.l(objK);
                v24 = v25;
                profileViewModel2 = profileViewModel3;
                str2 = str4;
                context4 = context6;
                aVar2 = aVar3;
                try {
                    objD = (S2) objK;
                } catch (Throwable th6) {
                    th = th6;
                    objD = AbstractC2467b.d(th);
                }
            } catch (Throwable th7) {
                th = th7;
                v24 = v25;
                profileViewModel2 = profileViewModel3;
                str2 = str4;
                context4 = context6;
                aVar2 = aVar3;
                objD = AbstractC2467b.d(th);
                Context context5222 = context4;
                profileKey = str2;
                thA = n.a(objD);
                if (thA != null) {
                }
            }
            Context context52222 = context4;
            profileKey = str2;
            thA = n.a(objD);
            if (thA != null) {
                z3.c(context52222, null);
                H h7 = profileViewModel2._uiState;
                do {
                    c0Var = (c0) h7;
                    value = c0Var.getValue();
                    t22 = (T2) value;
                    message = thA.getMessage();
                    if (message == null) {
                        message = "Failed to sync profile";
                    }
                } while (!c0Var.i(value, T2.a(t22, null, false, false, "", null, false, false, message, false, 0L, null, 1841)));
                return Boolean.FALSE;
            }
            S2 s23 = (S2) objD;
            e eVar = N.f8259a;
            c5.d dVar2 = c5.d.f13466b;
            r13 = 0;
            W2 w22 = new W2(context52222, profileKey, null);
            v24.f7586a = profileViewModel2;
            v24.f7587b = context52222;
            v24.f7588c = profileKey;
            v24.f7589d = s23;
            i6 = 2;
            v24.f7592j = 2;
            objK = E.H(dVar2, w22, v24);
            if (objK != aVar2) {
                context2 = context52222;
                s22 = s23;
                q qVar = (q) objK;
                boolean zBooleanValue = ((Boolean) qVar.f25479a).booleanValue();
                boolean zBooleanValue2 = ((Boolean) qVar.f25480b).booleanValue();
                boolean zBooleanValue3 = ((Boolean) qVar.f25481c).booleanValue();
                o.h(profileKey, "profileKey");
                if (profileKey.equals("main")) {
                    c0716s = C0716s.f8049a;
                    map = s22.f7532b;
                    c0673i0 = new C0673i0(profileViewModel2, i6);
                    v24.f7586a = profileViewModel2;
                    v24.f7587b = context2;
                    v24.f7588c = r13;
                    v24.f7589d = r13;
                    v24.f7592j = 3;
                    if (c0716s.m(context2, enumC0728v, map, c0673i0, v24) != aVar2) {
                    }
                }
            }
            return aVar2;
        }
        if (i8 == 2) {
            s22 = v25.f7589d;
            profileKey = v25.f7588c;
            Context context7 = v25.f7587b;
            ProfileViewModel profileViewModel4 = v25.f7586a;
            AbstractC2467b.l(objK);
            v24 = v25;
            i6 = 2;
            profileViewModel2 = profileViewModel4;
            r13 = 0;
            context2 = context7;
            aVar2 = aVar3;
            q qVar2 = (q) objK;
            boolean zBooleanValue4 = ((Boolean) qVar2.f25479a).booleanValue();
            boolean zBooleanValue22 = ((Boolean) qVar2.f25480b).booleanValue();
            boolean zBooleanValue32 = ((Boolean) qVar2.f25481c).booleanValue();
            o.h(profileKey, "profileKey");
            enumC0728v = (profileKey.equals("main") || !zBooleanValue4) ? EnumC0728v.f8114a : !zBooleanValue22 ? EnumC0728v.f8115b : !zBooleanValue32 ? EnumC0728v.f8116c : EnumC0728v.f8117d;
            try {
                c0716s = C0716s.f8049a;
                map = s22.f7532b;
                c0673i0 = new C0673i0(profileViewModel2, i6);
                v24.f7586a = profileViewModel2;
                v24.f7587b = context2;
                v24.f7588c = r13;
                v24.f7589d = r13;
                v24.f7592j = 3;
                if (c0716s.m(context2, enumC0728v, map, c0673i0, v24) != aVar2) {
                    context3 = context2;
                    r13 = r13;
                    objD2 = C3137A.f25453a;
                    str3 = r13;
                }
                return aVar2;
            } catch (Throwable th8) {
                th = th8;
                context3 = context2;
                objD2 = AbstractC2467b.d(th);
                str3 = r13;
                thA2 = n.a(objD2);
                if (thA2 == null) {
                }
            }
        } else {
            if (i8 != 3) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            context3 = v25.f7587b;
            profileViewModel2 = v25.f7586a;
            try {
                AbstractC2467b.l(objK);
                r13 = 0;
            } catch (Throwable th9) {
                th = th9;
                r13 = 0;
                objD2 = AbstractC2467b.d(th);
                str3 = r13;
                thA2 = n.a(objD2);
                if (thA2 == null) {
                }
            }
            try {
                objD2 = C3137A.f25453a;
                str3 = r13;
            } catch (Throwable th10) {
                th = th10;
                objD2 = AbstractC2467b.d(th);
                str3 = r13;
            }
        }
        thA2 = n.a(objD2);
        if (thA2 == null) {
            H h8 = profileViewModel2._uiState;
            do {
                c0Var2 = (c0) h8;
                value2 = c0Var2.getValue();
            } while (!c0Var2.i(value2, T2.a((T2) value2, null, false, true, "", null, false, true, null, false, 0L, null, 1841)));
            return Boolean.TRUE;
        }
        z3.c(context3, str3);
        H h9 = profileViewModel2._uiState;
        do {
            c0Var3 = (c0) h9;
            value3 = c0Var3.getValue();
            t23 = (T2) value3;
            message2 = thA2.getMessage();
            if (message2 == null) {
                message2 = "Failed to prepare home";
            }
        } while (!c0Var3.i(value3, T2.a(t23, null, false, false, "", null, false, false, message2, false, 0L, null, 1841)));
        return Boolean.FALSE;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final C3137A completeProfileEntry$lambda$26$lambda$25(ProfileViewModel profileViewModel, String str) {
        String stage = str;
        o.h(stage, "stage");
        H h5 = profileViewModel._uiState;
        while (true) {
            c0 c0Var = (c0) h5;
            Object value = c0Var.getValue();
            H h6 = h5;
            if (c0Var.i(value, T2.a((T2) value, null, false, false, stage, null, false, false, null, false, 0L, null, 2039))) {
                return C3137A.f25453a;
            }
            h5 = h6;
            stage = str;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final C3137A completeProfileEntry$lambda$31$lambda$30(ProfileViewModel profileViewModel, String str) {
        String msg = str;
        o.h(msg, "msg");
        H h5 = profileViewModel._uiState;
        while (true) {
            c0 c0Var = (c0) h5;
            Object value = c0Var.getValue();
            H h6 = h5;
            if (c0Var.i(value, T2.a((T2) value, null, false, false, msg, null, false, false, null, false, 0L, null, 2039))) {
                return C3137A.f25453a;
            }
            h5 = h6;
            msg = str;
        }
    }

    public static /* synthetic */ void setProfiles$default(ProfileViewModel profileViewModel, Context context, List list, boolean z6, String str, int i6, Object obj) {
        if ((i6 & 8) != 0) {
            str = null;
        }
        profileViewModel.setProfiles(context, list, z6, str);
    }

    public final void addProfile(Context context, A0 authUser, String name, boolean z6, String str) {
        o.h(context, "context");
        o.h(authUser, "authUser");
        o.h(name, "name");
        E.y(X.h(this), null, null, new U2(this, z6, authUser, name, context, str, null), 3);
    }

    public final void deleteProfile(Context context, A0 authUser, String profileId) {
        c0 c0Var;
        Object value;
        o.h(context, "context");
        o.h(authUser, "authUser");
        o.h(profileId, "profileId");
        if (!profileId.equals("main")) {
            E.y(X.h(this), null, null, new X2(this, context, authUser, profileId, null), 3);
            return;
        }
        H h5 = this._uiState;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
        } while (!c0Var.i(value, T2.a((T2) value, null, false, false, null, null, false, false, "Main profile cannot be deleted", false, 0L, null, 1919)));
    }

    public final a0 getUiState() {
        return this.uiState;
    }

    public final void onProfileEntryBufferRevealFinished() {
        c0 c0Var;
        Object value;
        H h5 = this._uiState;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
        } while (!c0Var.i(value, T2.a((T2) value, null, false, false, null, null, false, false, null, false, 0L, null, 2043)));
    }

    public final void onProfileNavigationHandled() {
        c0 c0Var;
        Object value;
        H h5 = this._uiState;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
        } while (!c0Var.i(value, T2.a((T2) value, null, false, false, null, null, false, false, null, false, 0L, null, 1983)));
    }

    public final void onProfilePickerAutoSelectHandled(long j4) {
        c0 c0Var;
        Object value;
        T2 t2A;
        H h5 = this._uiState;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
            t2A = (T2) value;
            if (t2A.f7552j == j4) {
                t2A = T2.a(t2A, null, false, false, null, null, false, false, null, false, 0L, null, 511);
            }
        } while (!c0Var.i(value, t2A));
    }

    public final void onProfilePickerResumeFailureHandled() {
        c0 c0Var;
        Object value;
        H h5 = this._uiState;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
        } while (!c0Var.i(value, T2.a((T2) value, null, false, false, null, null, false, false, null, false, 0L, null, 1791)));
    }

    public final void onProfileSelected(Context context, A0 authUser, R2 profile) {
        o.h(context, "context");
        o.h(authUser, "authUser");
        o.h(profile, "profile");
        E.y(X.h(this), null, null, new Y2(this, context, authUser, profile, null), 3);
    }

    public final boolean removeProfilePin(Context context, String profileId, String pin) {
        c0 c0Var;
        Object value;
        T2 t22;
        ArrayList arrayList;
        c0 c0Var2;
        Object value2;
        o.h(context, "context");
        o.h(profileId, "profileId");
        o.h(pin, "pin");
        String string = context.getApplicationContext().getSharedPreferences("debridstream_profile_pins", 0).getString(profileId, null);
        if (!(string == null ? false : string.equals(p.o1(pin).toString()))) {
            H h5 = this._uiState;
            do {
                c0Var2 = (c0) h5;
                value2 = c0Var2.getValue();
            } while (!c0Var2.i(value2, T2.a((T2) value2, null, false, false, null, null, false, false, "Incorrect PIN", false, 0L, null, 1919)));
            return false;
        }
        context.getApplicationContext().getSharedPreferences("debridstream_profile_pins", 0).edit().remove(profileId).apply();
        H h6 = this._uiState;
        do {
            c0Var = (c0) h6;
            value = c0Var.getValue();
            t22 = (T2) value;
            List<R2> list = t22.f7543a;
            arrayList = new ArrayList(AbstractC3253s.G(list, 10));
            for (R2 r2A : list) {
                if (o.c(r2A.f7513a, profileId)) {
                    r2A = R2.a(r2A, null, false, 3);
                }
                arrayList.add(r2A);
            }
        } while (!c0Var.i(value, T2.a(t22, arrayList, false, false, null, null, false, false, null, false, 0L, null, 1918)));
        return true;
    }

    public final void renameProfile(Context context, String profileId, String name) {
        c0 c0Var;
        Object value;
        T2 t22;
        ArrayList arrayList;
        o.h(context, "context");
        o.h(profileId, "profileId");
        o.h(name, "name");
        String string = p.o1(name).toString();
        if (p.Q0(string)) {
            string = profileId;
        }
        String string2 = p.o1(string).toString();
        if (string2 == null) {
            string2 = "";
        }
        SharedPreferences.Editor editorEdit = context.getApplicationContext().getSharedPreferences("debridstream_profile_names", 0).edit();
        if (p.Q0(string2)) {
            editorEdit.remove(profileId);
        } else {
            editorEdit.putString(profileId, string2);
        }
        editorEdit.apply();
        H h5 = this._uiState;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
            t22 = (T2) value;
            List<R2> list = t22.f7543a;
            arrayList = new ArrayList(AbstractC3253s.G(list, 10));
            for (R2 r2A : list) {
                if (o.c(r2A.f7513a, profileId)) {
                    r2A = R2.a(r2A, string, false, 5);
                }
                arrayList.add(r2A);
            }
        } while (!c0Var.i(value, T2.a(t22, arrayList, false, false, null, null, false, false, null, false, 0L, null, 1918)));
    }

    public final void requestProfilePickerAutoSelect(String str) {
        String profileId = str;
        o.h(profileId, "profileId");
        long j4 = this.nextAutoSelectRequestId;
        this.nextAutoSelectRequestId = 1 + j4;
        H h5 = this._uiState;
        while (true) {
            c0 c0Var = (c0) h5;
            Object value = c0Var.getValue();
            H h6 = h5;
            if (c0Var.i(value, T2.a((T2) value, null, false, false, null, profileId, false, false, null, false, j4, str, 303))) {
                return;
            }
            profileId = str;
            h5 = h6;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0017  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object resumeFromColdStart(Context context, A0 a02, d dVar) {
        Z2 z22;
        ProfileViewModel profileViewModel;
        Context context2;
        c0 c0Var;
        Object value;
        if (dVar instanceof Z2) {
            z22 = (Z2) dVar;
            int i6 = z22.f7665e;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                z22.f7665e = i6 - Integer.MIN_VALUE;
            } else {
                z22 = new Z2(this, dVar);
            }
        }
        Object objCompleteProfileEntry = z22.f7663c;
        a aVar = a.f492a;
        int i7 = z22.f7665e;
        C3137A c3137a = C3137A.f25453a;
        if (i7 == 0) {
            AbstractC2467b.l(objCompleteProfileEntry);
            String strA = z3.a(context);
            if (strA != null) {
                Context applicationContext = context.getApplicationContext();
                o.g(applicationContext, "getApplicationContext(...)");
                z22.f7661a = this;
                z22.f7662b = context;
                z22.f7665e = 1;
                objCompleteProfileEntry = completeProfileEntry(applicationContext, a02, strA, z22);
                if (objCompleteProfileEntry == aVar) {
                    return aVar;
                }
                profileViewModel = this;
                context2 = context;
            }
            return c3137a;
        }
        if (i7 != 1) {
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
        context2 = z22.f7662b;
        profileViewModel = z22.f7661a;
        AbstractC2467b.l(objCompleteProfileEntry);
        if (!((Boolean) objCompleteProfileEntry).booleanValue()) {
            z3.c(context2, null);
            H h5 = profileViewModel._uiState;
            do {
                c0Var = (c0) h5;
                value = c0Var.getValue();
            } while (!c0Var.i(value, T2.a((T2) value, null, false, false, null, null, false, false, null, true, 0L, null, 1791)));
        }
        return c3137a;
    }

    public final void setProfilePin(Context context, String profileId, String pin) {
        c0 c0Var;
        Object value;
        c0 c0Var2;
        Object value2;
        T2 t22;
        ArrayList arrayList;
        c0 c0Var3;
        Object value3;
        o.h(context, "context");
        o.h(profileId, "profileId");
        o.h(pin, "pin");
        if (profileId.equals("kids")) {
            H h5 = this._uiState;
            do {
                c0Var3 = (c0) h5;
                value3 = c0Var3.getValue();
            } while (!c0Var3.i(value3, T2.a((T2) value3, null, false, false, null, null, false, false, "Kids profile cannot have a PIN", false, 0L, null, 1919)));
            return;
        }
        String string = p.o1(pin).toString();
        if (string.length() == 4) {
            for (int i6 = 0; i6 < string.length(); i6++) {
                if (Character.isDigit(string.charAt(i6))) {
                }
            }
            String string2 = p.o1(string).toString();
            if (string2.length() == 4) {
                int i7 = 0;
                while (true) {
                    if (i7 >= string2.length()) {
                        context.getApplicationContext().getSharedPreferences("debridstream_profile_pins", 0).edit().putString(profileId, string2).apply();
                        break;
                    } else if (!Character.isDigit(string2.charAt(i7))) {
                        break;
                    } else {
                        i7++;
                    }
                }
            }
            H h6 = this._uiState;
            do {
                c0Var2 = (c0) h6;
                value2 = c0Var2.getValue();
                t22 = (T2) value2;
                List<R2> list = t22.f7543a;
                arrayList = new ArrayList(AbstractC3253s.G(list, 10));
                for (R2 r2A : list) {
                    if (o.c(r2A.f7513a, profileId)) {
                        r2A = R2.a(r2A, null, true, 3);
                    }
                    arrayList.add(r2A);
                }
            } while (!c0Var2.i(value2, T2.a(t22, arrayList, false, false, null, null, false, false, null, false, 0L, null, 1918)));
            return;
        }
        H h7 = this._uiState;
        do {
            c0Var = (c0) h7;
            value = c0Var.getValue();
        } while (!c0Var.i(value, T2.a((T2) value, null, false, false, null, null, false, false, "PIN must be 4 digits", false, 0L, null, 1919)));
    }

    public final void setProfiles(Context context, List<A3> startupProfiles, boolean z6, String str) {
        String str2;
        c0 c0Var;
        Object value;
        T2 t22;
        o.h(context, "context");
        o.h(startupProfiles, "startupProfiles");
        C0741y0 c0741y0 = C0741y0.f8184a;
        ArrayList arrayListJ = C0741y0.j(startupProfiles);
        ArrayList arrayList = new ArrayList(AbstractC3253s.G(arrayListJ, 10));
        Iterator it = arrayListJ.iterator();
        while (true) {
            str2 = null;
            if (!it.hasNext()) {
                break;
            }
            A3 a32 = (A3) it.next();
            String profileKey = a32.f7258a;
            o.h(profileKey, "profileKey");
            String defaultName = a32.f7259b;
            o.h(defaultName, "defaultName");
            boolean z7 = false;
            String string = context.getApplicationContext().getSharedPreferences("debridstream_profile_names", 0).getString(profileKey, null);
            if (string != null) {
                if (p.Q0(string)) {
                    string = null;
                }
                if (string != null) {
                    defaultName = string;
                }
            }
            String profileKey2 = a32.f7258a;
            o.h(profileKey2, "profileKey");
            String string2 = context.getApplicationContext().getSharedPreferences("debridstream_profile_pins", 0).getString(profileKey2, null);
            if (string2 != null && string2.length() == 4) {
                z7 = true;
            }
            arrayList.add(new R2(profileKey, defaultName, z7));
        }
        if (str != null && !arrayList.isEmpty()) {
            Iterator it2 = arrayList.iterator();
            while (true) {
                if (!it2.hasNext()) {
                    break;
                } else if (o.c(((R2) it2.next()).f7513a, str)) {
                    str2 = str;
                    break;
                }
            }
        }
        H h5 = this._uiState;
        do {
            c0Var = (c0) h5;
            value = c0Var.getValue();
            t22 = (T2) value;
        } while (!c0Var.i(value, T2.a(t22, arrayList.isEmpty() ? AbstractC2612c.q(new R2()) : arrayList, false, false, null, str2 == null ? t22.f7547e : str2, z6, false, null, false, 0L, null, 1998)));
    }
}
