package com.qualtrics.digital;

import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import java.util.HashMap;
import java.util.Locale;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.regex.Pattern;

/* loaded from: classes3.dex */
public class l0 {

    /* renamed from: f, reason: collision with root package name */
    private static l0 f15420f;

    /* renamed from: e, reason: collision with root package name */
    protected z f15425e = null;

    /* renamed from: a, reason: collision with root package name */
    public i0 f15421a = i0.d(null);

    /* renamed from: b, reason: collision with root package name */
    r0 f15422b = new r0(em.b.f17219b, Color.parseColor("#F5F5F5"));

    /* renamed from: c, reason: collision with root package name */
    q0 f15423c = q0.a();

    /* renamed from: d, reason: collision with root package name */
    ScheduledExecutorService f15424d = Executors.newScheduledThreadPool(1);

    private l0() {
    }

    public static l0 i() {
        if (f15420f == null) {
            f15420f = new l0();
        }
        return f15420f;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public /* synthetic */ void j(u uVar) {
        this.f15425e.t(uVar);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public /* synthetic */ void k() {
        this.f15425e.s();
    }

    private void l(String str) {
        Log.e("Qualtrics", String.format(Locale.US, "Invalid %s, initialization cancelled", str));
    }

    private boolean n(String str, String str2) {
        if (str2 == null) {
            return false;
        }
        return Pattern.compile(String.format(Locale.US, "%s_[0-9a-zA-Z]{11,15}", str)).matcher(str2).matches();
    }

    public boolean c(Context context) {
        return d(context, 0, false);
    }

    public boolean d(Context context, int i10, boolean z10) {
        try {
            z zVar = this.f15425e;
            if (zVar != null) {
                return zVar.k(context, i10, z10);
            }
            return false;
        } catch (Throwable th2) {
            g.a(th2);
            return false;
        }
    }

    public void e(t tVar) {
        try {
            z zVar = this.f15425e;
            if (zVar != null) {
                zVar.f15499h.g(tVar);
                this.f15425e.l();
            } else {
                Log.e("Qualtrics", "Cannot evaluate logic, SDK has not been initialized");
                y0 y0Var = new y0(z0.error, null, new Exception("Cannot evaluate logic, SDK has not been initialized"));
                HashMap hashMap = new HashMap();
                hashMap.put("Error", y0Var);
                tVar.a(hashMap);
            }
        } catch (Throwable th2) {
            g.a(th2);
        }
    }

    public r0 f() {
        return this.f15422b;
    }

    public void g(String str, String str2, Context context) {
        h(str, str2, null, context, null);
    }

    public void h(String str, String str2, String str3, Context context, final u uVar) {
        try {
            if (!n("ZN", str2)) {
                l("zone ID");
                if (uVar != null) {
                    HashMap hashMap = new HashMap();
                    hashMap.put("Error", new w(Boolean.FALSE, "Invalid Zone ID"));
                    uVar.a(hashMap);
                    return;
                }
                return;
            }
            if (str == null) {
                l("brand ID");
                if (uVar != null) {
                    HashMap hashMap2 = new HashMap();
                    hashMap2.put("Error", new w(Boolean.FALSE, "Invalid Brand ID"));
                    uVar.a(hashMap2);
                    return;
                }
                return;
            }
            if (str3 != null && str3.equals("")) {
                str3 = null;
            }
            n.b().c();
            QualtricsNotificationManager.a(context);
            this.f15421a.e(context);
            this.f15425e = new z(str, str2, context, u0.b(), c.e(), e.i(), this.f15424d, str3);
            if (uVar != null) {
                this.f15424d.execute(new Runnable(uVar) { // from class: com.qualtrics.digital.j0
                    @Override // java.lang.Runnable
                    public final void run() {
                        l0.this.j(null);
                    }
                });
            } else {
                this.f15424d.execute(new Runnable() { // from class: com.qualtrics.digital.k0
                    @Override // java.lang.Runnable
                    public final void run() {
                        l0.this.k();
                    }
                });
            }
        } catch (Throwable th2) {
            g.a(th2);
        }
    }

    public void m(String str) {
        try {
            g1.a().b(str);
        } catch (Throwable th2) {
            g.a(th2);
        }
    }
}
