package com.bytedance.sdk.openadsdk.core.dsz.ajl;

import android.text.TextUtils;
import com.bytedance.sdk.openadsdk.core.model.lse;
import com.bytedance.sdk.openadsdk.core.model.wey;
import java.util.Map;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public class wu {
    public void fm(String str, lse lseVar, String str2, Map<String, Object> map) {
        Object obj;
        Object value;
        Object value2;
        if (map != null) {
            try {
                if (map.isEmpty() || (obj = map.get("label")) == null) {
                    return;
                }
                String strValueOf = String.valueOf(obj);
                if (TextUtils.isEmpty(strValueOf)) {
                    return;
                }
                JSONObject jSONObject = new JSONObject();
                String strGt = lseVar.gt();
                if (!"sendLogExtra".equals(str) || TextUtils.isEmpty(strGt)) {
                    jSONObject.put("log_extra", strGt);
                } else {
                    JSONObject jSONObject2 = new JSONObject(strGt);
                    for (Map.Entry<String, Object> entry : map.entrySet()) {
                        if (!"label".equals(entry.getKey()) && (value2 = entry.getValue()) != null) {
                            jSONObject2.put(entry.getKey(), String.valueOf(value2));
                        }
                    }
                    jSONObject.put("log_extra", jSONObject2.toString());
                }
                JSONObject jSONObject3 = new JSONObject();
                if ("sendAdExtra".equals(str)) {
                    for (Map.Entry<String, Object> entry2 : map.entrySet()) {
                        if (!"label".equals(entry2.getKey()) && (value = entry2.getValue()) != null) {
                            jSONObject3.put(entry2.getKey(), String.valueOf(value));
                        }
                    }
                }
                jSONObject.put("ad_extra_data", jSONObject3.toString());
                jSONObject.putOpt("ua_policy", Integer.valueOf(lseVar.zh()));
                com.bytedance.sdk.openadsdk.yz.lb.fm(lseVar, "app_union", str2, strValueOf, Long.parseLong(lseVar.eo()), 0L, jSONObject, wey.wu(lseVar));
            } catch (Throwable unused) {
            }
        }
    }
}
