package com.google.firebase.messaging;

import L1.C0108j0;
import L1.C0146w0;
import L1.X;
import a.AbstractC0212a;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.util.SparseArray;
import c0.C0333a;
import c0.C0334b;
import c1.InterfaceC0336b;
import c4.InterfaceC0342a;
import com.google.android.gms.internal.measurement.A1;
import com.google.android.gms.internal.measurement.AbstractC0366e2;
import com.google.android.gms.internal.measurement.C0358d;
import com.google.android.gms.internal.measurement.C0368f;
import com.google.android.gms.internal.measurement.C0373g;
import com.google.android.gms.internal.measurement.C0403m;
import com.google.android.gms.internal.measurement.C0413o;
import com.google.android.gms.internal.measurement.C0437t;
import com.google.android.gms.internal.measurement.C0450v2;
import com.google.android.gms.internal.measurement.C0459x1;
import com.google.android.gms.internal.measurement.CallableC0364e0;
import com.google.android.gms.internal.measurement.I1;
import com.google.android.gms.internal.measurement.InterfaceC0408n;
import com.google.android.gms.internal.measurement.J1;
import com.google.android.gms.internal.measurement.P3;
import com.google.android.gms.internal.measurement.u4;
import e4.C0575s;
import i1.InterfaceC0623c;
import io.flutter.Build;
import io.flutter.Log;
import io.flutter.embedding.android.AndroidTouchProcessor;
import io.flutter.embedding.engine.FlutterJNI;
import io.sentry.A0;
import io.sentry.C0668a;
import io.sentry.C0705b1;
import io.sentry.C0717f1;
import io.sentry.C0720g1;
import io.sentry.C0723h1;
import io.sentry.C0732k1;
import io.sentry.C0755q;
import io.sentry.C0773w0;
import io.sentry.C0775x;
import io.sentry.C1;
import io.sentry.CallableC0708c1;
import io.sentry.CallableC0711d1;
import io.sentry.E1;
import io.sentry.EnumC0721h;
import io.sentry.EnumC0735l1;
import io.sentry.EnumC0738m1;
import io.sentry.F0;
import io.sentry.ILogger;
import io.sentry.InterfaceC0763t;
import io.sentry.InterfaceC0765t1;
import io.sentry.InterfaceC0771v1;
import io.sentry.K0;
import io.sentry.M0;
import io.sentry.O;
import io.sentry.O1;
import io.sentry.P1;
import io.sentry.RunnableC0758r0;
import io.sentry.S;
import io.sentry.SpotlightIntegration;
import io.sentry.U;
import io.sentry.V1;
import io.sentry.W;
import io.sentry.W0;
import io.sentry.X0;
import io.sentry.X1;
import io.sentry.Y1;
import io.sentry.android.core.C0689t;
import io.sentry.flutter.SentryFlutter;
import io.sentry.protocol.C0750c;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.security.GeneralSecurityException;
import java.security.InvalidAlgorithmParameterException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import p0.AbstractC0928a;
import r.C0966e;
import r.C0968g;
import r4.AbstractC0983h;
import u2.C1069e;

/* JADX INFO: loaded from: classes.dex */
public final class w implements InterfaceC0336b, io.sentry.G {

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public static w f5942o;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public Object f5943k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public Object f5944l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public Object f5945m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public Object f5946n;

    public w(C0108j0 c0108j0, String str) {
        Objects.requireNonNull(c0108j0);
        this.f5946n = c0108j0;
        s1.z.d(str);
        this.f5943k = str;
        this.f5944l = new Bundle();
    }

    public static boolean J(Context context, ILogger iLogger, io.sentry.android.core.D d3, ConnectivityManager.NetworkCallback networkCallback) {
        d3.getClass();
        ConnectivityManager connectivityManagerU = u(context, iLogger);
        if (connectivityManagerU == null) {
            return false;
        }
        if (!A1.r(context)) {
            iLogger.j(EnumC0738m1.INFO, "No permission (ACCESS_NETWORK_STATE) to check network status.", new Object[0]);
            return false;
        }
        try {
            connectivityManagerU.registerDefaultNetworkCallback(networkCallback);
            return true;
        } catch (Throwable th) {
            iLogger.p(EnumC0738m1.WARNING, "registerDefaultNetworkCallback failed", th);
            return false;
        }
    }

    public static ArrayList t(C0775x c0775x) {
        ArrayList arrayList = new ArrayList(c0775x.f8265b);
        C0668a c0668a = c0775x.f8266c;
        if (c0668a != null) {
            arrayList.add(c0668a);
        }
        C0668a c0668a2 = c0775x.f8267d;
        if (c0668a2 != null) {
            arrayList.add(c0668a2);
        }
        C0668a c0668a3 = c0775x.f8268e;
        if (c0668a3 != null) {
            arrayList.add(c0668a3);
        }
        return arrayList;
    }

