package com.mbridge.msdk.videocommon.d; import android.text.TextUtils; import com.mbridge.msdk.foundation.entity.CampaignEx; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.json.JSONArray; import org.json.JSONObject; /* loaded from: classes4.dex */ public class a { private Map a; private Map b; private long c; private long d; private long e; private long f; private long g; private long h; private String j; private int i = 0; private String k = ""; private String l = ""; public final String a() { return this.k; } public final void a(int i) { this.i = i; } public final void a(long j) { this.c = j; } public final void a(Map map) { this.a = map; } public final String b() { return this.j; } public final void b(long j) { this.d = j; } public final void b(Map map) { this.b = map; } public final String c() { return this.l; } public final void c(long j) { this.e = j; } public final long d() { return this.c * 1000; } public final void d(long j) { this.f = j; } public final long e() { return this.d * 1000; } public final void e(long j) { this.g = j; } public final long f() { return this.e * 1000; } public final long g() { return this.f; } public final long h() { return this.g; } public final long i() { return this.h; } public final Map j() { return this.b; } public static a a(String str) { a aVar = null; if (!TextUtils.isEmpty(str)) { try { a aVar2 = new a(); try { JSONObject jSONObject = new JSONObject(str); JSONObject optJSONObject = jSONObject.optJSONObject("caplist"); aVar2.j = jSONObject.optString("ab_id", ""); aVar2.l = jSONObject.optString("rid", ""); if (optJSONObject != null && optJSONObject.length() > 0) { HashMap hashMap = new HashMap(); Iterator keys = optJSONObject.keys(); while (keys != null && keys.hasNext()) { String next = keys.next(); int intValue = Integer.valueOf(optJSONObject.optInt(next, 1000)).intValue(); if (!TextUtils.isEmpty(next)) { if (!TextUtils.isEmpty(next) && intValue == 0) { hashMap.put(next, 1000); } else { hashMap.put(next, Integer.valueOf(intValue)); } } } aVar2.a = hashMap; } aVar2.b = com.mbridge.msdk.videocommon.b.c.a(jSONObject.optJSONArray("reward")); aVar2.c = jSONObject.optLong("getpf", 43200L); aVar2.d = jSONObject.optLong("ruct", 5400L); aVar2.e = jSONObject.optLong(CampaignEx.JSON_KEY_PLCT, 3600L); aVar2.f = jSONObject.optLong("dlct", 3600L); aVar2.g = jSONObject.optLong("vcct", 5L); aVar2.h = jSONObject.optLong("current_time"); aVar2.k = jSONObject.optString("vtag", ""); return aVar2; } catch (Exception e) { e = e; aVar = aVar2; e.printStackTrace(); return aVar; } } catch (Exception e2) { e = e2; } } return aVar; } public final JSONObject k() { JSONObject jSONObject = new JSONObject(); try { Map map = this.a; if (map != null && map.size() > 0) { try { JSONObject jSONObject2 = new JSONObject(); for (Map.Entry entry : this.a.entrySet()) { jSONObject2.put(entry.getKey(), entry.getValue().intValue()); } jSONObject.put("caplist", jSONObject2); } catch (Exception e) { e.printStackTrace(); } } Map map2 = this.b; if (map2 != null && map2.size() > 0) { try { JSONArray jSONArray = new JSONArray(); for (Map.Entry entry2 : this.b.entrySet()) { JSONObject jSONObject3 = new JSONObject(); String key = entry2.getKey(); com.mbridge.msdk.videocommon.b.c value = entry2.getValue(); if (value != null) { jSONObject3.put("name", value.a()); jSONObject3.put("amount", value.b()); jSONObject3.put("id", key); } jSONArray.put(jSONObject3); } jSONObject.put("reward", jSONArray); } catch (Exception e2) { e2.printStackTrace(); } } jSONObject.put("getpf", this.c); jSONObject.put("ruct", this.d); jSONObject.put(CampaignEx.JSON_KEY_PLCT, this.e); jSONObject.put("dlct", this.f); jSONObject.put("vcct", this.g); jSONObject.put("current_time", this.h); jSONObject.put("vtag", this.k); jSONObject.put("isDefault", this.i); return jSONObject; } catch (Exception e3) { e3.printStackTrace(); return jSONObject; } } }