package u0;

import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import java.util.ArrayList;
import java.util.List;
import rm.n0;
import rm.y;
import s1.f0;
import s1.g0;
import sm.c0;
import tp.m0;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public final class u {

    /* renamed from: a, reason: collision with root package name */
    private final boolean f36734a;

    /* renamed from: b, reason: collision with root package name */
    private final dn.a f36735b;

    /* renamed from: c, reason: collision with root package name */
    private final y.a f36736c = y.b.b(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, 2, null);

    /* renamed from: d, reason: collision with root package name */
    private final List f36737d = new ArrayList();

    /* renamed from: e, reason: collision with root package name */
    private d0.i f36738e;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class a extends kotlin.coroutines.jvm.internal.l implements dn.p {

        /* renamed from: p, reason: collision with root package name */
        int f36739p;

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ float f36741r;

        /* renamed from: s, reason: collision with root package name */
        final /* synthetic */ y.i f36742s;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        a(float f10, y.i iVar, vm.d dVar) {
            super(2, dVar);
            this.f36741r = f10;
            this.f36742s = iVar;
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            return new a(this.f36741r, this.f36742s, dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f36739p;
            if (i10 == 0) {
                y.b(obj);
                y.a aVar = u.this.f36736c;
                Float b10 = kotlin.coroutines.jvm.internal.b.b(this.f36741r);
                y.i iVar = this.f36742s;
                this.f36739p = 1;
                if (y.a.f(aVar, b10, iVar, null, null, this, 12, null) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
            }
            return n0.f34904a;
        }

        @Override // dn.p
        public final Object invoke(m0 m0Var, vm.d dVar) {
            return ((a) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class b extends kotlin.coroutines.jvm.internal.l implements dn.p {

        /* renamed from: p, reason: collision with root package name */
        int f36743p;

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ y.i f36745r;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        b(y.i iVar, vm.d dVar) {
            super(2, dVar);
            this.f36745r = iVar;
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            return new b(this.f36745r, dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f36743p;
            if (i10 == 0) {
                y.b(obj);
                y.a aVar = u.this.f36736c;
                Float b10 = kotlin.coroutines.jvm.internal.b.b(BitmapDescriptorFactory.HUE_RED);
                y.i iVar = this.f36745r;
                this.f36743p = 1;
                if (y.a.f(aVar, b10, iVar, null, null, this, 12, null) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
            }
            return n0.f34904a;
        }

        @Override // dn.p
        public final Object invoke(m0 m0Var, vm.d dVar) {
            return ((b) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
        }
    }

    public u(boolean z10, dn.a aVar) {
        this.f36734a = z10;
        this.f36735b = aVar;
    }

    public final void b(u1.f fVar, float f10, long j10) {
        float floatValue = ((Number) this.f36736c.m()).floatValue();
        if (floatValue > BitmapDescriptorFactory.HUE_RED) {
            long l10 = g0.l(j10, floatValue, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, 14, null);
            if (!this.f36734a) {
                u1.f.C0(fVar, l10, f10, 0L, BitmapDescriptorFactory.HUE_RED, null, null, 0, 124, null);
                return;
            }
            float i10 = r1.m.i(fVar.b());
            float g10 = r1.m.g(fVar.b());
            int b10 = f0.f35249a.b();
            u1.d Q0 = fVar.Q0();
            long b11 = Q0.b();
            Q0.i().n();
            try {
                Q0.f().c(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, i10, g10, b10);
                u1.f.C0(fVar, l10, f10, 0L, BitmapDescriptorFactory.HUE_RED, null, null, 0, 124, null);
            } finally {
                Q0.i().x();
                Q0.g(b11);
            }
        }
    }

    public final void c(d0.i iVar, m0 m0Var) {
        Object q02;
        y.i e10;
        y.i d10;
        boolean z10 = iVar instanceof d0.g;
        if (z10) {
            this.f36737d.add(iVar);
        } else if (iVar instanceof d0.h) {
            this.f36737d.remove(((d0.h) iVar).a());
        } else if (iVar instanceof d0.d) {
            this.f36737d.add(iVar);
        } else if (iVar instanceof d0.e) {
            this.f36737d.remove(((d0.e) iVar).a());
        } else if (iVar instanceof d0.b) {
            this.f36737d.add(iVar);
        } else if (iVar instanceof d0.c) {
            this.f36737d.remove(((d0.c) iVar).a());
        } else if (!(iVar instanceof d0.a)) {
            return;
        } else {
            this.f36737d.remove(((d0.a) iVar).a());
        }
        q02 = c0.q0(this.f36737d);
        d0.i iVar2 = (d0.i) q02;
        if (kotlin.jvm.internal.t.b(this.f36738e, iVar2)) {
            return;
        }
        if (iVar2 != null) {
            g gVar = (g) this.f36735b.invoke();
            float c10 = z10 ? gVar.c() : iVar instanceof d0.d ? gVar.b() : iVar instanceof d0.b ? gVar.a() : BitmapDescriptorFactory.HUE_RED;
            d10 = p.d(iVar2);
            tp.k.d(m0Var, null, null, new a(c10, d10, null), 3, null);
        } else {
            e10 = p.e(this.f36738e);
            tp.k.d(m0Var, null, null, new b(e10, null), 3, null);
        }
        this.f36738e = iVar2;
    }
}
