package com.qualtrics.digital;

import android.content.Context;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public class z {

    /* renamed from: a, reason: collision with root package name */
    private String f15492a;

    /* renamed from: b, reason: collision with root package name */
    private String f15493b;

    /* renamed from: d, reason: collision with root package name */
    protected String f15495d;

    /* renamed from: f, reason: collision with root package name */
    private b0 f15497f;

    /* renamed from: g, reason: collision with root package name */
    private b0 f15498g;

    /* renamed from: h, reason: collision with root package name */
    c f15499h;

    /* renamed from: i, reason: collision with root package name */
    e f15500i;

    /* renamed from: j, reason: collision with root package name */
    u0 f15501j;

    /* renamed from: k, reason: collision with root package name */
    x0 f15502k;

    /* renamed from: l, reason: collision with root package name */
    ScheduledExecutorService f15503l;

    /* renamed from: m, reason: collision with root package name */
    int f15504m;

    /* renamed from: c, reason: collision with root package name */
    private String f15494c = "";

    /* renamed from: e, reason: collision with root package name */
    private boolean f15496e = false;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes3.dex */
    public class a implements or.d {
        a() {
        }

        @Override // or.d
        public void a(or.b bVar, Throwable th2) {
            if (!(th2 instanceof IOException)) {
                z.this.x("Error calling loadProject", th2);
            }
            z.this.f15497f.d();
            m0.a("Unexpected response getting asset versions");
            m0.c(th2);
            z.this.j("Error", false, th2);
        }

        @Override // or.d
        public void b(or.b bVar, or.t tVar) {
            try {
                android.support.v4.media.session.b.a(tVar.a());
                throw null;
            } catch (Exception e10) {
                z.this.w(e10.getMessage() + ", mobileTargeting Error calling Targeting, initialization cancelled");
                z.this.y("Error loading project", true, e10);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes3.dex */
    public class b implements or.d {
        b() {
        }

        @Override // or.d
        public void a(or.b bVar, Throwable th2) {
            if (!(th2 instanceof IOException)) {
                z.this.x("Unexpected response getting contact frequency response", th2);
            }
            z.this.f15498g.d();
            m0.a("Unexpected response getting contact frequency response");
            m0.c(th2);
        }

        @Override // or.d
        public void b(or.b bVar, or.t tVar) {
            z zVar = z.this;
            android.support.v4.media.session.b.a(tVar.a());
            zVar.o(null, z.this.f15498g);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public z(String str, String str2, Context context, u0 u0Var, c cVar, e eVar, ScheduledExecutorService scheduledExecutorService, String str3) {
        this.f15493b = str2;
        this.f15495d = str3;
        this.f15492a = str;
        String str4 = m(context) + "_" + n(context);
        this.f15501j = u0Var;
        this.f15499h = cVar;
        this.f15500i = eVar;
        this.f15503l = scheduledExecutorService;
        this.f15504m = -1;
        b0 b0Var = new b0("targetingResponse", "/WRSiteInterceptEngine/MobileTargeting?Q_ZoneID=" + this.f15493b);
        this.f15497f = b0Var;
        b0Var.b();
        b0 b0Var2 = new b0("evaluateProject", "/WRSiteInterceptEngine/MobileXmdDcfEval?Q_ZoneID=" + this.f15493b);
        this.f15498g = b0Var2;
        b0Var2.b();
        p(str, str2, null, str4);
    }

    private void i(String str, boolean z10, String str2) {
        HashMap hashMap = new HashMap();
        hashMap.put(str, new w(Boolean.valueOf(z10), str2));
        this.f15499h.b(hashMap);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void j(String str, boolean z10, Throwable th2) {
        i(str, z10, (th2 == null || th2.toString() == null) ? "Unexpected error during initialization" : th2.toString());
    }

    private String m(Context context) {
        return context.getPackageName();
    }

    private String n(Context context) {
        try {
            return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
        } catch (Exception unused) {
            return "0";
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public /* synthetic */ void q(Map map) {
        this.f15499h.f(map);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public /* synthetic */ void r(Map map) {
        this.f15502k.j(this.f15493b, this.f15495d, map, new b());
    }

    private void u(String str) {
        m0.d(str);
    }

    private void v(String str) {
        m0.a(str + ", aborting SDK evaluation...");
        HashMap hashMap = new HashMap();
        hashMap.put("Error", new y0(z0.error, str + ", aborting SDK project evaluation...", new Exception("Qualtrics: " + str + ", evaluation cancelled")));
        this.f15499h.c(hashMap);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void w(String str) {
        m0.a(str + ", aborting SDK initialization...");
        HashMap hashMap = new HashMap();
        hashMap.put("Error", new w(Boolean.FALSE, str + ", aborting SDK project initialization..."));
        this.f15499h.b(hashMap);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void x(String str, Throwable th2) {
        this.f15501j.d(String.format("%s-%s-%s-%s", this.f15492a, this.f15493b, null, str), th2, true);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void y(String str, boolean z10, Throwable th2) {
        this.f15502k.f(String.format("%s zoneId=%s", str, this.f15493b), z10, th2);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public boolean k(Context context, int i10, boolean z10) {
        boolean z11;
        u("Displaying...");
        int i11 = this.f15504m;
        if (i11 == 2) {
            z11 = this.f15500i.b(context, i10, z10);
        } else {
            if (i11 == 1) {
                boolean z12 = this.f15496e;
            }
            z11 = false;
        }
        return z11;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void l() {
        boolean e10;
        this.f15499h.i(new t() { // from class: com.qualtrics.digital.x
            @Override // com.qualtrics.digital.t
            public final void a(Map map) {
                z.this.q(map);
            }
        });
        if (this.f15495d == null || !this.f15500i.d()) {
            e10 = this.f15500i.e(null);
        } else {
            this.f15498g.c();
            e10 = this.f15500i.e(new s() { // from class: com.qualtrics.digital.y
                @Override // com.qualtrics.digital.s
                public final void a(Map map) {
                    z.this.r(map);
                }
            });
        }
        this.f15504m = 2;
        if (e10) {
            x0.c().i(this.f15493b, null, null);
        }
    }

    void o(f fVar, b0 b0Var) {
        v("Error calling Contact Frequency");
        y("Received null contact frequency response", false, null);
    }

    void p(String str, String str2, String str3, String str4) {
        this.f15501j.a(str, str2, str3, str4);
        this.f15502k = x0.c();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void s() {
        this.f15497f.c();
        this.f15502k.a(this.f15493b, this.f15495d, new a());
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void t(u uVar) {
        this.f15499h.h(uVar);
        s();
    }
}
