package p421.p422.p423.p431;

import java.io.PrintStream;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p242.p246.p251.C4303;
import p421.p422.p423.p428.InterfaceC6727;
import p421.p422.p423.p429.p430.C6745;
import p421.p422.p423.p432.C6764;

/* JADX INFO: renamed from: ޏ.֏.֏.ށ.ކ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C6758 {

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static final InterfaceC6727<Method> f19541 = new C6759();

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Map<Class<? extends InterfaceC6753>, InterfaceC6753> f19542 = new HashMap();

    /* JADX INFO: renamed from: ޏ.֏.֏.ށ.ކ$֏, reason: contains not printable characters */
    public static class C6759 implements InterfaceC6727<Method> {
    }

    /* JADX WARN: Removed duplicated region for block: B:119:0x0241 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:121:0x006e A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:25:0x0070 A[LOOP:1: B:5:0x001f->B:25:0x0070, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00ea  */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public C6757 m9920(Class cls) {
        boolean z;
        boolean z2;
        InterfaceC6753[] interfaceC6753Arr;
        Method declaredMethod;
        boolean z3;
        C6757 c6757 = new C6757(cls);
        InterfaceC6727<Method> interfaceC6727 = f19541;
        ArrayList arrayList = new ArrayList();
        C4303.m7113(interfaceC6727, (Class<?>) cls, (ArrayList<Method>) arrayList);
        int size = arrayList.size();
        Method[] methodArr = new Method[size];
        arrayList.toArray(methodArr);
        char c = 0;
        for (int i = 0; i < size; i++) {
            Method method = methodArr[i];
            int i2 = 0;
            while (true) {
                if (i2 >= size) {
                    z = false;
                    break;
                }
                Method method2 = methodArr[i2];
                if (!method.getDeclaringClass().equals(method2.getDeclaringClass()) && method.getDeclaringClass().isAssignableFrom(method2.getDeclaringClass()) && method.getName().equals(method2.getName())) {
                    Class<?>[] parameterTypes = method.getParameterTypes();
                    Class<?>[] parameterTypes2 = method2.getParameterTypes();
                    for (int i3 = 0; i3 < parameterTypes2.length; i3++) {
                        if (!parameterTypes[i3].equals(parameterTypes2[i3])) {
                            z3 = false;
                            break;
                        }
                    }
                    z3 = true;
                    if (!z3) {
                    }
                } else {
                    z3 = false;
                    if (!z3) {
                        z = true;
                        break;
                    }
                    i2++;
                }
            }
            if (!z) {
                InterfaceC6752 interfaceC6752 = (InterfaceC6752) C4303.m7029((AnnotatedElement) method, InterfaceC6752.class);
                if (!interfaceC6752.enabled()) {
                    continue;
                } else if (method == null || C4303.m7029((AnnotatedElement) method, InterfaceC6752.class) == null) {
                    z2 = false;
                    if (z2) {
                        Class superclass = cls;
                        while (true) {
                            interfaceC6753Arr = null;
                            if (superclass.equals(method.getDeclaringClass())) {
                                declaredMethod = null;
                                break;
                            }
                            try {
                                declaredMethod = superclass.getDeclaredMethod(method.getName(), method.getParameterTypes());
                                break;
                            } catch (NoSuchMethodException unused) {
                                superclass = superclass.getSuperclass();
                            }
                        }
                        if (declaredMethod != null) {
                            method = declaredMethod;
                        }
                        if (interfaceC6752.filters().length != 0) {
                            interfaceC6753Arr = new InterfaceC6753[interfaceC6752.filters().length];
                            int i4 = 0;
                            for (InterfaceC6751 interfaceC6751 : interfaceC6752.filters()) {
                                InterfaceC6753 interfaceC6753NewInstance = this.f19542.get(interfaceC6751.value());
                                if (interfaceC6753NewInstance == null) {
                                    try {
                                        interfaceC6753NewInstance = interfaceC6751.value().newInstance();
                                        this.f19542.put(interfaceC6751.value(), interfaceC6753NewInstance);
                                    } catch (Exception e) {
                                        throw new RuntimeException(e);
                                    }
                                }
                                interfaceC6753Arr[i4] = interfaceC6753NewInstance;
                                i4++;
                            }
                        }
                        c = 0;
                        if (interfaceC6753Arr == null) {
                            interfaceC6753Arr = new InterfaceC6753[0];
                        }
                        InterfaceC6750 interfaceC6750 = (InterfaceC6750) C4303.m7029((AnnotatedElement) method, InterfaceC6750.class);
                        Class[] clsArrMessages = interfaceC6750 != null ? interfaceC6750.messages() : method.getParameterTypes();
                        method.setAccessible(true);
                        HashMap map = new HashMap();
                        map.put("handler", method);
                        if (interfaceC6752.condition().length() > 0) {
                            if (!(C6745.C6746.f19521 != null)) {
                                throw new IllegalStateException("A handler uses an EL filter but no EL implementation is available.");
                            }
                            InterfaceC6753[] interfaceC6753Arr2 = new InterfaceC6753[interfaceC6753Arr.length + 1];
                            for (int i5 = 0; i5 < interfaceC6753Arr.length; i5++) {
                                interfaceC6753Arr2[i5] = interfaceC6753Arr[i5];
                            }
                            interfaceC6753Arr2[interfaceC6753Arr.length] = new C6745();
                            interfaceC6753Arr = interfaceC6753Arr2;
                        }
                        map.put("filter", interfaceC6753Arr);
                        String strCondition = interfaceC6752.condition();
                        if (!strCondition.trim().startsWith("${") && !strCondition.trim().startsWith("#{")) {
                            strCondition = C2803.m4880("${", strCondition, "}");
                        }
                        map.put("condition", strCondition);
                        map.put("priority", Integer.valueOf(interfaceC6752.priority()));
                        map.put("invocation", interfaceC6752.invocation());
                        map.put("invocationMode", interfaceC6752.delivery());
                        map.put("envelope", Boolean.valueOf(interfaceC6750 != null));
                        map.put("subtypes", Boolean.valueOf(!interfaceC6752.rejectSubtypes()));
                        map.put("listener", c6757);
                        map.put("synchronized", Boolean.valueOf(C4303.m7029((AnnotatedElement) method, InterfaceC6761.class) != null));
                        map.put("messages", clsArrMessages);
                        c6757.f19539.add(new C6756(map));
                    } else {
                        continue;
                    }
                } else {
                    if (method.getParameterTypes().length != 1) {
                        PrintStream printStream = System.out;
                        StringBuilder sbM4889 = C2803.m4889("Found no or more than one parameter in messageHandler [");
                        sbM4889.append(method.getName());
                        sbM4889.append("]. A messageHandler must define exactly one parameter");
                        printStream.println(sbM4889.toString());
                    } else {
                        InterfaceC6750 interfaceC67502 = (InterfaceC6750) C4303.m7029((AnnotatedElement) method, InterfaceC6750.class);
                        if (interfaceC67502 != null && !C6764.class.isAssignableFrom(method.getParameterTypes()[c])) {
                            System.out.println("Message envelope configured but no subclass of MessageEnvelope found as parameter");
                        } else if (interfaceC67502 == null || interfaceC67502.messages().length != 0) {
                            z2 = true;
                            if (z2) {
                            }
                        } else {
                            System.out.println("Message envelope configured but message types defined for handler");
                        }
                    }
                    z2 = false;
                    if (z2) {
                    }
                }
            }
        }
        return c6757;
    }
}
