package Q2;

import M2.C0556x0;
import N2.t;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import m3.AbstractC2467b;
import w4.C3137A;
import x4.AbstractC3229F;
import x4.AbstractC3251q;
import x4.AbstractC3252r;
import x4.AbstractC3253s;
import x4.y;

/* JADX INFO: loaded from: classes.dex */
public final class g extends C4.j implements J4.f {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f5926a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public /* synthetic */ List f5927b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ String f5928c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ N2.r f5929d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ boolean f5930e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ Integer f5931f;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final /* synthetic */ Integer f5932j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final /* synthetic */ Map f5933k;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public g(String str, N2.r rVar, boolean z6, Integer num, Integer num2, Map map, A4.d dVar) {
        super(3, dVar);
        this.f5928c = str;
        this.f5929d = rVar;
        this.f5930e = z6;
        this.f5931f = num;
        this.f5932j = num2;
        this.f5933k = map;
    }

    @Override // J4.f
    public final Object invoke(Object obj, Object obj2, Object obj3) {
        ((Number) obj2).intValue();
        Integer num = this.f5932j;
        Map map = this.f5933k;
        g gVar = new g(this.f5928c, this.f5929d, this.f5930e, this.f5931f, num, map, (A4.d) obj3);
        gVar.f5927b = (List) obj;
        return gVar.invokeSuspend(C3137A.f25453a);
    }

    /* JADX WARN: Removed duplicated region for block: B:72:0x018e  */
    @Override // C4.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        List list;
        Object objN;
        String str;
        long j4;
        b bVar;
        B4.a aVar = B4.a.f492a;
        int i6 = this.f5926a;
        if (i6 == 0) {
            AbstractC2467b.l(obj);
            list = this.f5927b;
            ArrayList arrayList = new ArrayList(AbstractC3253s.G(list, 10));
            Iterator it = list.iterator();
            while (it.hasNext()) {
                arrayList.add(P2.c.g((String) it.next()));
            }
            Map mapW = AbstractC3229F.w(new w4.k("urls", arrayList), new w4.k("includeFiles", Boolean.TRUE));
            this.f5927b = list;
            this.f5926a = 1;
            objN = r.n("https://offcloud.com/api/cache/info", "POST", this.f5928c, mapW, this.f5929d, this);
            if (objN == aVar) {
                return aVar;
            }
        } else {
            if (i6 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            List list2 = this.f5927b;
            AbstractC2467b.l(obj);
            list = list2;
            objN = obj;
        }
        t tVar = (t) objN;
        y yVar = y.f26065a;
        if (tVar == null) {
            return yVar;
        }
        List listO = r.o(tVar.f5255c);
        ArrayList arrayList2 = new ArrayList();
        int i7 = 0;
        for (Object obj2 : list) {
            int i8 = i7 + 1;
            if (i7 < 0) {
                AbstractC3252r.F();
                throw null;
            }
            String str2 = (String) obj2;
            Object objH0 = AbstractC3251q.h0(i7, listO);
            Map map = objH0 instanceof Map ? (Map) objH0 : null;
            if (map != null && kotlin.jvm.internal.o.c(map.get("cached"), Boolean.TRUE)) {
                Object obj3 = map.get("files");
                List<Map> list3 = obj3 instanceof List ? (List) obj3 : null;
                if (list3 == null) {
                    list3 = yVar;
                }
                ArrayList arrayList3 = new ArrayList(AbstractC3253s.G(list3, 10));
                for (Map map2 : list3) {
                    arrayList3.add(new b(r.a(map2), map2));
                }
                ArrayList arrayList4 = new ArrayList();
                for (Object obj4 : arrayList3) {
                    S4.m mVar = P2.c.f5650a;
                    if (P2.c.f(((b) obj4).f5914b)) {
                        arrayList4.add(obj4);
                    }
                }
                if (arrayList4.isEmpty()) {
                    arrayList4 = arrayList3;
                }
                if (this.f5930e) {
                    S4.m mVar2 = P2.c.f5650a;
                    Integer num = this.f5931f;
                    kotlin.jvm.internal.o.e(num);
                    int iIntValue = num.intValue();
                    Integer num2 = this.f5932j;
                    kotlin.jvm.internal.o.e(num2);
                    str = null;
                    j4 = 0;
                    bVar = (b) P2.c.b(arrayList4, iIntValue, num2.intValue(), (String) this.f5933k.get(str2), new C0556x0(19));
                    if (bVar != null) {
                    }
                } else {
                    str = null;
                    j4 = 0;
                    Object obj5 = null;
                    for (Object obj6 : arrayList4) {
                        if (0 > 0) {
                            obj5 = obj6;
                        }
                    }
                    if (obj5 == null || !P2.c.f5652c.a(((b) obj5).f5914b)) {
                        obj5 = null;
                    }
                    bVar = (b) obj5;
                }
                if (bVar != null) {
                    String strL = r.l(bVar.f5914b);
                    String str3 = P2.c.e(strL) ? strL : str;
                    ArrayList arrayList5 = new ArrayList(AbstractC3253s.G(arrayList3, 10));
                    Iterator it2 = arrayList3.iterator();
                    while (it2.hasNext()) {
                        long j6 = j4;
                        arrayList5.add(new N2.e(((b) it2.next()).f5914b, j6));
                        j4 = j6;
                    }
                    arrayList2.add(new N2.f(str2, "offcloud", arrayList5, str3, null, 0L, null, null, 67108816));
                }
            }
            i7 = i8;
        }
        return arrayList2;
    }
}
