package V2;

import com.google.android.gms.common.internal.ImagesContract;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import m3.AbstractC2467b;
import org.json.JSONArray;
import org.json.JSONObject;
import w4.C3137A;

/* JADX INFO: loaded from: classes.dex */
public final class E1 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final E1 f7299a = new E1();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final Y4.c0 f7300b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final Y4.J f7301c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final LinkedHashMap f7302d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final e5.c f7303e;

    static {
        Y4.c0 c0VarC = Y4.O.c(x4.y.f26065a);
        f7300b = c0VarC;
        f7301c = new Y4.J(c0VarC);
        f7302d = new LinkedHashMap();
        f7303e = e5.d.a();
    }

    public static Y4.J a() {
        return f7301c;
    }

    /* JADX WARN: Removed duplicated region for block: B:33:0x0084 A[Catch: all -> 0x0031, TRY_LEAVE, TryCatch #0 {all -> 0x0031, blocks: (B:13:0x002d, B:31:0x0080, B:33:0x0084, B:36:0x008c), top: B:43:0x002d }] */
    /* JADX WARN: Removed duplicated region for block: B:36:0x008c A[Catch: all -> 0x0031, TRY_ENTER, TRY_LEAVE, TryCatch #0 {all -> 0x0031, blocks: (B:13:0x002d, B:31:0x0080, B:33:0x0084, B:36:0x008c), top: B:43:0x002d }] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object b(String str, C4.c cVar) throws Throwable {
        C1 c12;
        e5.a aVar;
        Throwable th;
        e5.a aVar2;
        String str2;
        e5.a aVar3;
        String str3;
        Object objI;
        if (cVar instanceof C1) {
            c12 = (C1) cVar;
            int i6 = c12.f7278e;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                c12.f7278e = i6 - Integer.MIN_VALUE;
            } else {
                c12 = new C1(this, cVar);
            }
        }
        Object obj = c12.f7276c;
        B4.a aVar4 = B4.a.f492a;
        int i7 = c12.f7278e;
        LinkedHashMap linkedHashMap = f7302d;
        try {
            if (i7 == 0) {
                AbstractC2467b.l(obj);
                c12.f7274a = str;
                e5.c cVar2 = f7303e;
                c12.f7275b = cVar2;
                c12.f7278e = 1;
                Object objE = cVar2.e(c12);
                aVar = cVar2;
                if (objE != aVar4) {
                }
                return aVar4;
            }
            if (i7 != 1) {
                if (i7 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                aVar2 = c12.f7275b;
                str2 = c12.f7274a;
                try {
                    AbstractC2467b.l(obj);
                    aVar3 = aVar2;
                    str3 = (String) obj;
                    if (str3 != null) {
                        objI = x4.y.f26065a;
                    } else {
                        objI = AbstractC0696m3.i(str3);
                        linkedHashMap.put(str2, objI);
                    }
                    ((e5.c) aVar3).g(null);
                    return objI;
                } catch (Throwable th2) {
                    th = th2;
                    ((e5.c) aVar2).g(null);
                    throw th;
                }
            }
            e5.a aVar5 = c12.f7275b;
            String str4 = c12.f7274a;
            AbstractC2467b.l(obj);
            aVar = aVar5;
            str = str4;
            List list = (List) linkedHashMap.get(str);
            if (list != null) {
                ((e5.c) aVar).g(null);
                return list;
            }
            c12.f7274a = str;
            c12.f7275b = aVar;
            c12.f7278e = 2;
            c5.e eVar = V4.N.f8259a;
            Object objH = V4.E.H(c5.d.f13466b, new A1(str, null), c12);
            if (objH != aVar4) {
                str2 = str;
                aVar3 = aVar;
                obj = objH;
                str3 = (String) obj;
                if (str3 != null) {
                }
                ((e5.c) aVar3).g(null);
                return objI;
            }
            return aVar4;
        } catch (Throwable th3) {
            e5.a aVar6 = aVar;
            th = th3;
            aVar2 = aVar6;
            ((e5.c) aVar2).g(null);
            throw th;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0014  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object c(C4.c cVar) {
        D1 d1;
        Object objD;
        if (cVar instanceof D1) {
            d1 = (D1) cVar;
            int i6 = d1.f7292c;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                d1.f7292c = i6 - Integer.MIN_VALUE;
            } else {
                d1 = new D1(this, cVar);
            }
        }
        Object objH = d1.f7290a;
        B4.a aVar = B4.a.f492a;
        int i7 = d1.f7292c;
        if (i7 == 0) {
            AbstractC2467b.l(objH);
            d1.f7292c = 1;
            c5.e eVar = V4.N.f8259a;
            objH = V4.E.H(c5.d.f13466b, new A1("https://raw.githubusercontent.com/lawdev-cmd/pub/refs/heads/main/collections-main.json", null), d1);
            if (objH == aVar) {
                return aVar;
            }
        } else {
            if (i7 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            AbstractC2467b.l(objH);
        }
        String str = (String) objH;
        C3137A c3137a = C3137A.f25453a;
        if (str != null) {
            try {
                objD = new JSONArray(str);
            } catch (Throwable th) {
                objD = AbstractC2467b.d(th);
            }
            if (w4.n.a(objD) == null) {
                JSONArray jSONArray = (JSONArray) objD;
                ArrayList arrayList = new ArrayList(jSONArray.length());
                int length = jSONArray.length();
                for (int i8 = 0; i8 < length; i8++) {
                    JSONObject jSONObjectOptJSONObject = jSONArray.optJSONObject(i8);
                    if (jSONObjectOptJSONObject != null) {
                        String strOptString = jSONObjectOptJSONObject.optString("title");
                        kotlin.jvm.internal.o.g(strOptString, "optString(...)");
                        String string = S4.p.o1(strOptString).toString();
                        String strOptString2 = jSONObjectOptJSONObject.optString(ImagesContract.URL);
                        kotlin.jvm.internal.o.g(strOptString2, "optString(...)");
                        String string2 = S4.p.o1(strOptString2).toString();
                        if (string.length() > 0 && string2.length() > 0) {
                            arrayList.add(new C0746z1(string, string2));
                        }
                    }
                }
                if (!arrayList.isEmpty()) {
                    Y4.c0 c0Var = f7300b;
                    c0Var.getClass();
                    c0Var.k(null, arrayList);
                }
            }
        }
        return c3137a;
    }
}
