package com.bytedance.frameworks.baselib.netx.partner;

import X.2te;
import X.2th;
import X.AnonymousClass7k2;
import X.C04537he;
import X.C23868bx;
import X.C50949eX;
import X.C50959eY;
import X.C50969eZ;
import X.C51029ef;
import X.C51039eg;
import X.C51069ej;
import X.C51339fA;
import X.C51499fQ;
import X.C51529fT;
import X.C51539fU;
import X.C51549fV;
import X.C51559fW;
import X.C51599fa;
import X.Crj;
import X.M12;
import android.os.SystemClock;
import com.bytedance.covode.number.Covode;
import com.bytedance.retrofit2.client.Request;
import java.util.ArrayList;
import java.util.List;

public final class NetworkPartnerGroup {
    public final List<C51069ej> LIZ = new ArrayList();
    public final List<C50949eX> LIZIZ = new ArrayList();
    public final List<C51039eg> LIZJ = new ArrayList();
    public final List<C50969eZ> LIZLLL = new ArrayList();
    public final List<C51559fW> LJ = new ArrayList();

    static {
        Covode.recordClassIndex(26250);
    }

    public static final class PartnerInterceptor implements C23868bx {
        public static final Crj LIZIZ = C04537he.LIZ(AnonymousClass7k2.LIZ);
        public static final C51599fa LIZJ = new C51599fa((byte) 0);
        public final List<C51559fW> LIZ;
        public final List<C51069ej> LIZLLL;
        public final List<C50949eX> LJ;
        public final List<C51039eg> LJFF;
        public final List<C50969eZ> LJI;

        static {
            Covode.recordClassIndex(26251);
        }

        private final void LIZ(Throwable th) {
            LIZJ.LIZ().post(new C51549fV(this, th));
        }

        public PartnerInterceptor(NetworkPartnerGroup networkPartnerGroup) {
            M12.LIZ(networkPartnerGroup);
            this.LIZLLL = new ArrayList(networkPartnerGroup.LIZ);
            this.LJ = new ArrayList(networkPartnerGroup.LIZIZ);
            this.LJFF = new ArrayList(networkPartnerGroup.LIZJ);
            this.LJI = new ArrayList(networkPartnerGroup.LIZLLL);
            this.LIZ = new ArrayList(networkPartnerGroup.LJ);
        }

