package fo;

import ap.d;
import bo.p;
import fo.b;
import io.d0;
import io.u;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import ko.r;
import ko.s;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import lo.a;
import sm.x0;

/* loaded from: classes3.dex */
public final class i extends m {

    /* renamed from: n, reason: collision with root package name */
    private final u f18683n;

    /* renamed from: o, reason: collision with root package name */
    private final h f18684o;

    /* renamed from: p, reason: collision with root package name */
    private final gp.j f18685p;

    /* renamed from: q, reason: collision with root package name */
    private final gp.h f18686q;

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes3.dex */
    public static final class a {

        /* renamed from: a, reason: collision with root package name */
        private final ro.f f18687a;

        /* renamed from: b, reason: collision with root package name */
        private final io.g f18688b;

        public a(ro.f name, io.g gVar) {
            t.g(name, "name");
            this.f18687a = name;
            this.f18688b = gVar;
        }

        public final io.g a() {
            return this.f18688b;
        }

        public final ro.f b() {
            return this.f18687a;
        }

        public boolean equals(Object obj) {
            return (obj instanceof a) && t.b(this.f18687a, ((a) obj).f18687a);
        }

        public int hashCode() {
            return this.f18687a.hashCode();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes3.dex */
    public static abstract class b {

        /* loaded from: classes3.dex */
        public static final class a extends b {

            /* renamed from: a, reason: collision with root package name */
            private final tn.e f18689a;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public a(tn.e descriptor) {
                super(null);
                t.g(descriptor, "descriptor");
                this.f18689a = descriptor;
            }

            public final tn.e a() {
                return this.f18689a;
            }
        }

        /* renamed from: fo.i$b$b, reason: collision with other inner class name */
        /* loaded from: classes3.dex */
        public static final class C0406b extends b {

            /* renamed from: a, reason: collision with root package name */
            public static final C0406b f18690a = new C0406b();

            private C0406b() {
                super(null);
            }
        }

        /* loaded from: classes3.dex */
        public static final class c extends b {

            /* renamed from: a, reason: collision with root package name */
            public static final c f18691a = new c();

            private c() {
                super(null);
            }
        }

        private b() {
        }

        public /* synthetic */ b(kotlin.jvm.internal.k kVar) {
            this();
        }
    }

    /* loaded from: classes3.dex */
    static final class c extends v implements dn.l {

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ eo.g f18693q;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        c(eo.g gVar) {
            super(1);
            this.f18693q = gVar;
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final tn.e invoke(a request) {
            t.g(request, "request");
            ro.b bVar = new ro.b(i.this.C().d(), request.b());
            r.a c10 = request.a() != null ? this.f18693q.a().j().c(request.a(), i.this.R()) : this.f18693q.a().j().b(bVar, i.this.R());
            ko.t a10 = c10 != null ? c10.a() : null;
            ro.b e10 = a10 != null ? a10.e() : null;
            if (e10 != null && (e10.l() || e10.k())) {
                return null;
            }
            b T = i.this.T(a10);
            if (T instanceof b.a) {
                return ((b.a) T).a();
            }
            if (T instanceof b.c) {
                return null;
            }
            if (!(T instanceof b.C0406b)) {
                throw new rm.t();
            }
            io.g a11 = request.a();
            if (a11 == null) {
                a11 = this.f18693q.a().d().b(new p.a(bVar, null, null, 4, null));
            }
            io.g gVar = a11;
            if ((gVar != null ? gVar.I() : null) != d0.BINARY) {
                ro.c d10 = gVar != null ? gVar.d() : null;
                if (d10 == null || d10.d() || !t.b(d10.e(), i.this.C().d())) {
                    return null;
                }
                f fVar = new f(this.f18693q, i.this.C(), gVar, null, 8, null);
                this.f18693q.a().e().a(fVar);
                return fVar;
            }
            throw new IllegalStateException("Couldn't find kotlin binary class for light class created by kotlin binary file\nJavaClass: " + gVar + "\nClassId: " + bVar + "\nfindKotlinClass(JavaClass) = " + s.a(this.f18693q.a().j(), gVar, i.this.R()) + "\nfindKotlinClass(ClassId) = " + s.b(this.f18693q.a().j(), bVar, i.this.R()) + '\n');
        }
    }

    /* loaded from: classes3.dex */
    static final class d extends v implements dn.a {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ eo.g f18694p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ i f18695q;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        d(eo.g gVar, i iVar) {
            super(0);
            this.f18694p = gVar;
            this.f18695q = iVar;
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Set invoke() {
            return this.f18694p.a().d().a(this.f18695q.C().d());
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public i(eo.g c10, u jPackage, h ownerDescriptor) {
        super(c10);
        t.g(c10, "c");
        t.g(jPackage, "jPackage");
        t.g(ownerDescriptor, "ownerDescriptor");
        this.f18683n = jPackage;
        this.f18684o = ownerDescriptor;
        this.f18685p = c10.e().d(new d(c10, this));
        this.f18686q = c10.e().h(new c(c10));
    }

    private final tn.e O(ro.f fVar, io.g gVar) {
        if (!ro.h.f34966a.a(fVar)) {
            return null;
        }
        Set set = (Set) this.f18685p.invoke();
        if (gVar != null || set == null || set.contains(fVar.e())) {
            return (tn.e) this.f18686q.invoke(new a(fVar, gVar));
        }
        return null;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final qo.e R() {
        return pp.c.a(w().a().b().d().g());
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final b T(ko.t tVar) {
        if (tVar == null) {
            return b.C0406b.f18690a;
        }
        if (tVar.a().c() != a.EnumC0634a.CLASS) {
            return b.c.f18691a;
        }
        tn.e l10 = w().a().b().l(tVar);
        return l10 != null ? new b.a(l10) : b.C0406b.f18690a;
    }

    public final tn.e P(io.g javaClass) {
        t.g(javaClass, "javaClass");
        return O(javaClass.getName(), javaClass);
    }

    @Override // ap.i, ap.k
    /* renamed from: Q, reason: merged with bridge method [inline-methods] */
    public tn.e e(ro.f name, ao.b location) {
        t.g(name, "name");
        t.g(location, "location");
        return O(name, null);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // fo.j
    /* renamed from: S, reason: merged with bridge method [inline-methods] */
    public h C() {
        return this.f18684o;
    }

    @Override // fo.j, ap.i, ap.h
    public Collection c(ro.f name, ao.b location) {
        List k10;
        t.g(name, "name");
        t.g(location, "location");
        k10 = sm.u.k();
        return k10;
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x0062 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:19:0x0035 A[SYNTHETIC] */
    @Override // fo.j, ap.i, ap.k
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Collection f(ap.d kindFilter, dn.l nameFilter) {
        boolean z10;
        List k10;
        t.g(kindFilter, "kindFilter");
        t.g(nameFilter, "nameFilter");
        d.a aVar = ap.d.f6107c;
        if (!kindFilter.a(aVar.e() | aVar.c())) {
            k10 = sm.u.k();
            return k10;
        }
        Iterable iterable = (Iterable) v().invoke();
        ArrayList arrayList = new ArrayList();
        for (Object obj : iterable) {
            tn.m mVar = (tn.m) obj;
            if (mVar instanceof tn.e) {
                ro.f name = ((tn.e) mVar).getName();
                t.f(name, "getName(...)");
                if (((Boolean) nameFilter.invoke(name)).booleanValue()) {
                    z10 = true;
                    if (!z10) {
                        arrayList.add(obj);
                    }
                }
            }
            z10 = false;
            if (!z10) {
            }
        }
        return arrayList;
    }

    @Override // fo.j
    protected Set l(ap.d kindFilter, dn.l lVar) {
        Set d10;
        t.g(kindFilter, "kindFilter");
        if (!kindFilter.a(ap.d.f6107c.e())) {
            d10 = x0.d();
            return d10;
        }
        Set set = (Set) this.f18685p.invoke();
        if (set != null) {
            HashSet hashSet = new HashSet();
            Iterator it = set.iterator();
            while (it.hasNext()) {
                hashSet.add(ro.f.s((String) it.next()));
            }
            return hashSet;
        }
        u uVar = this.f18683n;
        if (lVar == null) {
            lVar = pp.e.a();
        }
        Collection<io.g> B = uVar.B(lVar);
        LinkedHashSet linkedHashSet = new LinkedHashSet();
        for (io.g gVar : B) {
            ro.f name = gVar.I() == d0.SOURCE ? null : gVar.getName();
            if (name != null) {
                linkedHashSet.add(name);
            }
        }
        return linkedHashSet;
    }

    @Override // fo.j
    protected Set n(ap.d kindFilter, dn.l lVar) {
        Set d10;
        t.g(kindFilter, "kindFilter");
        d10 = x0.d();
        return d10;
    }

    @Override // fo.j
    protected fo.b p() {
        return b.a.f18624a;
    }

    @Override // fo.j
    protected void r(Collection result, ro.f name) {
        t.g(result, "result");
        t.g(name, "name");
    }

    @Override // fo.j
    protected Set t(ap.d kindFilter, dn.l lVar) {
        Set d10;
        t.g(kindFilter, "kindFilter");
        d10 = x0.d();
        return d10;
    }
}
