package B3;

import android.text.TextUtils;
import android.util.Log;
import d3.C;
import g4.C0988c;
import java.io.IOException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Objects;
import org.json.JSONObject;
import u.AbstractC1563h;

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

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public String f975b;

    public static void b(com.google.android.material.datepicker.c cVar, s4.d dVar) {
        String str = dVar.f16872a;
        if (str != null) {
            cVar.w("X-CRASHLYTICS-GOOGLE-APP-ID", str);
        }
        cVar.w("X-CRASHLYTICS-API-CLIENT-TYPE", "android");
        cVar.w("X-CRASHLYTICS-API-CLIENT-VERSION", "19.4.3");
        cVar.w("Accept", "application/json");
        String str2 = dVar.f16873b;
        if (str2 != null) {
            cVar.w("X-CRASHLYTICS-DEVICE-MODEL", str2);
        }
        String str3 = dVar.f16874c;
        if (str3 != null) {
            cVar.w("X-CRASHLYTICS-OS-BUILD-VERSION", str3);
        }
        String str4 = dVar.f16875d;
        if (str4 != null) {
            cVar.w("X-CRASHLYTICS-OS-DISPLAY-VERSION", str4);
        }
        String str5 = dVar.f16876e.c().f13848a;
        if (str5 != null) {
            cVar.w("X-CRASHLYTICS-INSTALLATION-ID", str5);
        }
    }

    public static HashMap c(s4.d dVar) {
        HashMap map = new HashMap();
        map.put("build_version", dVar.f16879h);
        map.put("display_version", dVar.f16878g);
        map.put("source", Integer.toString(dVar.i));
        String str = dVar.f16877f;
        if (!TextUtils.isEmpty(str)) {
            map.put("instance", str);
        }
        return map;
    }

    public static f e(x0.o oVar) {
        String str;
        oVar.G(2);
        int iT = oVar.t();
        int i = iT >> 1;
        int iT2 = ((oVar.t() >> 3) & 31) | ((iT & 1) << 5);
        if (i == 4 || i == 5 || i == 7 || i == 8) {
            str = "dvhe";
        } else if (i == 9) {
            str = "dvav";
        } else {
            if (i != 10) {
                return null;
            }
            str = "dav1";
        }
        StringBuilder sbB = AbstractC1563h.b(str);
        sbB.append(i < 10 ? ".0" : ".");
        sbB.append(i);
        sbB.append(iT2 < 10 ? ".0" : ".");
        sbB.append(iT2);
        return new f(2, sbB.toString());
    }

    public void a(StringBuilder sb, Iterator it) {
        try {
            if (it.hasNext()) {
                Object next = it.next();
                Objects.requireNonNull(next);
                sb.append(next instanceof CharSequence ? (CharSequence) next : next.toString());
                while (it.hasNext()) {
                    sb.append((CharSequence) this.f975b);
                    Object next2 = it.next();
                    Objects.requireNonNull(next2);
                    sb.append(next2 instanceof CharSequence ? (CharSequence) next2 : next2.toString());
                }
            }
        } catch (IOException e8) {
            throw new AssertionError(e8);
        }
    }

    public JSONObject d(B7.a aVar) {
        StringBuilder sb = new StringBuilder("Settings response code was: ");
        int i = aVar.f1039r;
        sb.append(i);
        String string = sb.toString();
        C0988c c0988c = C0988c.f12956a;
        c0988c.f(string);
        String str = this.f975b;
        if (i == 200 || i == 201 || i == 202 || i == 203) {
            String str2 = (String) aVar.f1040s;
            try {
                return new JSONObject(str2);
            } catch (Exception e8) {
                c0988c.g("Failed to parse settings JSON from " + str, e8);
                c0988c.g("Settings response " + str2, null);
            }
        } else {
            String str3 = "Settings request failed; (status: " + i + ") from " + str;
            if (c0988c.b(6)) {
                Log.e("FirebaseCrashlytics", str3, null);
                return null;
            }
        }
        return null;
    }

    public String toString() {
        boolean zContainsAlias;
        switch (this.f974a) {
            case 3:
                StringBuilder sb = new StringBuilder("MasterKey{keyAlias=");
                String str = this.f975b;
                sb.append(str);
                sb.append(", isKeyStoreBacked=");
                try {
                    KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
                    keyStore.load(null);
                    zContainsAlias = keyStore.containsAlias(str);
                    break;
                } catch (IOException | KeyStoreException | NoSuchAlgorithmException | CertificateException unused) {
                    zContainsAlias = false;
                }
                sb.append(zContainsAlias);
                sb.append("}");
                return sb.toString();
            case 4:
            default:
                return super.toString();
            case 5:
                return "<" + this.f975b + '>';
        }
    }

    public /* synthetic */ f(int i, String str) {
        this.f974a = i;
        this.f975b = str;
    }

    public f(String str, C c3) {
        this.f974a = 8;
        if (str != null) {
            this.f975b = str;
            return;
        }
        throw new IllegalArgumentException("url must not be null.");
    }

    public f(String str) {
        this.f974a = 0;
        str.getClass();
        this.f975b = str;
    }

    public f(Object obj, String str) {
        this.f974a = 3;
        this.f975b = str;
    }
}