        /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r2v4, resolved type: X.9ef} */
        /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r2v5, resolved type: boolean} */
        /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r2v6, resolved type: boolean} */
        /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r2v7, resolved type: boolean} */
        /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r2v12, resolved type: boolean} */
        /* JADX WARNING: type inference failed for: r2v3 */
        /* JADX WARNING: type inference failed for: r2v8, types: [java.lang.Throwable] */
        /* JADX WARNING: type inference failed for: r2v11 */
        /* JADX WARNING: type inference failed for: r2v13 */
        /* JADX WARNING: Multi-variable type inference failed */
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public final X.C51029ef<?> intercept(X.C51489fP r30) {
            /*
                r29 = this;
                r8 = r29
                r10 = r30
                X.M12.LIZ(r10)
                long r19 = android.os.SystemClock.uptimeMillis()
                com.bytedance.retrofit2.client.Request r7 = r10.LIZ()
                java.lang.String r9 = ""
                kotlin.h.b.n.LIZIZ(r7, r9)
                X.9fA r11 = new X.9fA
                r11.<init>(r7)
                X.2sG r5 = new X.2sG
                r5.<init>()
                r5.element = r9
                X.9fQ r6 = new X.9fQ
                r6.<init>(r10)
                X.9fT r4 = r6.LIZJ
                r0 = 0
                r3 = 0
            L_0x0029:
                X.9ef r12 = r8.LIZ(r11, r6)     // Catch:{ all -> 0x01f4 }
                r0 = 0
                if (r12 == 0) goto L_0x0035
                r8.LIZ(r7, r12, r0)     // Catch:{ all -> 0x01f4 }
                goto L_0x015b
            L_0x0035:
                X.9fa r0 = LIZJ     // Catch:{ all -> 0x01f4 }
                android.os.Handler r1 = r0.LIZ()     // Catch:{ all -> 0x01f4 }
                X.9fX r0 = new X.9fX     // Catch:{ all -> 0x01f4 }
                r0.<init>(r8, r7)     // Catch:{ all -> 0x01f4 }
                r1.post(r0)     // Catch:{ all -> 0x01f4 }
                X.9fT r13 = r6.LIZJ     // Catch:{ all -> 0x01f4 }
                java.util.List<X.9eX> r0 = r8.LJ     // Catch:{ all -> 0x01f4 }
                java.util.Iterator r16 = r0.iterator()     // Catch:{ all -> 0x01f4 }
            L_0x004b:
                boolean r0 = r16.hasNext()     // Catch:{ all -> 0x01f4 }
                if (r0 == 0) goto L_0x0081
                java.lang.Object r0 = r16.next()     // Catch:{ all -> 0x01f4 }
                X.9eX r0 = (X.C50949eX) r0     // Catch:{ all -> 0x01f4 }
                long r14 = android.os.SystemClock.uptimeMillis()     // Catch:{ all -> 0x01f4 }
                r0.LIZ(r11, r6)     // Catch:{ all -> 0x01f4 }
                java.lang.String r12 = r0.LIZ()     // Catch:{ all -> 0x01f4 }
                long r0 = android.os.SystemClock.uptimeMillis()     // Catch:{ all -> 0x01f4 }
                long r0 = r0 - r14
                X.M12.LIZ(r12)     // Catch:{ all -> 0x01f4 }
                java.util.HashMap<java.lang.String, java.lang.Long> r2 = r13.LIZJ     // Catch:{ all -> 0x01f4 }
                java.util.HashMap<java.lang.String, java.lang.Long> r14 = r13.LIZJ     // Catch:{ all -> 0x01f4 }
                java.lang.Object r14 = r14.get(r12)     // Catch:{ all -> 0x01f4 }
                java.lang.Long r14 = (java.lang.Long) r14     // Catch:{ all -> 0x01f4 }
                long r0 = r13.LIZ((long) r0, (java.lang.Long) r14)     // Catch:{ all -> 0x01f4 }
                java.lang.Long r0 = java.lang.Long.valueOf(r0)     // Catch:{ all -> 0x01f4 }
                r2.put(r12, r0)     // Catch:{ all -> 0x01f4 }
                r0 = 0
                goto L_0x004b
            L_0x0081:
                com.bytedance.retrofit2.client.Request r7 = r11.LIZIZ()     // Catch:{ all -> 0x01f4 }
                X.9ef r11 = r8.LIZIZ(r11, r6)     // Catch:{ all -> 0x01f4 }
                if (r11 == 0) goto L_0x0091
                r0 = 0
                r8.LIZ(r7, r11, r0)     // Catch:{ all -> 0x01f4 }
                goto L_0x01d5
            L_0x0091:
                r2 = 0
                X.9fa r0 = LIZJ     // Catch:{ all -> 0x01f4 }
                android.os.Handler r1 = r0.LIZ()     // Catch:{ all -> 0x01f4 }
                X.9fY r0 = new X.9fY     // Catch:{ all -> 0x01f4 }
                r0.<init>(r8, r7)     // Catch:{ all -> 0x01f4 }
                r1.post(r0)     // Catch:{ all -> 0x01f4 }
                long r13 = android.os.SystemClock.uptimeMillis()     // Catch:{ all -> 0x01f4 }
                X.9ef r12 = r10.LIZ(r7)     // Catch:{ all -> 0x00ac }
                X.2te.constructor-impl(r12)     // Catch:{ all -> 0x00ac }
                goto L_0x00b4
            L_0x00ac:
                r0 = move-exception
                java.lang.Object r12 = X.2th.LIZ(r0)     // Catch:{ all -> 0x01f4 }
                X.2te.constructor-impl(r12)     // Catch:{ all -> 0x01f4 }
            L_0x00b4:
                long r0 = android.os.SystemClock.uptimeMillis()     // Catch:{ all -> 0x01f4 }
                long r0 = r0 - r13
                r4.LIZ = r0     // Catch:{ all -> 0x01f4 }
                java.lang.Throwable r0 = X.2te.exceptionOrNull-impl(r12)     // Catch:{ all -> 0x01f4 }
                if (r0 != 0) goto L_0x00e5
            L_0x00c1:
                X.2th.LIZ(r12)     // Catch:{ all -> 0x01f4 }
                X.9ef r12 = (X.C51029ef) r12     // Catch:{ all -> 0x01f4 }
                X.9fa r0 = LIZJ     // Catch:{ all -> 0x01f4 }
                android.os.Handler r1 = r0.LIZ()     // Catch:{ all -> 0x01f4 }
                X.9fZ r0 = new X.9fZ     // Catch:{ all -> 0x01f4 }
                r0.<init>(r8, r12)     // Catch:{ all -> 0x01f4 }
                r1.post(r0)     // Catch:{ all -> 0x01f4 }
                X.9ee r11 = new X.9ee     // Catch:{ all -> 0x01f4 }
                r11.<init>(r12)     // Catch:{ all -> 0x01f4 }
                X.8BT r1 = r11.LIZLLL     // Catch:{ all -> 0x01f4 }
                java.lang.String r0 = "x-tt-logid"
                java.lang.String r0 = r1.LIZ(r0)     // Catch:{ all -> 0x01f4 }
                if (r0 != 0) goto L_0x0177
                goto L_0x0176
            L_0x00e5:
                r8.LIZ(r0)     // Catch:{ all -> 0x01f4 }
                X.9fA r11 = new X.9fA     // Catch:{ all -> 0x01f4 }
                r11.<init>(r7)     // Catch:{ all -> 0x01f4 }
                X.9fT r13 = r6.LIZJ     // Catch:{ all -> 0x01f4 }
                java.util.List<X.9eZ> r1 = r8.LJI     // Catch:{ all -> 0x01f4 }
                java.util.Iterator r18 = r1.iterator()     // Catch:{ all -> 0x01f4 }
                r17 = 0
            L_0x00f7:
                boolean r1 = r18.hasNext()     // Catch:{ all -> 0x01f4 }
                if (r1 == 0) goto L_0x0151
                java.lang.Object r1 = r18.next()     // Catch:{ all -> 0x01f4 }
                X.9eZ r1 = (X.C50969eZ) r1     // Catch:{ all -> 0x01f4 }
                long r15 = android.os.SystemClock.uptimeMillis()     // Catch:{ all -> 0x01f4 }
                if (r17 != 0) goto L_0x0124
                r28 = r11
                r27 = r0
                r2 = 0
                r26 = 0
                r21 = r1
                r22 = r11
                r23 = r6
                r24 = r0
                r25 = r3
                boolean r0 = r21.LIZ(r22, r23, r24, r25, r26)     // Catch:{ all -> 0x01f4 }
                if (r0 == 0) goto L_0x0121
                goto L_0x0128
            L_0x0121:
                r17 = 0
                goto L_0x012b
            L_0x0124:
                r28 = r11
                r27 = r0
            L_0x0128:
                r0 = 1
                r17 = 1
            L_0x012b:
                java.lang.String r14 = r1.LIZ()     // Catch:{ all -> 0x01f4 }
                long r0 = android.os.SystemClock.uptimeMillis()     // Catch:{ all -> 0x01f4 }
                long r0 = r0 - r15
                X.M12.LIZ(r14)     // Catch:{ all -> 0x01f4 }
                java.util.HashMap<java.lang.String, java.lang.Long> r11 = r13.LJ     // Catch:{ all -> 0x01f4 }
                java.util.HashMap<java.lang.String, java.lang.Long> r15 = r13.LJ     // Catch:{ all -> 0x01f4 }
                java.lang.Object r15 = r15.get(r14)     // Catch:{ all -> 0x01f4 }
                java.lang.Long r15 = (java.lang.Long) r15     // Catch:{ all -> 0x01f4 }
                long r0 = r13.LIZ((long) r0, (java.lang.Long) r15)     // Catch:{ all -> 0x01f4 }
                java.lang.Long r0 = java.lang.Long.valueOf(r0)     // Catch:{ all -> 0x01f4 }
                r11.put(r14, r0)     // Catch:{ all -> 0x01f4 }
                r0 = r27
                r11 = r28
                goto L_0x00f7
            L_0x0151:
                if (r17 == 0) goto L_0x01f0
                int r3 = r3 + 1
                r0 = 10
                if (r3 < r0) goto L_0x0029
                goto L_0x00c1
            L_0x015b:
                java.lang.String r2 = r7.getPath()
                long r0 = android.os.SystemClock.uptimeMillis()
                long r0 = r0 - r19
                r4.LIZIZ = r0
                X.9fa r0 = LIZJ
                android.os.Handler r1 = r0.LIZ()
                X.9fS r0 = new X.9fS
                r0.<init>(r2, r5, r4)
                r1.post(r0)
                return r12
            L_0x0176:
                r0 = r9
            L_0x0177:
                r5.element = r0     // Catch:{ all -> 0x01f4 }
                X.9fT r12 = r6.LIZJ     // Catch:{ all -> 0x01f4 }
                java.util.List<X.9eg> r0 = r8.LJFF     // Catch:{ all -> 0x01f4 }
                java.util.Iterator r15 = r0.iterator()     // Catch:{ all -> 0x01f4 }
            L_0x0181:
                boolean r0 = r15.hasNext()     // Catch:{ all -> 0x01f4 }
                if (r0 == 0) goto L_0x01b6
                java.lang.Object r0 = r15.next()     // Catch:{ all -> 0x01f4 }
                X.9eg r0 = (X.C51039eg) r0     // Catch:{ all -> 0x01f4 }
                long r13 = android.os.SystemClock.uptimeMillis()     // Catch:{ all -> 0x01f4 }
                r0.LIZ(r11, r6)     // Catch:{ all -> 0x01f4 }
                java.lang.String r10 = r0.LIZ()     // Catch:{ all -> 0x01f4 }
                long r0 = android.os.SystemClock.uptimeMillis()     // Catch:{ all -> 0x01f4 }
                long r0 = r0 - r13
                X.M12.LIZ(r10)     // Catch:{ all -> 0x01f4 }
                java.util.HashMap<java.lang.String, java.lang.Long> r9 = r12.LIZLLL     // Catch:{ all -> 0x01f4 }
                java.util.HashMap<java.lang.String, java.lang.Long> r3 = r12.LIZLLL     // Catch:{ all -> 0x01f4 }
                java.lang.Object r3 = r3.get(r10)     // Catch:{ all -> 0x01f4 }
                java.lang.Long r3 = (java.lang.Long) r3     // Catch:{ all -> 0x01f4 }
                long r0 = r12.LIZ((long) r0, (java.lang.Long) r3)     // Catch:{ all -> 0x01f4 }
                java.lang.Long r0 = java.lang.Long.valueOf(r0)     // Catch:{ all -> 0x01f4 }
                r9.put(r10, r0)     // Catch:{ all -> 0x01f4 }
                goto L_0x0181
            L_0x01b6:
                X.9ef r11 = r11.LIZ()     // Catch:{ all -> 0x01f4 }
                r8.LIZ(r7, r11, r2)     // Catch:{ all -> 0x01f4 }
                java.lang.String r2 = r7.getPath()
                long r0 = android.os.SystemClock.uptimeMillis()
                long r0 = r0 - r19
                r4.LIZIZ = r0
                X.9fa r0 = LIZJ
                android.os.Handler r1 = r0.LIZ()
                X.9fS r0 = new X.9fS
                r0.<init>(r2, r5, r4)
                goto L_0x01ec
            L_0x01d5:
                java.lang.String r2 = r7.getPath()
                long r0 = android.os.SystemClock.uptimeMillis()
                long r0 = r0 - r19
                r4.LIZIZ = r0
                X.9fa r0 = LIZJ
                android.os.Handler r1 = r0.LIZ()
                X.9fS r0 = new X.9fS
                r0.<init>(r2, r5, r4)
            L_0x01ec:
                r1.post(r0)
                return r11
            L_0x01f0:
                r8.LIZ(r7, r2, r0)     // Catch:{ all -> 0x01f4 }
                throw r0     // Catch:{ all -> 0x01f4 }
            L_0x01f4:
                r3 = move-exception
                java.lang.String r2 = r7.getPath()
                long r0 = android.os.SystemClock.uptimeMillis()
                long r0 = r0 - r19
                r4.LIZIZ = r0
                X.9fa r0 = LIZJ
                android.os.Handler r1 = r0.LIZ()
                X.9fS r0 = new X.9fS
                r0.<init>(r2, r5, r4)
                r1.post(r0)
                throw r3
            */
            throw new UnsupportedOperationException("Method not decompiled: com.bytedance.frameworks.baselib.netx.partner.NetworkPartnerGroup.PartnerInterceptor.intercept(X.9fP):X.9ef");
        }

        private final C51029ef<?> LIZIZ(C51339fA r8, C51499fQ r9) {
            C51529fT r6 = r9.LIZJ;
            try {
                for (C51069ej next : this.LIZLLL) {
                    long uptimeMillis = SystemClock.uptimeMillis();
                    next.LIZIZ(r8, r9);
                    r6.LIZ(next.LIZ(), SystemClock.uptimeMillis() - uptimeMillis);
                }
                return null;
            } catch (Throwable th) {
                Object LIZ2 = 2th.LIZ(th);
                2te.constructor-impl(LIZ2);
                Throwable r0 = 2te.exceptionOrNull-impl(LIZ2);
                if (r0 == null) {
                    return (C51029ef) LIZ2;
                }
                LIZ(r0);
                throw r0;
            }
        }

        private final C51029ef<?> LIZ(C51339fA r9, C51499fQ r10) {
            C51529fT r7 = r10.LIZJ;
            try {
                for (C51069ej next : this.LIZLLL) {
                    long uptimeMillis = SystemClock.uptimeMillis();
                    C51029ef<?> LIZ2 = next.LIZ(r9, r10);
                    r7.LIZ(next.LIZ(), SystemClock.uptimeMillis() - uptimeMillis);
                    if (LIZ2 != null) {
                        return LIZ2;
                    }
                }
                return null;
            } catch (Throwable th) {
                Object LIZ3 = 2th.LIZ(th);
                2te.constructor-impl(LIZ3);
                Throwable r0 = 2te.exceptionOrNull-impl(LIZ3);
                if (r0 == null) {
                    return (C51029ef) LIZ3;
                }
                LIZ(r0);
                throw r0;
            }
        }

        private final void LIZ(Request request, C51029ef<?> r4, Throwable th) {
            LIZJ.LIZ().post(new C51539fU(this, request, r4, th));
        }
    }

    public final NetworkPartnerGroup LIZ(C50959eY r2) {
        M12.LIZ(r2);
        if (r2 instanceof C51559fW) {
            this.LJ.add(r2);
            return this;
        }
        if (r2 instanceof C51069ej) {
            this.LIZ.add(r2);
        }
        if (r2 instanceof C50969eZ) {
            this.LIZLLL.add(r2);
        }
        if (r2 instanceof C51039eg) {
            this.LIZJ.add(r2);
        }
        if (r2 instanceof C50949eX) {
            this.LIZIZ.add(r2);
        }
        return this;
    }

    public final NetworkPartnerGroup LIZ(NetworkPartnerGroup networkPartnerGroup) {
        M12.LIZ(networkPartnerGroup);
        this.LIZ.addAll(networkPartnerGroup.LIZ);
        this.LIZIZ.addAll(networkPartnerGroup.LIZIZ);
        this.LIZJ.addAll(networkPartnerGroup.LIZJ);
        this.LIZLLL.addAll(networkPartnerGroup.LIZLLL);
        this.LJ.addAll(networkPartnerGroup.LJ);
        return this;
    }
}