    public static ConnectivityManager u(Context context, ILogger iLogger) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
        if (connectivityManager == null) {
            iLogger.j(EnumC0738m1.INFO, "ConnectivityManager is null and cannot check network status", new Object[0]);
        }
        return connectivityManager;
    }

    public static synchronized w v() {
        try {
            if (f5942o == null) {
                f5942o = new w(0);
            }
        } catch (Throwable th) {
            throw th;
        }
        return f5942o;
    }

    public void A(String str, Object... objArr) {
        String str2 = String.format(Locale.US, str, objArr);
        if (((B2.c) this.f5946n) != null) {
            Log.d(FlutterJNI.TAG, str2);
        }
    }

    public void B(String str, AbstractC0212a abstractC0212a) {
        AbstractC0983h.e("method", str);
        if (str.length() <= 0) {
            throw new IllegalArgumentException("method.isEmpty() == true");
        }
        if (abstractC0212a == null) {
            if (str.equals("POST") || str.equals("PUT") || str.equals("PATCH") || str.equals("PROPPATCH") || str.equals("REPORT")) {
                throw new IllegalArgumentException(AbstractC0928a.l("method ", str, " must have a request body.").toString());
            }
        } else if (!AbstractC0366e2.q(str)) {
            throw new IllegalArgumentException(AbstractC0928a.l("method ", str, " must not have a request body.").toString());
        }
        this.f5943k = str;
    }

    public void C(IOException iOException) {
        ((c5.f) this.f5946n).d(true, 8, iOException.getMessage(), iOException, null);
        ((c5.f) this.f5946n).f4755r = null;
    }

    /* JADX WARN: Removed duplicated region for block: B:37:0x0091  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public void D(K4.u r11) {
        /*
            r10 = this;
            java.lang.Object r0 = r10.f5946n
            r1 = r0
            c5.f r1 = (c5.f) r1
            r0 = 200(0xc8, float:2.8E-43)
            int r2 = r11.f1226n
            r5 = 8
            if (r0 > r2) goto L12
            r0 = 300(0x12c, float:4.2E-43)
            if (r2 >= r0) goto L12
            goto L2b
        L12:
            java.lang.StringBuilder r0 = new java.lang.StringBuilder
            java.lang.String r3 = "Http request finished with status "
            r0.<init>(r3)
            r0.append(r2)
            java.lang.String r6 = r0.toString()
            r7 = 0
            r8 = 0
            java.lang.Object r0 = r10.f5946n
            r3 = r0
            c5.f r3 = (c5.f) r3
            r4 = 1
            r3.d(r4, r5, r6, r7, r8)
        L2b:
            r9 = 0
            java.lang.Object r0 = r10.f5944l     // Catch: java.lang.RuntimeException -> L45 java.io.IOException -> L49 R4.E -> Lb3
            java.io.File r0 = (java.io.File) r0     // Catch: java.lang.RuntimeException -> L45 java.io.IOException -> L49 R4.E -> Lb3
            X4.b r0 = S4.d.H(r0)     // Catch: java.lang.RuntimeException -> L4b java.io.IOException -> L4e R4.E -> Lb3
            X4.n r2 = new X4.n     // Catch: java.lang.RuntimeException -> L45 java.io.IOException -> L49 R4.E -> Lb3
            r2.<init>(r0)     // Catch: java.lang.RuntimeException -> L45 java.io.IOException -> L49 R4.E -> Lb3
            K4.w r11 = r11.q     // Catch: java.lang.RuntimeException -> L45 java.io.IOException -> L49 R4.E -> Lb3
            if (r11 == 0) goto L50
            X4.g r11 = r11.e()     // Catch: java.lang.RuntimeException -> L4b java.io.IOException -> L4e R4.E -> Lb3
            r2.e(r11)     // Catch: java.lang.RuntimeException -> L45 java.io.IOException -> L49 R4.E -> Lb3
            goto L50
        L45:
            r0 = move-exception
            goto L4c
        L47:
            r7 = r11
            goto La2
        L49:
            r0 = move-exception
            goto L4c
        L4b:
            r0 = move-exception
        L4c:
            r11 = r0
            goto L47
        L4e:
            r0 = move-exception
            goto L4c
        L50:
            r2.close()     // Catch: java.lang.RuntimeException -> L45 java.io.IOException -> L49 R4.E -> Lb3
            r1.getClass()
            java.io.File r11 = new java.io.File
            java.lang.Object r0 = r10.f5943k
            java.lang.String r0 = (java.lang.String) r0
            r11.<init>(r0)
            boolean r0 = r11.exists()
            if (r0 != 0) goto L6f
            r2 = 1
            java.lang.String r4 = "File was not downloaded"
            r3 = r5
            r5 = 0
            r6 = 0
            r1.d(r2, r3, r4, r5, r6)
            goto L9f
        L6f:
            java.lang.String r0 = r1.f4759v
            if (r0 == 0) goto L91
            r3 = 9
            boolean r0 = b5.a.I(r0, r11)     // Catch: java.lang.RuntimeException -> L84
            if (r0 != 0) goto L91
            java.lang.String r4 = "Checksum verification failed"
            r5 = 0
            r6 = 0
            r2 = 1
            r1.d(r2, r3, r4, r5, r6)     // Catch: java.lang.RuntimeException -> L84
            goto L9f
        L84:
            r0 = move-exception
            r11 = r0
            r5 = r11
            java.lang.String r4 = r5.getMessage()
            r6 = 0
            r2 = 1
            r1.d(r2, r3, r4, r5, r6)
            goto L9f
        L91:
            c5.e r0 = r1.f4753n
            F.j r2 = new F.j
            java.lang.Object r3 = r10.f5945m
            android.net.Uri r3 = (android.net.Uri) r3
            r2.<init>(r1, r3, r11)
            r0.post(r2)
        L9f:
            r1.f4755r = r9
            goto Lb5
        La2:
            java.lang.String r6 = r7.getMessage()
            r4 = 1
            r8 = 0
            java.lang.Object r11 = r10.f5946n
            r3 = r11
            c5.f r3 = (c5.f) r3
            r3.d(r4, r5, r6, r7, r8)
            r1.f4755r = r9
            goto Lb5
        Lb3:
            r1.f4755r = r9
        Lb5:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.messaging.w.D(K4.u):void");
    }

    public C0723h1 E(C0723h1 c0723h1, C0775x c0775x, List list) {
        C1 c12 = (C1) this.f5943k;
        Iterator it = list.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            InterfaceC0763t interfaceC0763t = (InterfaceC0763t) it.next();
            try {
                boolean z5 = interfaceC0763t instanceof C0689t;
                boolean zIsInstance = io.sentry.hints.b.class.isInstance(AbstractC0212a.v(c0775x));
                if (zIsInstance && z5) {
                    ((C0689t) interfaceC0763t).f(c0723h1, c0775x);
                } else if (!zIsInstance && !z5) {
                    c0723h1 = interfaceC0763t.f(c0723h1, c0775x);
                }
            } catch (Throwable th) {
                c12.getLogger().o(EnumC0738m1.ERROR, th, "An exception occurred while processing event by processor: %s", interfaceC0763t.getClass().getName());
            }
            if (c0723h1 == null) {
                c12.getLogger().j(EnumC0738m1.DEBUG, "Event was dropped by a processor: %s", interfaceC0763t.getClass().getName());
                c12.getClientReportRecorder().f(io.sentry.clientreport.d.EVENT_PROCESSOR, EnumC0721h.Error);
                break;
            }
        }
        return c0723h1;
    }

    public io.sentry.protocol.A F(io.sentry.protocol.A a5, C0775x c0775x, List list) {
        C1 c12 = (C1) this.f5943k;
        Iterator it = list.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            InterfaceC0763t interfaceC0763t = (InterfaceC0763t) it.next();
            int size = a5.f7900C.size();
            try {
                a5 = interfaceC0763t.e(a5, c0775x);
            } catch (Throwable th) {
                c12.getLogger().o(EnumC0738m1.ERROR, th, "An exception occurred while processing transaction by processor: %s", interfaceC0763t.getClass().getName());
            }
            int size2 = a5 == null ? 0 : a5.f7900C.size();
            if (a5 == null) {
                c12.getLogger().j(EnumC0738m1.DEBUG, "Transaction was dropped by a processor: %s", interfaceC0763t.getClass().getName());
                io.sentry.clientreport.f clientReportRecorder = c12.getClientReportRecorder();
                io.sentry.clientreport.d dVar = io.sentry.clientreport.d.EVENT_PROCESSOR;
                clientReportRecorder.f(dVar, EnumC0721h.Transaction);
                c12.getClientReportRecorder().k(dVar, EnumC0721h.Span, size + 1);
                break;
            }
            if (size2 < size) {
                int i = size - size2;
                c12.getLogger().j(EnumC0738m1.DEBUG, "%d spans were dropped by a processor: %s", Integer.valueOf(i), interfaceC0763t.getClass().getName());
                c12.getClientReportRecorder().k(io.sentry.clientreport.d.EVENT_PROCESSOR, EnumC0721h.Span, i);
            }
        }
        return a5;
    }

    /* JADX WARN: Code restructure failed: missing block: B:17:0x0039, code lost:
    
        if (r3 < 5) goto L64;
     */
    /* JADX WARN: Code restructure failed: missing block: B:19:0x003c, code lost:
    
        r0.remove();
        r2.f2333l.incrementAndGet();
        r1.add(r2);
        ((java.util.ArrayDeque) r14.f5944l).add(r2);
     */
    /* JADX WARN: Removed duplicated region for block: B:28:0x006b  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public void G() {
        /*
            Method dump skipped, instruction units count: 232
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.messaging.w.G():void");
    }

    public void H(A2.a aVar) throws GeneralSecurityException {
        aVar.getClass();
        A2.r rVar = new A2.r(A2.p.class, aVar.f24a);
        HashMap map = (HashMap) this.f5944l;
        if (!map.containsKey(rVar)) {
            map.put(rVar, aVar);
            return;
        }
        A2.a aVar2 = (A2.a) map.get(rVar);
        if (aVar2.equals(aVar) && aVar.equals(aVar2)) {
            return;
        }
        throw new GeneralSecurityException("Attempt to register non-equal parser for already existing object of type: " + rVar);
    }

    public void I(A2.c cVar) throws GeneralSecurityException {
        A2.s sVar = new A2.s(cVar.f26a, A2.p.class);
        HashMap map = (HashMap) this.f5943k;
        if (!map.containsKey(sVar)) {
            map.put(sVar, cVar);
            return;
        }
        A2.c cVar2 = (A2.c) map.get(sVar);
        if (cVar2.equals(cVar) && cVar.equals(cVar2)) {
            return;
        }
        throw new GeneralSecurityException("Attempt to register non-equal serializer for already existing object of type: " + sVar);
    }

    public void K(A2.k kVar) throws GeneralSecurityException {
        kVar.getClass();
        A2.r rVar = new A2.r(A2.q.class, kVar.f40a);
        HashMap map = (HashMap) this.f5946n;
        if (!map.containsKey(rVar)) {
            map.put(rVar, kVar);
            return;
        }
        A2.k kVar2 = (A2.k) map.get(rVar);
        if (kVar2.equals(kVar) && kVar.equals(kVar2)) {
            return;
        }
        throw new GeneralSecurityException("Attempt to register non-equal parser for already existing object of type: " + rVar);
    }

    public void L(A2.l lVar) throws GeneralSecurityException {
        A2.s sVar = new A2.s(lVar.f41a, A2.q.class);
        HashMap map = (HashMap) this.f5945m;
        if (!map.containsKey(sVar)) {
            map.put(sVar, lVar);
            return;
        }
        A2.l lVar2 = (A2.l) map.get(sVar);
        if (lVar2.equals(lVar) && lVar.equals(lVar2)) {
            return;
        }
        throw new GeneralSecurityException("Attempt to register non-equal serializer for already existing object of type: " + sVar);
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public java.lang.Object M(j4.AbstractC0801c r10) throws java.lang.Throwable {
        /*
            r9 = this;
            boolean r0 = r10 instanceof W.f0
            if (r0 == 0) goto L13
            r0 = r10
            W.f0 r0 = (W.f0) r0
            int r1 = r0.f3130n
            r2 = -2147483648(0xffffffff80000000, float:-0.0)
            r3 = r1 & r2
            if (r3 == 0) goto L13
            int r1 = r1 - r2
            r0.f3130n = r1
            goto L18
        L13:
            W.f0 r0 = new W.f0
            r0.<init>(r9, r10)
        L18:
            java.lang.Object r10 = r0.f3128l
            i4.a r1 = i4.EnumC0643a.f6670k
            int r2 = r0.f3130n
            d4.i r3 = d4.C0550i.f6143a
            r4 = 2
            r5 = 1
            java.lang.Object r6 = r9.f5944l
            B4.p r6 = (B4.C0020p) r6
            r7 = 0
            if (r2 == 0) goto L44
            if (r2 == r5) goto L3d
            if (r2 != r4) goto L35
            J4.a r0 = r0.f3127k
            a.AbstractC0212a.H(r10)     // Catch: java.lang.Throwable -> L33
            goto L83
        L33:
            r10 = move-exception
            goto L92
        L35:
            java.lang.IllegalStateException r10 = new java.lang.IllegalStateException
            java.lang.String r0 = "call to 'resume' before 'invoke' with coroutine"
            r10.<init>(r0)
            throw r10
        L3d:
            J4.a r2 = r0.f3127k
            a.AbstractC0212a.H(r10)
            r10 = r2
            goto L64
        L44:
            a.AbstractC0212a.H(r10)
            r6.getClass()
            java.util.concurrent.atomic.AtomicReferenceFieldUpdater r10 = B4.e0.f239k
            java.lang.Object r10 = r10.get(r6)
            boolean r10 = r10 instanceof B4.T
            if (r10 != 0) goto L55
            return r3
        L55:
            java.lang.Object r10 = r9.f5943k
            J4.e r10 = (J4.e) r10
            r0.f3127k = r10
            r0.f3130n = r5
            java.lang.Object r2 = r10.c(r0)
            if (r2 != r1) goto L64
            goto L81
        L64:
            r6.getClass()     // Catch: java.lang.Throwable -> L90
            java.util.concurrent.atomic.AtomicReferenceFieldUpdater r2 = B4.e0.f239k     // Catch: java.lang.Throwable -> L90
            java.lang.Object r2 = r2.get(r6)     // Catch: java.lang.Throwable -> L90
            boolean r2 = r2 instanceof B4.T     // Catch: java.lang.Throwable -> L90
            if (r2 != 0) goto L77
            J4.e r10 = (J4.e) r10
            r10.e(r7)
            return r3
        L77:
            r0.f3127k = r10     // Catch: java.lang.Throwable -> L90
            r0.f3130n = r4     // Catch: java.lang.Throwable -> L90
            java.lang.Object r0 = r9.r(r0)     // Catch: java.lang.Throwable -> L90
            if (r0 != r1) goto L82
        L81:
            return r1
        L82:
            r0 = r10
        L83:
            r6.I(r3)     // Catch: java.lang.Throwable -> L33
            J4.e r0 = (J4.e) r0
            r0.e(r7)
            return r3
        L8c:
            r8 = r0
            r0 = r10
            r10 = r8
            goto L92
        L90:
            r0 = move-exception
            goto L8c
        L92:
            J4.e r0 = (J4.e) r0
            r0.e(r7)
            throw r10
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.messaging.w.M(j4.c):java.lang.Object");
    }

    public io.sentry.protocol.t N(io.sentry.internal.debugmeta.c cVar, C0775x c0775x) {
        C1 c12 = (C1) this.f5943k;
        InterfaceC0765t1 beforeEnvelopeCallback = c12.getBeforeEnvelopeCallback();
        if (beforeEnvelopeCallback != null) {
            try {
                SpotlightIntegration spotlightIntegration = (SpotlightIntegration) beforeEnvelopeCallback;
                try {
                    spotlightIntegration.f7026m.submit(new F.j(16, spotlightIntegration, cVar));
                } catch (RejectedExecutionException e2) {
                    spotlightIntegration.f7025l.p(EnumC0738m1.WARNING, "Spotlight envelope submission rejected.", e2);
                }
            } catch (Throwable th) {
                c12.getLogger().p(EnumC0738m1.ERROR, "The BeforeEnvelope callback threw an exception.", th);
            }
        }
        ((io.sentry.transport.f) this.f5944l).i(cVar, c0775x);
        io.sentry.protocol.t tVar = ((C0705b1) cVar.f7826l).f7675k;
        return tVar != null ? tVar : io.sentry.protocol.t.f8041l;
    }

    public boolean O(W0 w02, C0775x c0775x) {
        if (AbstractC0212a.F(c0775x)) {
            return true;
        }
        ((C1) this.f5943k).getLogger().j(EnumC0738m1.DEBUG, "Event was cached so not applying scope: %s", w02.f7048k);
        return false;
    }

    public void P(String str) {
        AbstractC0983h.e("url", str);
        if (A4.q.H(str, "ws:", true)) {
            String strSubstring = str.substring(3);
            AbstractC0983h.d("this as java.lang.String).substring(startIndex)", strSubstring);
            str = AbstractC0983h.h("http:", strSubstring);
        } else if (A4.q.H(str, "wss:", true)) {
            String strSubstring2 = str.substring(4);
            AbstractC0983h.d("this as java.lang.String).substring(startIndex)", strSubstring2);
            str = AbstractC0983h.h("https:", strSubstring2);
        }
        AbstractC0983h.e("<this>", str);
        K4.n nVar = new K4.n();
        nVar.c(null, str);
        this.f5944l = nVar.a();
    }

    /* JADX WARN: Removed duplicated region for block: B:37:0x0090  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x0095  */
    /* JADX WARN: Removed duplicated region for block: B:59:0x011b A[Catch: NumberFormatException | JSONException -> 0x0123, NumberFormatException | JSONException -> 0x0123, TRY_LEAVE, TryCatch #0 {NumberFormatException | JSONException -> 0x0123, blocks: (B:10:0x0031, B:44:0x009d, B:44:0x009d, B:45:0x00ab, B:45:0x00ab, B:47:0x00b8, B:47:0x00b8, B:49:0x00ca, B:49:0x00ca, B:50:0x00d3, B:50:0x00d3, B:51:0x00d7, B:51:0x00d7, B:53:0x00e4, B:53:0x00e4, B:55:0x00f6, B:55:0x00f6, B:56:0x00ff, B:56:0x00ff, B:57:0x0103, B:57:0x0103, B:58:0x010f, B:58:0x010f, B:59:0x011b, B:59:0x011b), top: B:71:0x0031, outer: #1 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public android.os.Bundle Q() {
        /*
            Method dump skipped, instruction units count: 347
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.messaging.w.Q():android.os.Bundle");
    }

    public InterfaceC0408n R(InterfaceC0408n interfaceC0408n) {
        return ((C0437t) this.f5944l).c(this, interfaceC0408n);
    }

    public InterfaceC0408n S(w wVar, C0459x1... c0459x1Arr) {
        InterfaceC0408n interfaceC0408nE = InterfaceC0408n.f5181c;
        for (C0459x1 c0459x1 : c0459x1Arr) {
            interfaceC0408nE = AbstractC0366e2.E(c0459x1);
            J1.F((w) this.f5945m);
            if ((interfaceC0408nE instanceof C0413o) || (interfaceC0408nE instanceof C0403m)) {
                interfaceC0408nE = ((C0437t) this.f5943k).c(wVar, interfaceC0408nE);
            }
        }
        return interfaceC0408nE;
    }

    public InterfaceC0408n T(C0358d c0358d) {
        InterfaceC0408n interfaceC0408nC = InterfaceC0408n.f5181c;
        Iterator itS = c0358d.s();
        while (itS.hasNext()) {
            interfaceC0408nC = ((C0437t) this.f5944l).c(this, c0358d.v(((Integer) itS.next()).intValue()));
            if (interfaceC0408nC instanceof C0368f) {
                break;
            }
        }
        return interfaceC0408nC;
    }

    public void U(Bundle bundle) {
        Iterator<String> it;
        JSONObject jSONObject;
        boolean zU;
        X x5;
        Bundle bundle2 = bundle == null ? new Bundle() : new Bundle(bundle);
        C0108j0 c0108j0 = (C0108j0) this.f5946n;
        SharedPreferences sharedPreferencesO = c0108j0.o();
        C0146w0 c0146w0 = (C0146w0) c0108j0.f29k;
        SharedPreferences.Editor editorEdit = sharedPreferencesO.edit();
        int size = bundle2.size();
        String str = (String) this.f5943k;
        if (size == 0) {
            editorEdit.remove(str);
        } else {
            JSONArray jSONArray = new JSONArray();
            Iterator<String> it2 = bundle2.keySet().iterator();
            while (it2.hasNext()) {
                String next = it2.next();
                Object obj = bundle2.get(next);
                if (obj != null) {
                    try {
                        jSONObject = new JSONObject();
                        jSONObject.put("n", next);
                        P3.a();
                        zU = c0146w0.f2035n.u(null, L1.F.Q0);
                        x5 = c0146w0.p;
                    } catch (JSONException e2) {
                        e = e2;
                        it = it2;
                    }
                    if (zU) {
                        it = it2;
                        try {
                        } catch (JSONException e6) {
                            e = e6;
                            X x6 = c0146w0.p;
                            C0146w0.l(x6);
                            x6.p.c("Cannot serialize bundle value to SharedPreferences", e);
                        }
                        if (obj instanceof String) {
                            jSONObject.put("v", obj.toString());
                            jSONObject.put("t", "s");
                        } else if (obj instanceof Long) {
                            jSONObject.put("v", obj.toString());
                            jSONObject.put("t", "l");
                        } else if (obj instanceof int[]) {
                            jSONObject.put("v", Arrays.toString((int[]) obj));
                            jSONObject.put("t", "ia");
                        } else if (obj instanceof long[]) {
                            jSONObject.put("v", Arrays.toString((long[]) obj));
                            jSONObject.put("t", "la");
                        } else if (obj instanceof Double) {
                            jSONObject.put("v", obj.toString());
                            jSONObject.put("t", "d");
                        } else {
                            C0146w0.l(x5);
                            x5.p.c("Cannot serialize bundle value to SharedPreferences. Type", obj.getClass());
                            it2 = it;
                        }
                        jSONArray.put(jSONObject);
                        it2 = it;
                    } else {
                        it = it2;
                        jSONObject.put("v", obj.toString());
                        if (obj instanceof String) {
                            jSONObject.put("t", "s");
                        } else if (obj instanceof Long) {
                            jSONObject.put("t", "l");
                        } else if (obj instanceof Double) {
                            jSONObject.put("t", "d");
                        } else {
                            C0146w0.l(x5);
                            x5.p.c("Cannot serialize bundle value to SharedPreferences. Type", obj.getClass());
                            it2 = it;
                        }
                        jSONArray.put(jSONObject);
                        it2 = it;
                    }
                }
            }
            editorEdit.putString(str, jSONArray.toString());
        }
        editorEdit.apply();
        this.f5945m = bundle2;
    }

    public w V() {
        return new w(this, (C0437t) this.f5944l);
    }

    public boolean W(String str) {
        if (((HashMap) this.f5945m).containsKey(str)) {
            return true;
        }
        w wVar = (w) this.f5943k;
        if (wVar != null) {
            return wVar.W(str);
        }
        return false;
    }

    public void X(String str, InterfaceC0408n interfaceC0408n) {
        w wVar;
        HashMap map = (HashMap) this.f5945m;
        if (!map.containsKey(str) && (wVar = (w) this.f5943k) != null && wVar.W(str)) {
            wVar.X(str, interfaceC0408n);
        } else {
            if (((HashMap) this.f5946n).containsKey(str)) {
                return;
            }
            if (interfaceC0408n == null) {
                map.remove(str);
            } else {
                map.put(str, interfaceC0408n);
            }
        }
    }

    public void Y(String str, InterfaceC0408n interfaceC0408n) {
        if (((HashMap) this.f5946n).containsKey(str)) {
            return;
        }
        HashMap map = (HashMap) this.f5945m;
        if (interfaceC0408n == null) {
            map.remove(str);
        } else {
            map.put(str, interfaceC0408n);
        }
    }

    public InterfaceC0408n Z(String str) {
        HashMap map = (HashMap) this.f5945m;
        if (map.containsKey(str)) {
            return (InterfaceC0408n) map.get(str);
        }
        w wVar = (w) this.f5943k;
        if (wVar != null) {
            return wVar.Z(str);
        }
        throw new IllegalArgumentException(s0.c.c(str, " is not defined"));
    }

    @Override // io.sentry.G
    public io.sentry.E a() {
        Context context = (Context) this.f5943k;
        ILogger iLogger = (ILogger) this.f5944l;
        ConnectivityManager connectivityManagerU = u(context, iLogger);
        if (connectivityManagerU == null) {
            return io.sentry.E.UNKNOWN;
        }
        if (!A1.r(context)) {
            iLogger.j(EnumC0738m1.INFO, "No permission (ACCESS_NETWORK_STATE) to check network status.", new Object[0]);
            return io.sentry.E.NO_PERMISSION;
        }
        try {
            NetworkInfo activeNetworkInfo = connectivityManagerU.getActiveNetworkInfo();
            if (activeNetworkInfo != null) {
                return activeNetworkInfo.isConnected() ? io.sentry.E.CONNECTED : io.sentry.E.DISCONNECTED;
            }
            iLogger.j(EnumC0738m1.INFO, "NetworkInfo is null, there's no active network.", new Object[0]);
            return io.sentry.E.DISCONNECTED;
        } catch (Throwable th) {
            iLogger.p(EnumC0738m1.WARNING, "Could not retrieve Connection Status", th);
            return io.sentry.E.UNKNOWN;
        }
    }

    @Override // io.sentry.G
    public boolean b(io.sentry.F f6) {
        io.sentry.android.core.D d3 = (io.sentry.android.core.D) this.f5945m;
        d3.getClass();
        io.sentry.android.core.internal.util.a aVar = new io.sentry.android.core.internal.util.a(this, f6);
        ((HashMap) this.f5946n).put(f6, aVar);
        return J((Context) this.f5943k, (ILogger) this.f5944l, d3, aVar);
    }

    @Override // io.sentry.G
    public String c() {
        io.sentry.android.core.D d3 = (io.sentry.android.core.D) this.f5945m;
        Context context = (Context) this.f5943k;
        ILogger iLogger = (ILogger) this.f5944l;
        ConnectivityManager connectivityManagerU = u(context, iLogger);
        if (connectivityManagerU != null) {
            if (!A1.r(context)) {
                iLogger.j(EnumC0738m1.INFO, "No permission (ACCESS_NETWORK_STATE) to check network status.", new Object[0]);
                return null;
            }
            try {
                d3.getClass();
                Network activeNetwork = connectivityManagerU.getActiveNetwork();
                if (activeNetwork == null) {
                    iLogger.j(EnumC0738m1.INFO, "Network is null and cannot check network status", new Object[0]);
                    return null;
                }
                NetworkCapabilities networkCapabilities = connectivityManagerU.getNetworkCapabilities(activeNetwork);
                if (networkCapabilities == null) {
                    iLogger.j(EnumC0738m1.INFO, "NetworkCapabilities is null and cannot check network type", new Object[0]);
                    return null;
                }
                boolean zHasTransport = networkCapabilities.hasTransport(3);
                boolean zHasTransport2 = networkCapabilities.hasTransport(1);
                boolean zHasTransport3 = networkCapabilities.hasTransport(0);
                if (zHasTransport) {
                    return "ethernet";
                }
                if (zHasTransport2) {
                    return "wifi";
                }
                if (zHasTransport3) {
                    return "cellular";
                }
            } catch (Throwable th) {
                iLogger.p(EnumC0738m1.ERROR, "Failed to retrieve network info", th);
            }
        }
        return null;
    }

    @Override // io.sentry.G
    public void d(io.sentry.F f6) {
        ConnectivityManager.NetworkCallback networkCallback = (ConnectivityManager.NetworkCallback) ((HashMap) this.f5946n).remove(f6);
        if (networkCallback != null) {
            ((io.sentry.android.core.D) this.f5945m).getClass();
            Context context = (Context) this.f5943k;
            ILogger iLogger = (ILogger) this.f5944l;
            ConnectivityManager connectivityManagerU = u(context, iLogger);
            if (connectivityManagerU == null) {
                return;
            }
            try {
                connectivityManagerU.unregisterNetworkCallback(networkCallback);
            } catch (Throwable th) {
                iLogger.p(EnumC0738m1.WARNING, "unregisterNetworkCallback failed", th);
            }
        }
    }

    public void e(W0 w02, O o5) {
        if (o5 != null) {
            if (w02.f7051n == null) {
                w02.f7051n = ((M0) o5).f6950d;
            }
            if (w02.f7054s == null) {
                w02.f7054s = ((M0) o5).f6948b;
            }
            if (w02.f7052o == null) {
                w02.f7052o = new HashMap(new HashMap(S4.d.A(((M0) o5).f6953g)));
            } else {
                for (Map.Entry entry : S4.d.A(((M0) o5).f6953g).entrySet()) {
                    if (!w02.f7052o.containsKey(entry.getKey())) {
                        w02.f7052o.put((String) entry.getKey(), (String) entry.getValue());
                    }
                }
            }
            List list = w02.f7058w;
            if (list == null) {
                w02.f7058w = new ArrayList(new ArrayList(((M0) o5).f6952f));
            } else {
                V1 v12 = ((M0) o5).f6952f;
                if (!v12.isEmpty()) {
                    list.addAll(v12);
                    Collections.sort(list, (X0) this.f5945m);
                }
            }
            if (w02.f7060y == null) {
                w02.f7060y = new HashMap(new HashMap(((M0) o5).f6954h));
            } else {
                for (Map.Entry entry2 : ((M0) o5).f6954h.entrySet()) {
                    if (!w02.f7060y.containsKey(entry2.getKey())) {
                        w02.f7060y.put((String) entry2.getKey(), entry2.getValue());
                    }
                }
            }
            Iterator it = new C0750c(((M0) o5).f6960o).entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry entry3 = (Map.Entry) it.next();
                Object key = entry3.getKey();
                C0750c c0750c = w02.f7049l;
                if (!c0750c.containsKey(key)) {
                    c0750c.put((String) entry3.getKey(), entry3.getValue());
                }
            }
        }
    }

    public B2.o f() throws GeneralSecurityException {
        Integer num = (Integer) this.f5943k;
        if (num == null) {
            throw new GeneralSecurityException("key size is not set");
        }
        if (((Integer) this.f5944l) == null) {
            throw new GeneralSecurityException("tag size is not set");
        }
        if (((B2.g) this.f5945m) == null) {
            throw new GeneralSecurityException("hash type is not set");
        }
        if (((B2.g) this.f5946n) == null) {
            throw new GeneralSecurityException("variant is not set");
        }
        if (num.intValue() < 16) {
            throw new InvalidAlgorithmParameterException(String.format("Invalid key size in bytes %d; must be at least 16 bytes", (Integer) this.f5943k));
        }
        Integer num2 = (Integer) this.f5944l;
        int iIntValue = num2.intValue();
        B2.g gVar = (B2.g) this.f5945m;
        if (iIntValue < 10) {
            throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; must be at least 10 bytes", num2));
        }
        if (gVar == B2.g.f149g) {
            if (iIntValue > 20) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 20 bytes for SHA1", num2));
            }
        } else if (gVar == B2.g.f150h) {
            if (iIntValue > 28) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 28 bytes for SHA224", num2));
            }
        } else if (gVar == B2.g.i) {
            if (iIntValue > 32) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 32 bytes for SHA256", num2));
            }
        } else if (gVar == B2.g.f151j) {
            if (iIntValue > 48) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 48 bytes for SHA384", num2));
            }
        } else {
            if (gVar != B2.g.f152k) {
                throw new GeneralSecurityException("unknown hash type; must be SHA256, SHA384 or SHA512");
            }
            if (iIntValue > 64) {
                throw new GeneralSecurityException(String.format("Invalid tag size in bytes %d; can be at most 64 bytes for SHA512", num2));
            }
        }
        return new B2.o(((Integer) this.f5943k).intValue(), ((Integer) this.f5944l).intValue(), (B2.g) this.f5946n, (B2.g) this.f5945m);
    }

    public F3.e g() {
        Map mapUnmodifiableMap;
        K4.o oVar = (K4.o) this.f5944l;
        if (oVar == null) {
            throw new IllegalStateException("url == null");
        }
        String str = (String) this.f5943k;
        K4.m mVarB = ((K4.l) this.f5945m).b();
        LinkedHashMap linkedHashMap = (LinkedHashMap) this.f5946n;
        byte[] bArr = L4.b.f2100a;
        AbstractC0983h.e("<this>", linkedHashMap);
        if (linkedHashMap.isEmpty()) {
            mapUnmodifiableMap = C0575s.f6260k;
        } else {
            mapUnmodifiableMap = Collections.unmodifiableMap(new LinkedHashMap(linkedHashMap));
            AbstractC0983h.d("{\n    Collections.unmodi…(LinkedHashMap(this))\n  }", mapUnmodifiableMap);
        }
        return new F3.e(oVar, str, mVarB, null, mapUnmodifiableMap);
    }

    @Override // c4.InterfaceC0342a
    public Object get() {
        return new g1.k((Executor) ((InterfaceC0342a) this.f5943k).get(), (h1.d) ((InterfaceC0342a) this.f5944l).get(), (g1.d) ((B2.a) this.f5945m).get(), (InterfaceC0623c) ((InterfaceC0342a) this.f5946n).get());
    }

    public C1069e h() throws GeneralSecurityException {
        g3.c cVar;
        u2.h hVar = (u2.h) this.f5943k;
        if (hVar == null) {
            throw new GeneralSecurityException("Cannot build without parameters");
        }
        g3.c cVar2 = (g3.c) this.f5944l;
        if (cVar2 == null || (cVar = (g3.c) this.f5945m) == null) {
            throw new GeneralSecurityException("Cannot build without key material");
        }
        if (hVar.f10340b != ((H2.a) cVar2.f6465l).f873a.length) {
            throw new GeneralSecurityException("AES key size mismatch");
        }
        if (hVar.f10341c != ((H2.a) cVar.f6465l).f873a.length) {
            throw new GeneralSecurityException("HMAC key size mismatch");
        }
        u2.g gVar = u2.g.f10324j;
        u2.g gVar2 = hVar.f10343e;
        if (gVar2 != gVar && ((Integer) this.f5946n) == null) {
            throw new GeneralSecurityException("Cannot create key without ID requirement with parameters with ID requirement");
        }
        if (gVar2 == gVar && ((Integer) this.f5946n) != null) {
            throw new GeneralSecurityException("Cannot create key with ID requirement with parameters without ID requirement");
        }
        if (gVar2 == gVar) {
            H2.a.a(new byte[0]);
        } else if (gVar2 == u2.g.i) {
            H2.a.a(ByteBuffer.allocate(5).put((byte) 0).putInt(((Integer) this.f5946n).intValue()).array());
        } else {
            if (gVar2 != u2.g.f10323h) {
                throw new IllegalStateException("Unknown AesCtrHmacAeadParameters.Variant: " + ((u2.h) this.f5943k).f10343e);
            }
            H2.a.a(ByteBuffer.allocate(5).put((byte) 1).putInt(((Integer) this.f5946n).intValue()).array());
        }
        return new C1069e();
    }

    public io.sentry.internal.debugmeta.c i(W0 w02, ArrayList arrayList, O1 o12, X1 x12, F0 f02) {
        io.sentry.protocol.t tVar;
        int i = 2;
        ArrayList arrayList2 = new ArrayList();
        C1 c12 = (C1) this.f5943k;
        if (w02 != null) {
            S serializer = c12.getSerializer();
            Charset charset = C0717f1.f7770d;
            A1.v("ISerializer is required.", serializer);
            C0732k1 c0732k1 = new C0732k1(new CallableC0505i(i, serializer, w02));
            arrayList2.add(new C0717f1(new C0720g1(EnumC0735l1.resolve(w02), new CallableC0708c1(c0732k1, 4), "application/json", (String) null, (String) null), new CallableC0708c1(c0732k1, 5)));
            tVar = w02.f7048k;
        } else {
            tVar = null;
        }
        if (o12 != null) {
            arrayList2.add(C0717f1.b(c12.getSerializer(), o12));
        }
        if (f02 != null) {
            long maxTraceFileSize = c12.getMaxTraceFileSize();
            S serializer2 = c12.getSerializer();
            Charset charset2 = C0717f1.f7770d;
            File file = f02.f6903k;
            C0732k1 c0732k12 = new C0732k1(new CallableC0711d1(file, maxTraceFileSize, f02, serializer2));
            arrayList2.add(new C0717f1(new C0720g1(EnumC0735l1.Profile, new CallableC0708c1(c0732k12, i), "application-json", file.getName(), (String) null), new CallableC0708c1(c0732k12, 3)));
            if (tVar == null) {
                tVar = new io.sentry.protocol.t(f02.f6899G);
            }
        }
        if (arrayList != null) {
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                C0668a c0668a = (C0668a) it.next();
                S serializer3 = c12.getSerializer();
                ILogger logger = c12.getLogger();
                long maxAttachmentSize = c12.getMaxAttachmentSize();
                Charset charset3 = C0717f1.f7770d;
                C0732k1 c0732k13 = new C0732k1(new CallableC0711d1(c0668a, maxAttachmentSize, serializer3, logger));
                arrayList2.add(new C0717f1(new C0720g1(EnumC0735l1.Attachment, new CallableC0708c1(c0732k13, 0), c0668a.f7091d, c0668a.f7090c, c0668a.f7092e), new CallableC0708c1(c0732k13, 1)));
            }
        }
        if (arrayList2.isEmpty()) {
            return null;
        }
        return new io.sentry.internal.debugmeta.c(new C0705b1(tVar, c12.getSdkVersion(), x12), arrayList2);
    }

    public io.sentry.internal.debugmeta.c j(final E1 e1, final K0 k02, X1 x12, final boolean z5) {
        ArrayList arrayList = new ArrayList();
        C1 c12 = (C1) this.f5943k;
        final S serializer = c12.getSerializer();
        final ILogger logger = c12.getLogger();
        Charset charset = C0717f1.f7770d;
        final File file = e1.f6892z;
        C0732k1 c0732k1 = new C0732k1(new Callable() { // from class: io.sentry.e1
            @Override // java.util.concurrent.Callable
            public final Object call() {
                S s5 = serializer;
                E1 e12 = e1;
                File file2 = file;
                ILogger iLogger = logger;
                boolean z6 = z5;
                try {
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    try {
                        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(byteArrayOutputStream, C0717f1.f7770d));
                        try {
                            LinkedHashMap linkedHashMap = new LinkedHashMap();
                            s5.d(e12, bufferedWriter);
                            linkedHashMap.put(EnumC0735l1.ReplayEvent.getItemType(), byteArrayOutputStream.toByteArray());
                            byteArrayOutputStream.reset();
                            K0 k03 = k02;
                            if (k03 != null) {
                                s5.d(k03, bufferedWriter);
                                linkedHashMap.put(EnumC0735l1.ReplayRecording.getItemType(), byteArrayOutputStream.toByteArray());
                                byteArrayOutputStream.reset();
                            }
                            if (file2 != null && file2.exists()) {
                                byte[] bArrX = S4.m.x(file2.getPath(), 10485760L);
                                if (bArrX.length > 0) {
                                    linkedHashMap.put(EnumC0735l1.ReplayVideo.getItemType(), bArrX);
                                }
                            }
                            byte[] bArrG = C0717f1.g(linkedHashMap);
                            bufferedWriter.close();
                            byteArrayOutputStream.close();
                            if (file2 != null) {
                                if (z6) {
                                    return bArrG;
                                }
                            }
                            return bArrG;
                        } finally {
                        }
                    } finally {
                    }
                } catch (Throwable th) {
                    try {
                        iLogger.p(EnumC0738m1.ERROR, "Could not serialize replay recording", th);
                        if (file2 == null) {
                            return null;
                        }
                        if (z6) {
                            S4.m.g(file2.getParentFile());
                            return null;
                        }
                        file2.delete();
                        return null;
                    } finally {
                        if (file2 != null) {
                            if (z6) {
                                S4.m.g(file2.getParentFile());
                            } else {
                                file2.delete();
                            }
                        }
                    }
                }
            }
        });
        arrayList.add(new C0717f1(new C0720g1(EnumC0735l1.ReplayVideo, new CallableC0708c1(c0732k1, 12), (String) null, (String) null, (String) null), new CallableC0708c1(c0732k1, 13)));
        return new io.sentry.internal.debugmeta.c(new C0705b1(e1.f7048k, c12.getSessionReplay().f6932k, x12), arrayList);
    }

    public io.sentry.protocol.t k(io.sentry.internal.debugmeta.c cVar, C0775x c0775x) {
        if (c0775x == null) {
            c0775x = new C0775x();
        }
        try {
            c0775x.a();
            return N(cVar, c0775x);
        } catch (IOException e2) {
            ((C1) this.f5943k).getLogger().p(EnumC0738m1.ERROR, "Failed to capture envelope.", e2);
            return io.sentry.protocol.t.f8041l;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:108:0x01eb  */
    /* JADX WARN: Removed duplicated region for block: B:182:0x02df  */
    /* JADX WARN: Removed duplicated region for block: B:188:0x02f9  */
    /* JADX WARN: Removed duplicated region for block: B:189:0x0308  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public io.sentry.protocol.t l(io.sentry.C0723h1 r11, io.sentry.O r12, io.sentry.C0775x r13) {
        /*
            Method dump skipped, instruction units count: 782
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.messaging.w.l(io.sentry.h1, io.sentry.O, io.sentry.x):io.sentry.protocol.t");
    }

    public io.sentry.protocol.t m(E1 e1, M0 m02, C0775x c0775x) {
        C0750c c0750c;
        P1 p1A;
        if (O(e1, c0775x) && m02 != null) {
            if (e1.f7051n == null) {
                e1.f7051n = m02.f6950d;
            }
            if (e1.f7054s == null) {
                e1.f7054s = m02.f6948b;
            }
            if (e1.f7052o == null) {
                e1.f7052o = new HashMap(new HashMap(S4.d.A(m02.f6953g)));
            } else {
                for (Map.Entry entry : S4.d.A(m02.f6953g).entrySet()) {
                    if (!e1.f7052o.containsKey(entry.getKey())) {
                        e1.f7052o.put((String) entry.getKey(), (String) entry.getValue());
                    }
                }
            }
            Iterator it = new C0750c(m02.f6960o).entrySet().iterator();
            while (true) {
                boolean zHasNext = it.hasNext();
                c0750c = e1.f7049l;
                if (!zHasNext) {
                    break;
                }
                Map.Entry entry2 = (Map.Entry) it.next();
                if (!c0750c.containsKey(entry2.getKey())) {
                    c0750c.put((String) entry2.getKey(), entry2.getValue());
                }
            }
            U u5 = m02.f6947a;
            if (u5 != null && (p1A = u5.a()) != null) {
                u5 = p1A;
            }
            if (c0750c.a() == null) {
                if (u5 == null) {
                    c0750c.c(Y1.a(m02.q));
                } else {
                    c0750c.c(u5.l());
                }
            }
        }
        C1 c12 = (C1) this.f5943k;
        c12.getLogger().j(EnumC0738m1.DEBUG, "Capturing session replay: %s", e1.f7048k);
        io.sentry.protocol.t tVar = io.sentry.protocol.t.f8041l;
        io.sentry.protocol.t tVar2 = e1.f7048k;
        if (tVar2 != null) {
            tVar = tVar2;
        }
        Iterator<InterfaceC0763t> it2 = c12.getEventProcessors().iterator();
        while (true) {
            if (!it2.hasNext()) {
                break;
            }
            InterfaceC0763t next = it2.next();
            try {
                e1 = next.a(e1, c0775x);
            } catch (Throwable th) {
                c12.getLogger().o(EnumC0738m1.ERROR, th, "An exception occurred while processing replay event by processor: %s", next.getClass().getName());
            }
            if (e1 == null) {
                c12.getLogger().j(EnumC0738m1.DEBUG, "Replay event was dropped by a processor: %s", next.getClass().getName());
                c12.getClientReportRecorder().f(io.sentry.clientreport.d.EVENT_PROCESSOR, EnumC0721h.Replay);
                break;
            }
        }
        X1 x1F = null;
        if (e1 != null) {
            InterfaceC0771v1 beforeSendReplay = c12.getBeforeSendReplay();
            if (beforeSendReplay != null) {
                try {
                    e1 = SentryFlutter.updateReplayOptions$lambda$4((Map) ((N2.a) beforeSendReplay).f2181l, e1, c0775x);
                } catch (Throwable th2) {
                    c12.getLogger().p(EnumC0738m1.ERROR, "The BeforeSendReplay callback threw an exception. It will be added as breadcrumb and continue.", th2);
                    e1 = null;
                }
            }
            if (e1 == null) {
                c12.getLogger().j(EnumC0738m1.DEBUG, "Event was dropped by beforeSendReplay", new Object[0]);
                c12.getClientReportRecorder().f(io.sentry.clientreport.d.BEFORE_SEND, EnumC0721h.Replay);
            }
        }
        if (e1 == null) {
            return io.sentry.protocol.t.f8041l;
        }
        if (m02 != null) {
            try {
                U u6 = m02.f6947a;
                if (u6 != null) {
                    x1F = u6.b();
                } else {
                    I1 i12 = (I1) m02.e(new C0503g(13, c12, m02)).f134l;
                    if (i12 != null) {
                        x1F = i12.f();
                    }
                }
            } catch (IOException e2) {
                c12.getLogger().o(EnumC0738m1.WARNING, e2, "Capturing event %s failed.", tVar);
                return io.sentry.protocol.t.f8041l;
            }
        }
        io.sentry.internal.debugmeta.c cVarJ = j(e1, c0775x.f8269f, x1F, io.sentry.hints.b.class.isInstance(AbstractC0212a.v(c0775x)));
        c0775x.a();
        ((io.sentry.transport.f) this.f5944l).i(cVarJ, c0775x);
        return tVar;
    }

    public void n(O1 o12, C0775x c0775x) {
        A1.v("Session is required.", o12);
        C1 c12 = (C1) this.f5943k;
        String str = o12.f6987w;
        if (str == null || str.isEmpty()) {
            c12.getLogger().j(EnumC0738m1.WARNING, "Sessions can't be captured without setting a release.", new Object[0]);
            return;
        }
        try {
            S serializer = c12.getSerializer();
            io.sentry.protocol.r sdkVersion = c12.getSdkVersion();
            A1.v("Serializer is required.", serializer);
            k(new io.sentry.internal.debugmeta.c((io.sentry.protocol.t) null, sdkVersion, C0717f1.b(serializer, o12)), c0775x);
        } catch (IOException e2) {
            c12.getLogger().p(EnumC0738m1.ERROR, "Failed to capture session.", e2);
        }
    }

    public io.sentry.protocol.t o(io.sentry.protocol.A a5, X1 x12, M0 m02, C0775x c0775x, F0 f02) {
        io.sentry.protocol.A aF;
        C0775x c0775x2 = c0775x == null ? new C0775x() : c0775x;
        if (O(a5, c0775x2) && m02 != null) {
            c0775x2.f8265b.addAll(new CopyOnWriteArrayList(m02.p));
        }
        C1 c12 = (C1) this.f5943k;
        ILogger logger = c12.getLogger();
        EnumC0738m1 enumC0738m1 = EnumC0738m1.DEBUG;
        logger.j(enumC0738m1, "Capturing transaction: %s", a5.f7048k);
        io.sentry.protocol.t tVar = io.sentry.protocol.t.f8041l;
        io.sentry.protocol.t tVar2 = a5.f7048k;
        io.sentry.protocol.t tVar3 = tVar2 != null ? tVar2 : tVar;
        if (O(a5, c0775x2)) {
            e(a5, m02);
            aF = m02 != null ? F(a5, c0775x2, m02.i) : a5;
            if (aF == null) {
                c12.getLogger().j(enumC0738m1, "Transaction was dropped by applyScope", new Object[0]);
            }
        } else {
            aF = a5;
        }
        if (aF != null) {
            aF = F(aF, c0775x2, c12.getEventProcessors());
        }
        io.sentry.protocol.A a6 = aF;
        if (a6 == null) {
            c12.getLogger().j(enumC0738m1, "Transaction was dropped by Event processors.", new Object[0]);
            return tVar;
        }
        ArrayList arrayList = a6.f7900C;
        int size = arrayList.size();
        c12.getBeforeSendTransaction();
        int size2 = arrayList.size();
        if (size2 < size) {
            int i = size - size2;
            c12.getLogger().j(enumC0738m1, "%d spans were dropped by beforeSendTransaction.", Integer.valueOf(i));
            c12.getClientReportRecorder().k(io.sentry.clientreport.d.BEFORE_SEND, EnumC0721h.Span, i);
        }
        try {
            ArrayList arrayListT = t(c0775x2);
            ArrayList arrayList2 = new ArrayList();
            Iterator it = arrayListT.iterator();
            while (it.hasNext()) {
                ((C0668a) it.next()).getClass();
            }
            io.sentry.internal.debugmeta.c cVarI = i(a6, arrayList2, null, x12, f02);
            c0775x2.a();
            return cVarI != null ? N(cVarI, c0775x2) : tVar3;
        } catch (io.sentry.exception.b | IOException e2) {
            c12.getLogger().o(EnumC0738m1.WARNING, e2, "Capturing transaction %s failed.", tVar3);
            return io.sentry.protocol.t.f8041l;
        }
    }

    public void p(boolean z5) {
        long shutdownTimeoutMillis;
        io.sentry.transport.f fVar = (io.sentry.transport.f) this.f5944l;
        C1 c12 = (C1) this.f5943k;
        c12.getLogger().j(EnumC0738m1.INFO, "Closing SentryClient.", new Object[0]);
        try {
            ((io.sentry.J) this.f5946n).close();
        } catch (IOException e2) {
            c12.getLogger().p(EnumC0738m1.WARNING, "Failed to close the metrics aggregator.", e2);
        }
        if (z5) {
            shutdownTimeoutMillis = 0;
        } else {
            try {
                shutdownTimeoutMillis = c12.getShutdownTimeoutMillis();
            } catch (IOException e6) {
                c12.getLogger().p(EnumC0738m1.WARNING, "Failed to close the connection to the Sentry Server.", e6);
            }
        }
        fVar.j(shutdownTimeoutMillis);
        fVar.b(z5);
        for (InterfaceC0763t interfaceC0763t : c12.getEventProcessors()) {
            if (interfaceC0763t instanceof Closeable) {
                try {
                    ((Closeable) interfaceC0763t).close();
                } catch (IOException e7) {
                    c12.getLogger().j(EnumC0738m1.WARNING, "Failed to close the event processor {}.", interfaceC0763t, e7);
                }
            }
        }
    }

    public void q(Object obj, ArrayList arrayList, HashSet hashSet) {
        if (arrayList.contains(obj)) {
            return;
        }
        if (hashSet.contains(obj)) {
            throw new RuntimeException("This graph contains cyclic dependencies");
        }
        hashSet.add(obj);
        ArrayList arrayList2 = (ArrayList) ((r.j) this.f5944l).get(obj);
        if (arrayList2 != null) {
            int size = arrayList2.size();
            for (int i = 0; i < size; i++) {
                q(arrayList2.get(i), arrayList, hashSet);
            }
        }
        hashSet.remove(obj);
        arrayList.add(obj);
    }

    /* JADX WARN: Code restructure failed: missing block: B:22:0x005a, code lost:
    
        if (r7 == r1) goto L27;
     */
    /* JADX WARN: Code restructure failed: missing block: B:26:0x0067, code lost:
    
        if (r7 == r1) goto L27;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public java.lang.Object r(j4.AbstractC0801c r7) throws java.lang.Throwable {
        /*
            r6 = this;
            boolean r0 = r7 instanceof W.C0197k
            if (r0 == 0) goto L13
            r0 = r7
            W.k r0 = (W.C0197k) r0
            int r1 = r0.f3158m
            r2 = -2147483648(0xffffffff80000000, float:-0.0)
            r3 = r1 & r2
            if (r3 == 0) goto L13
            int r1 = r1 - r2
            r0.f3158m = r1
            goto L18
        L13:
            W.k r0 = new W.k
            r0.<init>(r6, r7)
        L18:
            java.lang.Object r7 = r0.f3156k
            i4.a r1 = i4.EnumC0643a.f6670k
            int r2 = r0.f3158m
            r3 = 2
            r4 = 1
            java.lang.Object r5 = r6.f5946n
            W.O r5 = (W.O) r5
            if (r2 == 0) goto L3a
            if (r2 == r4) goto L36
            if (r2 != r3) goto L2e
            a.AbstractC0212a.H(r7)
            goto L5d
        L2e:
            java.lang.IllegalStateException r7 = new java.lang.IllegalStateException
            java.lang.String r0 = "call to 'resume' before 'invoke' with coroutine"
            r7.<init>(r0)
            throw r7
        L36:
            a.AbstractC0212a.H(r7)
            goto L6a
        L3a:
            a.AbstractC0212a.H(r7)
            java.lang.Object r7 = r6.f5945m
            java.util.List r7 = (java.util.List) r7
            if (r7 == 0) goto L60
            boolean r7 = r7.isEmpty()
            if (r7 == 0) goto L4a
            goto L60
        L4a:
            W.l0 r7 = r5.h()
            W.n r2 = new W.n
            r4 = 0
            r2.<init>(r5, r6, r4)
            r0.f3158m = r3
            java.lang.Object r7 = r7.b(r2, r0)
            if (r7 != r1) goto L5d
            goto L69
        L5d:
            W.d r7 = (W.C0190d) r7
            goto L6c
        L60:
            r0.f3158m = r4
            r7 = 0
            java.lang.Object r7 = W.O.g(r5, r7, r0)
            if (r7 != r1) goto L6a
        L69:
            return r1
        L6a:
            W.d r7 = (W.C0190d) r7
        L6c:
            S.g r0 = r5.f3073h
            r0.Y(r7)
            d4.i r7 = d4.C0550i.f6143a
            return r7
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.firebase.messaging.w.r(j4.c):java.lang.Object");
    }

    public void s(O4.e eVar) {
        eVar.f2333l.decrementAndGet();
        ArrayDeque arrayDeque = (ArrayDeque) this.f5944l;
        synchronized (this) {
            if (!arrayDeque.remove(eVar)) {
                throw new AssertionError("Call wasn't in-flight!");
            }
            synchronized (this) {
            }
            G();
        }
        G();
    }

    public File w(Context context) {
        ((L1.B) this.f5944l).getClass();
        return new File(context.getDir("lib", 0), System.mapLibraryName("flutter"));
    }

    public boolean x(Context context) {
        if (((Boolean) this.f5945m) == null) {
            this.f5945m = Boolean.valueOf(context.checkCallingOrSelfPermission("android.permission.ACCESS_NETWORK_STATE") == 0);
        }
        if (!((Boolean) this.f5944l).booleanValue() && android.util.Log.isLoggable("FirebaseMessaging", 3)) {
            android.util.Log.d("FirebaseMessaging", "Missing Permission: android.permission.ACCESS_NETWORK_STATE this should normally be included by the manifest merger, but may needed to be manually added to your manifest");
        }
        return ((Boolean) this.f5945m).booleanValue();
    }

    public boolean y(Context context) {
        if (((Boolean) this.f5944l) == null) {
            this.f5944l = Boolean.valueOf(context.checkCallingOrSelfPermission("android.permission.WAKE_LOCK") == 0);
        }
        if (!((Boolean) this.f5944l).booleanValue() && android.util.Log.isLoggable("FirebaseMessaging", 3)) {
            android.util.Log.d("FirebaseMessaging", "Missing Permission: android.permission.WAKE_LOCK this should normally be included by the manifest merger, but may needed to be manually added to your manifest");
        }
        return ((Boolean) this.f5944l).booleanValue();
    }

    public void z(String str, String str2) {
        AbstractC0983h.e("value", str2);
        K4.l lVar = (K4.l) this.f5945m;
        lVar.getClass();
        S4.d.g(str);
        S4.d.l(str2, str);
        lVar.h(str);
        lVar.a(str, str2);
    }

    public w(w wVar, C0437t c0437t) {
        this.f5945m = new HashMap();
        this.f5946n = new HashMap();
        this.f5943k = wVar;
        this.f5944l = c0437t;
    }

    public w(Boolean bool, Double d3) {
        this(bool, d3, Boolean.FALSE, null);
    }

    public w(Boolean bool, Double d3, Boolean bool2, Double d6) {
        this.f5944l = bool;
        this.f5943k = d3;
        this.f5945m = Boolean.valueOf(bool.booleanValue() && bool2.booleanValue());
        this.f5946n = d6;
    }

    public w(C1 c12) {
        Object runnableC0758r0;
        this.f5945m = new X0();
        this.f5943k = c12;
        W transportFactory = c12.getTransportFactory();
        if (transportFactory instanceof A0) {
            transportFactory = new C0773w0(5);
            c12.setTransportFactory(transportFactory);
        }
        C0755q c0755qRetrieveParsedDsn = c12.retrieveParsedDsn();
        URI uri = c0755qRetrieveParsedDsn.f8093c;
        String string = uri.resolve(uri.getPath() + "/envelope/").toString();
        StringBuilder sb = new StringBuilder("Sentry sentry_version=7,sentry_client=");
        sb.append(c12.getSentryClientName());
        sb.append(",sentry_key=");
        sb.append(c0755qRetrieveParsedDsn.f8092b);
        String str = c0755qRetrieveParsedDsn.f8091a;
        sb.append((str == null || str.length() <= 0) ? "" : ",sentry_secret=".concat(str));
        String string2 = sb.toString();
        String sentryClientName = c12.getSentryClientName();
        HashMap map = new HashMap();
        map.put("User-Agent", sentryClientName);
        map.put("X-Sentry-Auth", string2);
        this.f5944l = transportFactory.n(c12, new io.sentry.internal.debugmeta.c(string, map));
        if (c12.isEnableMetrics()) {
            runnableC0758r0 = new RunnableC0758r0(c12, this);
        } else {
            runnableC0758r0 = io.sentry.metrics.d.f7875k;
        }
        this.f5946n = runnableC0758r0;
    }

    public w(A2.t tVar) {
        this.f5943k = new HashMap(tVar.f59a);
        this.f5944l = new HashMap(tVar.f60b);
        this.f5945m = new HashMap(tVar.f61c);
        this.f5946n = new HashMap(tVar.f62d);
    }

    public w(Typeface typeface, C0334b c0334b) {
        int i;
        int i5;
        int i6;
        int i7;
        this.f5946n = typeface;
        this.f5943k = c0334b;
        this.f5945m = new b0.q(1024);
        int iA = c0334b.a(6);
        if (iA != 0) {
            int i8 = iA + c0334b.f2381a;
            i = ((ByteBuffer) c0334b.f2384d).getInt(((ByteBuffer) c0334b.f2384d).getInt(i8) + i8);
        } else {
            i = 0;
        }
        this.f5944l = new char[i * 2];
        int iA2 = c0334b.a(6);
        if (iA2 != 0) {
            int i9 = iA2 + c0334b.f2381a;
            i5 = ((ByteBuffer) c0334b.f2384d).getInt(((ByteBuffer) c0334b.f2384d).getInt(i9) + i9);
        } else {
            i5 = 0;
        }
        for (int i10 = 0; i10 < i5; i10++) {
            b0.m mVar = new b0.m(this, i10);
            C0333a c0333aB = mVar.b();
            int iA3 = c0333aB.a(4);
            Character.toChars(iA3 != 0 ? ((ByteBuffer) c0333aB.f2384d).getInt(iA3 + c0333aB.f2381a) : 0, (char[]) this.f5944l, i10 * 2);
            C0333a c0333aB2 = mVar.b();
            int iA4 = c0333aB2.a(16);
            if (iA4 != 0) {
                int i11 = iA4 + c0333aB2.f2381a;
                i6 = ((ByteBuffer) c0333aB2.f2384d).getInt(((ByteBuffer) c0333aB2.f2384d).getInt(i11) + i11);
            } else {
                i6 = 0;
            }
            S4.d.c("invalid metadata codepoint length", i6 > 0);
            C0333a c0333aB3 = mVar.b();
            int iA5 = c0333aB3.a(16);
            if (iA5 != 0) {
                int i12 = iA5 + c0333aB3.f2381a;
                i7 = ((ByteBuffer) c0333aB3.f2384d).getInt(((ByteBuffer) c0333aB3.f2384d).getInt(i12) + i12);
            } else {
                i7 = 0;
            }
            ((b0.q) this.f5945m).a(mVar, 0, i7 - 1);
        }
    }

    public w(int i) {
        switch (i) {
            case 1:
                this.f5943k = new HashMap();
                this.f5944l = new HashMap();
                this.f5945m = new HashMap();
                this.f5946n = new HashMap();
                break;
            case 2:
                this.f5943k = new O.b(10);
                this.f5944l = new r.j(0);
                this.f5945m = new ArrayList();
                this.f5946n = new HashSet();
                break;
            case 4:
                this.f5946n = new ArrayDeque();
                this.f5944l = new ArrayDeque();
                this.f5945m = new ArrayDeque();
                break;
            case 5:
                this.f5946n = new LinkedHashMap();
                this.f5943k = "GET";
                this.f5945m = new K4.l(0);
                break;
            case AndroidTouchProcessor.PointerChange.PAN_ZOOM_END /* 9 */:
                L1.B b2 = new L1.B(18);
                L1.A a5 = new L1.A(18);
                this.f5943k = new HashSet();
                this.f5944l = b2;
                this.f5945m = a5;
                break;
            case 12:
                C0437t c0437t = new C0437t(0);
                this.f5943k = c0437t;
                w wVar = new w((w) null, c0437t);
                this.f5945m = wVar;
                this.f5944l = wVar.V();
                C0450v2 c0450v2 = new C0450v2(1);
                this.f5946n = c0450v2;
                wVar.X("require", new u4(c0450v2));
                ((HashMap) c0450v2.f5257k).put("internal.platform", CallableC0364e0.f5060a);
                wVar.X("runtime.counter", new C0373g(Double.valueOf(0.0d)));
                break;
            case Build.API_LEVELS.API_21 /* 21 */:
                this.f5943k = new C0966e(0);
                this.f5944l = new SparseArray();
                this.f5945m = new C0968g();
                this.f5946n = new C0966e(0);
                break;
            default:
                this.f5943k = null;
                this.f5944l = null;
                this.f5945m = null;
                this.f5946n = new ArrayDeque();
                break;
        }
    }
}
