package com.google.android.gms.internal.ads;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

/* JADX INFO: loaded from: classes2.dex */
public abstract class xb2 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final char[] f18402a;

    static {
        char[] cArr = new char[80];
        f18402a = cArr;
        Arrays.fill(cArr, ' ');
    }

    public static void a(StringBuilder sb, int i10, String str, Object obj) {
        if (obj instanceof List) {
            Iterator it = ((List) obj).iterator();
            while (it.hasNext()) {
                a(sb, i10, str, it.next());
            }
            return;
        }
        if (obj instanceof Map) {
            Iterator it2 = ((Map) obj).entrySet().iterator();
            while (it2.hasNext()) {
                a(sb, i10, str, (Map.Entry) it2.next());
            }
            return;
        }
        sb.append('\n');
        c(i10, sb);
        if (!str.isEmpty()) {
            StringBuilder sb2 = new StringBuilder();
            sb2.append(Character.toLowerCase(str.charAt(0)));
            for (int i11 = 1; i11 < str.length(); i11++) {
                char cCharAt = str.charAt(i11);
                if (Character.isUpperCase(cCharAt)) {
                    sb2.append("_");
                }
                sb2.append(Character.toLowerCase(cCharAt));
            }
            str = sb2.toString();
        }
        sb.append(str);
        if (obj instanceof String) {
            sb.append(": \"");
            zzian zzianVar = zzian.f19856a;
            sb.append(vj1.d(new zzial(((String) obj).getBytes(kb2.f13211a))));
            sb.append('\"');
            return;
        }
        if (obj instanceof zzian) {
            sb.append(": \"");
            sb.append(vj1.d((zzian) obj));
            sb.append('\"');
            return;
        }
        if (obj instanceof cb2) {
            sb.append(" {");
            b((cb2) obj, sb, i10 + 2);
            sb.append("\n");
            c(i10, sb);
            sb.append("}");
            return;
        }
        if (!(obj instanceof Map.Entry)) {
            sb.append(": ");
            sb.append(obj);
            return;
        }
        int i12 = i10 + 2;
        sb.append(" {");
        Map.Entry entry = (Map.Entry) obj;
        a(sb, i12, "key", entry.getKey());
        a(sb, i12, "value", entry.getValue());
        sb.append("\n");
        c(i10, sb);
        sb.append("}");
    }

    /* JADX WARN: Removed duplicated region for block: B:102:0x0201  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static void b(wb2 wb2Var, StringBuilder sb, int i10) {
        int i11;
        boolean zEquals;
        Method method;
        Method method2;
        HashSet hashSet = new HashSet();
        HashMap map = new HashMap();
        TreeMap treeMap = new TreeMap();
        Method[] declaredMethods = wb2Var.getClass().getDeclaredMethods();
        int length = declaredMethods.length;
        int i12 = 0;
        while (true) {
            i11 = 3;
            if (i12 >= length) {
                break;
            }
            Method method3 = declaredMethods[i12];
            if (!Modifier.isStatic(method3.getModifiers()) && method3.getName().length() >= 3) {
                if (method3.getName().startsWith("set")) {
                    hashSet.add(method3.getName());
                } else if (Modifier.isPublic(method3.getModifiers()) && method3.getParameterTypes().length == 0) {
                    if (method3.getName().startsWith("has")) {
                        map.put(method3.getName(), method3);
                    } else if (method3.getName().startsWith("get")) {
                        treeMap.put(method3.getName(), method3);
                    }
                }
            }
            i12++;
        }
        for (Map.Entry entry : treeMap.entrySet()) {
            String strSubstring = ((String) entry.getKey()).substring(i11);
            if (strSubstring.endsWith("List") && !strSubstring.endsWith("OrBuilderList") && !strSubstring.equals("List") && (method2 = (Method) entry.getValue()) != null && method2.getReturnType().equals(List.class)) {
                a(sb, i10, strSubstring.substring(0, strSubstring.length() - 4), cb2.j(method2, wb2Var, new Object[0]));
            } else if (strSubstring.endsWith("Map") && !strSubstring.equals("Map") && (method = (Method) entry.getValue()) != null && method.getReturnType().equals(Map.class) && !method.isAnnotationPresent(Deprecated.class) && Modifier.isPublic(method.getModifiers())) {
                a(sb, i10, strSubstring.substring(0, strSubstring.length() - 3), cb2.j(method, wb2Var, new Object[0]));
            } else if (hashSet.contains("set".concat(strSubstring)) && (!strSubstring.endsWith("Bytes") || !treeMap.containsKey("get".concat(String.valueOf(strSubstring.substring(0, strSubstring.length() - 5)))))) {
                Method method4 = (Method) entry.getValue();
                Method method5 = (Method) map.get("has".concat(strSubstring));
                if (method4 != null) {
                    Object objJ = cb2.j(method4, wb2Var, new Object[0]);
                    if (method5 == null) {
                        if (objJ instanceof Boolean) {
                            if (((Boolean) objJ).booleanValue()) {
                                a(sb, i10, strSubstring, objJ);
                            }
                        } else if (objJ instanceof Integer) {
                            if (((Integer) objJ).intValue() != 0) {
                            }
                        } else if (objJ instanceof Float) {
                            if (Float.floatToRawIntBits(((Float) objJ).floatValue()) != 0) {
                            }
                        } else if (!(objJ instanceof Double)) {
                            if (objJ instanceof String) {
                                zEquals = objJ.equals("");
                            } else if (objJ instanceof zzian) {
                                zEquals = objJ.equals(zzian.f19856a);
                            } else if (objJ instanceof wb2) {
                                if (objJ != ((cb2) ((cb2) ((wb2) objJ)).x(zzibq.f19866f, null))) {
                                }
                            } else if (!(objJ instanceof Enum) || ((Enum) objJ).ordinal() != 0) {
                            }
                            if (!zEquals) {
                            }
                        } else if (Double.doubleToRawLongBits(((Double) objJ).doubleValue()) != 0) {
                        }
                    } else if (((Boolean) cb2.j(method5, wb2Var, new Object[0])).booleanValue()) {
                    }
                }
            }
            i11 = 3;
        }
        nc2 nc2Var = ((cb2) wb2Var).zzt;
        if (nc2Var != null) {
            for (int i13 = 0; i13 < nc2Var.f14530a; i13++) {
                a(sb, i10, String.valueOf(nc2Var.f14531b[i13] >>> 3), nc2Var.f14532c[i13]);
            }
        }
    }

    public static void c(int i10, StringBuilder sb) {
        while (i10 > 0) {
            int i11 = 80;
            if (i10 <= 80) {
                i11 = i10;
            }
            sb.append(f18402a, 0, i11);
            i10 -= i11;
        }
    }
}
