package com.flurry.android;

import com.tapjoy.TapjoyConstants;
import java.util.Iterator;
import java.util.Map;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: /storage/emulated/0/Documents/jadec/sources/com.UBI.A90.WW/dex-files/0.dex */
public final class r {
    private static String a = "FlurryAgent";
    private be b;

    /* JADX INFO: Access modifiers changed from: package-private */
    public r(be beVar) {
        this.b = beVar;
    }

    private static boolean a(String str, String str2) {
        return str2.equals("%{" + str + "}");
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final String a(bb bbVar, AdUnit adUnit, String str, String str2) {
        String str3;
        if (a("fids", str2)) {
            String str4 = "0:" + this.b.e();
            bc.a(a, "Replacing param fids with: " + str4);
            return str.replace(str2, y.b(str4));
        } else if (a("sid", str2)) {
            String valueOf = String.valueOf(this.b.b());
            bc.a(a, "Replacing param sid with: " + valueOf);
            return str.replace(str2, y.b(valueOf));
        } else if (a("lid", str2)) {
            String valueOf2 = String.valueOf(bbVar.a());
            bc.a(a, "Replacing param lid with: " + valueOf2);
            return str.replace(str2, y.b(valueOf2));
        } else if (a(TapjoyConstants.TJC_GUID, str2)) {
            String b = bbVar.b();
            bc.a(a, "Replacing param guid with: " + b);
            return str.replace(str2, y.b(b));
        } else if (a("ats", str2)) {
            String valueOf3 = String.valueOf(System.currentTimeMillis());
            bc.a(a, "Replacing param ats with: " + valueOf3);
            return str.replace(str2, y.b(valueOf3));
        } else if (a("apik", str2)) {
            String c = this.b.c();
            bc.a(a, "Replacing param apik with: " + c);
            return str.replace(str2, y.b(c));
        } else if (a("hid", str2)) {
            String obj = adUnit.a().toString();
            bc.a(a, "Replacing param hid with: " + obj);
            return str.replace(str2, y.b(obj));
        } else if (a("eso", str2)) {
            String l = Long.toString(System.currentTimeMillis() - this.b.b());
            bc.a(a, "Replacing param eso with: " + l);
            return str.replace(str2, y.b(l));
        } else if (a("uc", str2)) {
            String str5 = "";
            Iterator<Map.Entry<String, String>> it = this.b.i().entrySet().iterator();
            while (true) {
                str3 = str5;
                if (!it.hasNext()) {
                    break;
                }
                Map.Entry<String, String> next = it.next();
                str5 = str3 + "c_" + y.b(next.getKey()) + "=" + y.b(next.getValue()) + "&";
            }
            bc.a(a, "Replacing param uc with: " + str3);
            String replace = str.replace(str2, str3);
            if (str3.equals("") && replace.length() > 0) {
                return replace.substring(0, replace.length() - 1);
            }
            return replace;
        } else {
            bc.a(a, "Unknown param: " + str2);
            return str.replace(str2, "");
        }
    }
}
