package defpackage;

import android.app.Application;
import android.content.Context;
import com.google.firebase.remoteconfig.internal.ConfigFetchHttpClient;
import j$.util.concurrent.ConcurrentHashMap;
import java.util.Collections;
import java.util.HashMap;
import java.util.Random;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicReference;

/* renamed from: ˏˑˆˁ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C1849 implements InterfaceC2053 {

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public static final Random f7467 = new Random();

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public static final HashMap f7468 = new HashMap();

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final InterfaceC0466 f7469;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final InterfaceC3290 f7470;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final C1096 f7471;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final ScheduledExecutorService f7472;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final Context f7475;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final String f7476;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final C2288 f7477;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final HashMap f7474 = new HashMap();

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final HashMap f7473 = new HashMap();

    public C1849(Context context, ScheduledExecutorService scheduledExecutorService, C2288 c2288, InterfaceC0466 interfaceC0466, C1096 c1096, InterfaceC3290 interfaceC3290) {
        this.f7475 = context;
        this.f7472 = scheduledExecutorService;
        this.f7477 = c2288;
        this.f7469 = interfaceC0466;
        this.f7471 = c1096;
        this.f7470 = interfaceC3290;
        c2288.m5993();
        this.f7476 = c2288.f8945.f15904;
        AtomicReference atomicReference = C4516.f16828;
        Application application = (Application) context.getApplicationContext();
        AtomicReference atomicReference2 = C4516.f16828;
        if (atomicReference2.get() == null) {
            C4516 c4516 = new C4516();
            while (true) {
                if (atomicReference2.compareAndSet(null, c4516)) {
                    ComponentCallbacks2C5475.m11104(application);
                    ComponentCallbacks2C5475.f20548.m11106(c4516);
                    break;
                } else if (atomicReference2.get() != null) {
                    break;
                }
            }
        }
        ʼٴ.ˇʼʤˎ(new ːⁱᵸ(6, this), scheduledExecutorService);
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final synchronized C2720 m5215(C2288 c2288, InterfaceC0466 interfaceC0466, C4995 c4995, C0382 c0382, Context context, C4093 c4093) {
        return new C2720(c2288, interfaceC0466, c4995, c0382, context, c4093, this.f7472);
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final C0382 m5216(String str) {
        C4366 c4366;
        String strM4105 = AbstractC1327.m4105("frc_", this.f7476, "_firebase_", str, ".json");
        ScheduledExecutorService scheduledExecutorService = this.f7472;
        Context context = this.f7475;
        HashMap map = C4366.f16328;
        synchronized (C4366.class) {
            try {
                HashMap map2 = C4366.f16328;
                if (!map2.containsKey(strM4105)) {
                    map2.put(strM4105, new C4366(context, strM4105));
                }
                c4366 = (C4366) map2.get(strM4105);
            } catch (Throwable th) {
                throw th;
            }
        }
        return C0382.m1828(scheduledExecutorService, c4366);
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final synchronized C4291 m5217() throws Throwable {
        C1849 c1849;
        C0382 c0382M5216;
        C0382 c0382M52162;
        C0382 c0382M52163;
        C4093 c4093;
        C2304 c2304;
        ᵮᵥٴ r13;
        try {
            try {
                c0382M5216 = m5216("fetch");
                c0382M52162 = m5216("activate");
                c0382M52163 = m5216("defaults");
                try {
                } catch (Throwable th) {
                    th = th;
                    c1849 = this;
                }
            } catch (Throwable th2) {
                th = th2;
            }
            try {
                boolean z = false;
                c4093 = new C4093(this.f7475.getSharedPreferences("frc_" + this.f7476 + "_firebase_settings", 0));
                c2304 = new C2304(this.f7472, c0382M52162, c0382M52163);
                C2288 c2288 = this.f7477;
                InterfaceC3290 interfaceC3290 = this.f7470;
                c2288.m5993();
                C5553 c5553 = c2288.f8948.equals("[DEFAULT]") ? new C5553(interfaceC3290) : null;
                if (c5553 != null) {
                    c2304.m6010(new C1743(c5553));
                }
                C5553 c55532 = new C5553(15, z);
                c55532.f20833 = c0382M52162;
                c55532.f20835 = c0382M52163;
                ScheduledExecutorService scheduledExecutorService = this.f7472;
                r13 = new ᵮᵥٴ(25, false);
                r13.ᵤᵙᵷ = Collections.newSetFromMap(new ConcurrentHashMap());
                r13.ᵢˇᵭ = c0382M52162;
                r13.ᵿʗᵝʽ = c55532;
                r13.ᵾᵬ = scheduledExecutorService;
            } catch (Throwable th3) {
                c1849 = this;
                th = th3;
                throw th;
            }
        } catch (Throwable th4) {
            th = th4;
            c1849 = this;
        }
        return m5218(this.f7477, this.f7469, this.f7471, this.f7472, c0382M5216, c0382M52162, c0382M52163, m5219(c0382M5216, c4093), c2304, c4093, r13);
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final synchronized C4291 m5218(C2288 c2288, InterfaceC0466 interfaceC0466, C1096 c1096, Executor executor, C0382 c0382, C0382 c03822, C0382 c03823, C4995 c4995, C2304 c2304, C4093 c4093, ᵮᵥٴ r24) {
        try {
            if (!this.f7474.containsKey("firebase")) {
                c2288.m5993();
                C4291 c4291 = new C4291(c2288.f8948.equals("[DEFAULT]") ? c1096 : null, executor, c0382, c03822, c03823, c4995, c2304, c4093, m5215(c2288, interfaceC0466, c4995, c03822, this.f7475, c4093), r24);
                c03822.m1831();
                c03823.m1831();
                c0382.m1831();
                this.f7474.put("firebase", c4291);
                f7468.put("firebase", c4291);
            }
        } catch (Throwable th) {
            throw th;
        }
        return (C4291) this.f7474.get("firebase");
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final synchronized C4995 m5219(C0382 c0382, C4093 c4093) {
        InterfaceC0466 interfaceC0466;
        InterfaceC3290 c4347;
        ScheduledExecutorService scheduledExecutorService;
        Random random;
        String str;
        C2288 c2288;
        try {
            interfaceC0466 = this.f7469;
            C2288 c22882 = this.f7477;
            c22882.m5993();
            c4347 = c22882.f8948.equals("[DEFAULT]") ? this.f7470 : new C4347(6);
            scheduledExecutorService = this.f7472;
            random = f7467;
            C2288 c22883 = this.f7477;
            c22883.m5993();
            str = c22883.f8945.f15903;
            c2288 = this.f7477;
            c2288.m5993();
        } catch (Throwable th) {
            throw th;
        }
        return new C4995(interfaceC0466, c4347, scheduledExecutorService, random, c0382, new ConfigFetchHttpClient(this.f7475, c2288.f8945.f15904, str, c4093.f15298.getLong("fetch_timeout_in_seconds", 60L), c4093.f15298.getLong("fetch_timeout_in_seconds", 60L)), c4093, this.f7473);
    }
}
