package 㳳.ῲ.K;

import com.facebook.appevents.codeless.CodelessMatcher;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.greenrobot.eventbus.EventBusException;
import ඓ.K.K.K.C1293;
import 㳳.ῲ.K.ᓣ.AbstractC2405;
import 㳳.ῲ.K.ᓣ.AbstractC2406;

/* renamed from: 㳳.ῲ.K.㗗  reason: contains not printable characters */
/* compiled from: SubscriberMethodFinder */
public class C2414 {

    /* renamed from: ඓ  reason: contains not printable characters */
    public static final C2415[] f8337 = new C2415[4];

    /* renamed from: 㸾  reason: contains not printable characters */
    public static final Map<Class<?>, List<C2402>> f8338 = new ConcurrentHashMap();

    /* renamed from: ʬ  reason: contains not printable characters */
    public final boolean f8339;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final boolean f8340;

    /* renamed from: K  reason: contains not printable characters */
    public List<AbstractC2405> f8341;

    public C2414(List<AbstractC2405> list, boolean z, boolean z2) {
        this.f8341 = list;
        this.f8340 = z;
        this.f8339 = z2;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public final List<C2402> m6462(C2415 k) {
        ArrayList arrayList = new ArrayList(k.f8346);
        k.f8346.clear();
        k.f8344.clear();
        k.f8342.clear();
        int i = 0;
        k.f8348.setLength(0);
        k.f8343 = null;
        k.f8347 = false;
        synchronized (f8337) {
            while (true) {
                if (i >= 4) {
                    break;
                } else if (f8337[i] == null) {
                    f8337[i] = k;
                    break;
                } else {
                    i++;
                }
            }
        }
        return arrayList;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:18:0x0048, code lost:
        if (r0.f8343 == r0.f8345.m6453().m6454()) goto L_0x0067;
     */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x0059  */
    /* renamed from: K  reason: contains not printable characters */
    public List<C2402> m6463(Class<?> cls) {
        List<C2402> list;
        List<C2402> list2 = f8338.get(cls);
        if (list2 != null) {
            return list2;
        }
        if (this.f8339) {
            C2415 r0 = m6464();
            r0.m6468(cls);
            while (r0.f8343 != null) {
                m6465(r0);
                r0.m6467();
            }
            list = m6462(r0);
        } else {
            C2415 r02 = m6464();
            r02.m6468(cls);
            while (r02.f8343 != null) {
                AbstractC2406 k = r02.f8345;
                if (!(k == null || k.m6453() == null)) {
                }
                List<AbstractC2405> list3 = this.f8341;
                if (list3 != null) {
                    Iterator<AbstractC2405> it2 = list3.iterator();
                    while (it2.hasNext() && it2.next().m6452(r02.f8343) == null) {
                        while (it2.hasNext()) {
                            while (it2.hasNext()) {
                            }
                        }
                    }
                }
                r02.f8345 = null;
                AbstractC2406 k2 = r02.f8345;
                if (k2 != null) {
                    C2402[] r1 = k2.m6455();
                    for (C2402 r4 : r1) {
                        if (r02.m6469(r4.f8317, r4.f8314)) {
                            r02.f8346.add(r4);
                        }
                    }
                } else {
                    m6465(r02);
                }
                r02.m6467();
            }
            list = m6462(r02);
        }
        if (!list.isEmpty()) {
            f8338.put(cls, list);
            return list;
        }
        throw new EventBusException("Subscriber " + cls + " and its super classes have no public methods with the @Subscribe annotation");
    }

    /* renamed from: 㳳.ῲ.K.㗗$K  reason: contains not printable characters */
    /* compiled from: SubscriberMethodFinder */
    public static class C2415 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final Map<String, Class> f8342 = new HashMap();

        /* renamed from: ඓ  reason: contains not printable characters */
        public Class<?> f8343;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final Map<Class, Object> f8344 = new HashMap();

        /* renamed from: ⁱ  reason: contains not printable characters */
        public AbstractC2406 f8345;

        /* renamed from: K  reason: contains not printable characters */
        public final List<C2402> f8346 = new ArrayList();

        /* renamed from: 㴹  reason: contains not printable characters */
        public boolean f8347;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final StringBuilder f8348 = new StringBuilder(128);

        /* renamed from: ῲ  reason: contains not printable characters */
        public final boolean m6466(Method method, Class<?> cls) {
            this.f8348.setLength(0);
            this.f8348.append(method.getName());
            StringBuilder sb = this.f8348;
            sb.append('>');
            sb.append(cls.getName());
            String sb2 = this.f8348.toString();
            Class<?> declaringClass = method.getDeclaringClass();
            Class put = this.f8342.put(sb2, declaringClass);
            if (put == null || put.isAssignableFrom(declaringClass)) {
                return true;
            }
            this.f8342.put(sb2, put);
            return false;
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m6468(Class<?> cls) {
            this.f8343 = cls;
            this.f8347 = false;
        }

        /* renamed from: K  reason: contains not printable characters */
        public boolean m6469(Method method, Class<?> cls) {
            Object put = this.f8344.put(cls, method);
            if (put == null) {
                return true;
            }
            if (put instanceof Method) {
                if (m6466((Method) put, cls)) {
                    this.f8344.put(cls, this);
                } else {
                    throw new IllegalStateException();
                }
            }
            return m6466(method, cls);
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m6467() {
            if (this.f8347) {
                this.f8343 = null;
                return;
            }
            this.f8343 = this.f8343.getSuperclass();
            String name = this.f8343.getName();
            if (name.startsWith("java.") || name.startsWith("javax.") || name.startsWith("android.")) {
                this.f8343 = null;
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final C2415 m6464() {
        synchronized (f8337) {
            for (int i = 0; i < 4; i++) {
                C2415 k = f8337[i];
                if (k != null) {
                    f8337[i] = null;
                    return k;
                }
            }
            return new C2415();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m6465(C2415 k) {
        Method[] methodArr;
        try {
            methodArr = k.f8343.getDeclaredMethods();
        } catch (Throwable unused) {
            methodArr = k.f8343.getMethods();
            k.f8347 = true;
        }
        for (Method method : methodArr) {
            int modifiers = method.getModifiers();
            if ((modifiers & 1) != 0 && (modifiers & 5192) == 0) {
                Class<?>[] parameterTypes = method.getParameterTypes();
                if (parameterTypes.length == 1) {
                    AbstractC2413 r7 = (AbstractC2413) method.getAnnotation(AbstractC2413.class);
                    if (r7 != null) {
                        Class<?> cls = parameterTypes[0];
                        if (k.m6469(method, cls)) {
                            k.f8346.add(new C2402(method, cls, r7.threadMode(), r7.priority(), r7.sticky()));
                        }
                    }
                } else if (this.f8340 && method.isAnnotationPresent(AbstractC2413.class)) {
                    throw new EventBusException("@Subscribe method " + (method.getDeclaringClass().getName() + CodelessMatcher.CURRENT_CLASS_NAME + method.getName()) + "must have exactly 1 parameter but has " + parameterTypes.length);
                }
            } else if (this.f8340 && method.isAnnotationPresent(AbstractC2413.class)) {
                throw new EventBusException(C1293.m3412(method.getDeclaringClass().getName() + CodelessMatcher.CURRENT_CLASS_NAME + method.getName(), " is a illegal @Subscribe method: must be public, non-static, and non-abstract"));
            }
        }
    }
}
