package com.ironsource;

import android.util.Log;
import android.util.Pair;
import com.google.gson.reflect.VR.KSeeLS;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/* loaded from: classes4.dex */
public class zb {
    private static final String e = "EventsTracker";

    /* renamed from: a  reason: collision with root package name */
    private fe f3290a;
    private tb b;
    private we c;
    private ExecutorService d;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes7.dex */
    public class a implements Runnable {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ String f3291a;

        a(String str) {
            this.f3291a = str;
        }

        @Override // java.lang.Runnable
        public void run() {
            String str = KSeeLS.XQrTSmkIE;
            try {
                ap apVar = new ap();
                ArrayList<Pair<String, String>> d = zb.this.b.d();
                if ("POST".equals(zb.this.b.e())) {
                    apVar = sf.b(zb.this.b.b(), this.f3291a, d);
                } else if ("GET".equals(zb.this.b.e())) {
                    apVar = sf.a(zb.this.b.b(), this.f3291a, d);
                }
                zb.this.a(str + apVar.f2200a);
            } catch (Exception e) {
                l9.d().a(e);
            }
        }
    }

    public zb(tb tbVar, fe feVar) {
        if (tbVar == null) {
            throw new InvalidParameterException("Null configuration not supported ");
        }
        if (tbVar.c() == null) {
            throw new InvalidParameterException("Null formatter not supported ");
        }
        this.b = tbVar;
        this.f3290a = feVar;
        this.c = tbVar.c();
        this.d = Executors.newSingleThreadExecutor();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void a(String str) {
        if (this.b.f()) {
            Log.d(e, str);
        }
    }

    private void a(Map<String, Object> map, Map<String, Object> map2) {
        try {
            map.putAll(map2);
        } catch (Exception e2) {
            l9.d().a(e2);
        }
    }

    private void b(String str) {
        this.d.submit(new a(str));
    }

    public void a(String str, Map<String, Object> map) {
        a(String.format(Locale.ENGLISH, "%s %s", str, map.toString()));
        if (this.b.a() && !str.isEmpty()) {
            HashMap hashMap = new HashMap();
            hashMap.put("eventname", str);
            a(hashMap, this.f3290a.a());
            a(hashMap, map);
            b(this.c.a(hashMap));
        }
    }
}
