package M4;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public static final Date f4230h = new Date(0);

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final JSONObject f4231a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final JSONObject f4232b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Date f4233c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final JSONArray f4234d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final JSONObject f4235e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final long f4236f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final JSONArray f4237g;

    public f(JSONObject jSONObject, Date date, JSONArray jSONArray, JSONObject jSONObject2, long j8, JSONArray jSONArray2) throws JSONException {
        JSONObject jSONObject3 = new JSONObject();
        jSONObject3.put("configs_key", jSONObject);
        jSONObject3.put("fetch_time_key", date.getTime());
        jSONObject3.put("abt_experiments_key", jSONArray);
        jSONObject3.put("personalization_metadata_key", jSONObject2);
        jSONObject3.put("template_version_number_key", j8);
        jSONObject3.put("rollout_metadata_key", jSONArray2);
        this.f4232b = jSONObject;
        this.f4233c = date;
        this.f4234d = jSONArray;
        this.f4235e = jSONObject2;
        this.f4236f = j8;
        this.f4237g = jSONArray2;
        this.f4231a = jSONObject3;
    }

    public static f a(JSONObject jSONObject) throws JSONException {
        JSONObject jSONObjectOptJSONObject = jSONObject.optJSONObject("personalization_metadata_key");
        if (jSONObjectOptJSONObject == null) {
            jSONObjectOptJSONObject = new JSONObject();
        }
        JSONObject jSONObject2 = jSONObjectOptJSONObject;
        JSONArray jSONArrayOptJSONArray = jSONObject.optJSONArray("rollout_metadata_key");
        if (jSONArrayOptJSONArray == null) {
            jSONArrayOptJSONArray = new JSONArray();
        }
        return new f(jSONObject.getJSONObject("configs_key"), new Date(jSONObject.getLong("fetch_time_key")), jSONObject.getJSONArray("abt_experiments_key"), jSONObject2, jSONObject.optLong("template_version_number_key"), jSONArrayOptJSONArray);
    }

    public static e c() {
        e eVar = new e();
        eVar.f4224a = new JSONObject();
        eVar.f4225b = f4230h;
        eVar.f4226c = new JSONArray();
        eVar.f4227d = new JSONObject();
        eVar.f4228e = 0L;
        eVar.f4229f = new JSONArray();
        return eVar;
    }

    public final HashMap b() throws JSONException {
        HashMap map = new HashMap();
        int i = 0;
        while (true) {
            JSONArray jSONArray = this.f4237g;
            if (i >= jSONArray.length()) {
                return map;
            }
            JSONObject jSONObject = jSONArray.getJSONObject(i);
            String string = jSONObject.getString("rolloutId");
            String string2 = jSONObject.getString("variantId");
            JSONArray jSONArray2 = jSONObject.getJSONArray("affectedParameterKeys");
            for (int i5 = 0; i5 < jSONArray2.length(); i5++) {
                String string3 = jSONArray2.getString(i5);
                if (!map.containsKey(string3)) {
                    map.put(string3, new HashMap());
                }
                Map map2 = (Map) map.get(string3);
                if (map2 != null) {
                    map2.put(string, string2);
                }
            }
            i++;
        }
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof f) {
            return this.f4231a.toString().equals(((f) obj).f4231a.toString());
        }
        return false;
    }

    public final int hashCode() {
        return this.f4231a.hashCode();
    }

    public final String toString() {
        return this.f4231a.toString();
    }
}
