package androidx.datastore.preferences.protobuf;

import defpackage.AbstractC0702;
import defpackage.AbstractC2956;
import defpackage.C3056;
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: renamed from: androidx.datastore.preferences.protobuf.ᵻˈᵦʼ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public abstract class AbstractC0012 {

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static final char[] f376;

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

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public static void m248(StringBuilder sb, int i, String str, Object obj) {
        if (obj instanceof List) {
            Iterator it = ((List) obj).iterator();
            while (it.hasNext()) {
                m248(sb, i, str, it.next());
            }
            return;
        }
        if (obj instanceof Map) {
            Iterator it2 = ((Map) obj).entrySet().iterator();
            while (it2.hasNext()) {
                m248(sb, i, str, (Map.Entry) it2.next());
            }
            return;
        }
        sb.append('\n');
        m250(i, sb);
        if (!str.isEmpty()) {
            StringBuilder sb2 = new StringBuilder();
            sb2.append(Character.toLowerCase(str.charAt(0)));
            for (int i2 = 1; i2 < str.length(); i2++) {
                char cCharAt = str.charAt(i2);
                if (Character.isUpperCase(cCharAt)) {
                    sb2.append("_");
                }
                sb2.append(Character.toLowerCase(cCharAt));
            }
            str = sb2.toString();
        }
        sb.append(str);
        if (obj instanceof String) {
            sb.append(": \"");
            C3056 c3056 = C3056.f11705;
            sb.append(AbstractC0702.m2539(new C3056(((String) obj).getBytes(AbstractC2956.f11367))));
            sb.append('\"');
            return;
        }
        if (obj instanceof C3056) {
            sb.append(": \"");
            sb.append(AbstractC0702.m2539((C3056) obj));
            sb.append('\"');
            return;
        }
        if (obj instanceof AbstractC0004) {
            sb.append(" {");
            m249((AbstractC0004) obj, sb, i + 2);
            sb.append("\n");
            m250(i, sb);
            sb.append("}");
            return;
        }
        if (!(obj instanceof Map.Entry)) {
            sb.append(": ");
            sb.append(obj);
            return;
        }
        sb.append(" {");
        Map.Entry entry = (Map.Entry) obj;
        int i3 = i + 2;
        m248(sb, i3, "key", entry.getKey());
        m248(sb, i3, "value", entry.getValue());
        sb.append("\n");
        m250(i, sb);
        sb.append("}");
    }

    /* JADX WARN: Removed duplicated region for block: B:75:0x0194  */
    /* JADX WARN: Removed duplicated region for block: B:76:0x0196  */
    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static void m249(AbstractC0004 abstractC0004, StringBuilder sb, int i) {
        int i2;
        int i3;
        boolean zBooleanValue;
        boolean zEquals;
        Method method;
        Method method2;
        HashSet hashSet = new HashSet();
        HashMap map = new HashMap();
        TreeMap treeMap = new TreeMap();
        Method[] declaredMethods = abstractC0004.getClass().getDeclaredMethods();
        int length = declaredMethods.length;
        int i4 = 0;
        while (true) {
            i2 = 3;
            if (i4 >= length) {
                break;
            }
            Method method3 = declaredMethods[i4];
            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);
                    }
                }
            }
            i4++;
        }
        for (Map.Entry entry : treeMap.entrySet()) {
            String strSubstring = ((String) entry.getKey()).substring(i2);
            if (!strSubstring.endsWith("List") || strSubstring.endsWith("OrBuilderList") || strSubstring.equals("List") || (method2 = (Method) entry.getValue()) == null) {
                i3 = i2;
            } else {
                i3 = i2;
                if (method2.getReturnType().equals(List.class)) {
                    m248(sb, i, strSubstring.substring(0, strSubstring.length() - 4), AbstractC0004.m151(method2, abstractC0004, new Object[0]));
                }
                i2 = i3;
            }
            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())) {
                m248(sb, i, strSubstring.substring(0, strSubstring.length() - 3), AbstractC0004.m151(method, abstractC0004, new Object[0]));
            } else if (hashSet.contains("set".concat(strSubstring)) && (!strSubstring.endsWith("Bytes") || !treeMap.containsKey("get".concat(strSubstring.substring(0, strSubstring.length() - 5))))) {
                Method method4 = (Method) entry.getValue();
                Method method5 = (Method) map.get("has".concat(strSubstring));
                if (method4 != null) {
                    Object objM151 = AbstractC0004.m151(method4, abstractC0004, new Object[0]);
                    if (method5 == null) {
                        zBooleanValue = true;
                        if (objM151 instanceof Boolean) {
                            zEquals = !((Boolean) objM151).booleanValue();
                        } else if (objM151 instanceof Integer) {
                            zEquals = ((Integer) objM151).intValue() == 0;
                        } else if (objM151 instanceof Float) {
                            if (Float.floatToRawIntBits(((Float) objM151).floatValue()) == 0) {
                            }
                        } else if (objM151 instanceof Double) {
                            if (Double.doubleToRawLongBits(((Double) objM151).doubleValue()) == 0) {
                            }
                        } else if (objM151 instanceof String) {
                            zEquals = objM151.equals("");
                        } else if (objM151 instanceof C3056) {
                            zEquals = objM151.equals(C3056.f11705);
                        } else if (!(objM151 instanceof AbstractC0007) ? !(objM151 instanceof Enum) || ((Enum) objM151).ordinal() != 0 : objM151 != ((AbstractC0004) ((AbstractC0004) ((AbstractC0007) objM151)).mo157(6))) {
                        }
                        if (zEquals) {
                            zBooleanValue = false;
                        }
                    } else {
                        zBooleanValue = ((Boolean) AbstractC0004.m151(method5, abstractC0004, new Object[0])).booleanValue();
                    }
                    if (zBooleanValue) {
                        m248(sb, i, strSubstring, objM151);
                    }
                }
            }
            i2 = i3;
        }
        C0009 c0009 = abstractC0004.unknownFields;
        if (c0009 != null) {
            for (int i5 = 0; i5 < c0009.f367; i5++) {
                m248(sb, i, String.valueOf(c0009.f364[i5] >>> 3), c0009.f365[i5]);
            }
        }
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static void m250(int i, StringBuilder sb) {
        while (i > 0) {
            int i2 = 80;
            if (i <= 80) {
                i2 = i;
            }
            sb.append(f376, 0, i2);
            i -= i2;
        }
    }
}
