package o;

import android.graphics.Canvas;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.LinkedHashMap;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.g5, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1260g5 extends LP implements InterfaceC0581Wk, InterfaceC1905mt, InterfaceC0993dK {
    public final boolean A;
    public final float B;
    public final C1426hr C;
    public final C1330gr D;
    public C2398s4 E;
    public float F;
    public boolean H;
    public Z20 J;
    public C0683a30 K;
    public final KQ z;
    public long G = 0;
    public final UQ I = new UQ();

    public C1260g5(KQ kq, boolean z, float f, C1426hr c1426hr, C1330gr c1330gr) {
        this.z = kq;
        this.A = z;
        this.B = f;
        this.C = c1426hr;
        this.D = c1330gr;
    }

    @Override // o.LP
    public final void A0() {
        Z20 z20 = this.J;
        if (z20 != null) {
            this.K = null;
            AbstractC2461sm0.A(this);
            C3040yr c3040yr = z20.f433o;
            C0683a30 c0683a30 = (C0683a30) ((LinkedHashMap) c3040yr.m).get(this);
            if (c0683a30 != null) {
                c0683a30.c();
                LinkedHashMap linkedHashMap = (LinkedHashMap) c3040yr.m;
                C0683a30 c0683a302 = (C0683a30) linkedHashMap.get(this);
                if (c0683a302 != null) {
                }
                linkedHashMap.remove(this);
                z20.n.add(c0683a30);
            }
        }
    }

    public final void H0(CY cy) {
        C0683a30 c0683a30;
        if (!(cy instanceof AY)) {
            if (cy instanceof BY) {
                C0683a30 c0683a302 = this.K;
                if (c0683a302 != null) {
                    c0683a302.d();
                    return;
                }
                return;
            }
            if (!(cy instanceof C3099zY) || (c0683a30 = this.K) == null) {
                return;
            }
            c0683a30.d();
            return;
        }
        AY ay = (AY) cy;
        long j = this.G;
        float f = this.F;
        Z20 z20 = this.J;
        if (z20 == null) {
            Object obj = (View) AbstractC2461sm0.j(this, N3.f);
            while (!(obj instanceof ViewGroup)) {
                Object parent = ((View) obj).getParent();
                if (!(parent instanceof View)) {
                    throw new IllegalArgumentException(("Couldn't find a valid parent for " + obj + ". Are you overriding LocalView and providing a View that is not attached to the view hierarchy?").toString());
                }
                obj = parent;
            }
            ViewGroup viewGroup = (ViewGroup) obj;
            int childCount = viewGroup.getChildCount();
            int i = 0;
            while (true) {
                if (i >= childCount) {
                    Z20 z202 = new Z20(viewGroup.getContext());
                    viewGroup.addView(z202);
                    z20 = z202;
                    break;
                } else {
                    View childAt = viewGroup.getChildAt(i);
                    if (childAt instanceof Z20) {
                        z20 = (Z20) childAt;
                        break;
                    }
                    i++;
                }
            }
            this.J = z20;
        }
        ArrayList arrayList = z20.m;
        C3040yr c3040yr = z20.f433o;
        LinkedHashMap linkedHashMap = (LinkedHashMap) c3040yr.m;
        LinkedHashMap linkedHashMap2 = (LinkedHashMap) c3040yr.m;
        LinkedHashMap linkedHashMap3 = (LinkedHashMap) c3040yr.n;
        C0683a30 c0683a303 = (C0683a30) linkedHashMap.get(this);
        if (c0683a303 == null) {
            ArrayList arrayList2 = z20.n;
            c0683a303 = (C0683a30) (arrayList2.isEmpty() ? null : arrayList2.remove(0));
            if (c0683a303 == null) {
                if (z20.p > AbstractC0008Ai.R(arrayList)) {
                    c0683a303 = new C0683a30(z20.getContext());
                    z20.addView(c0683a303);
                    arrayList.add(c0683a303);
                } else {
                    c0683a303 = (C0683a30) arrayList.get(z20.p);
                    C1260g5 c1260g5 = (C1260g5) linkedHashMap3.get(c0683a303);
                    if (c1260g5 != null) {
                        c1260g5.K = null;
                        AbstractC2461sm0.A(c1260g5);
                        C0683a30 c0683a304 = (C0683a30) linkedHashMap2.get(c1260g5);
                        if (c0683a304 != null) {
                        }
                        linkedHashMap2.remove(c1260g5);
                        c0683a303.c();
                    }
                }
                int i2 = z20.p;
                if (i2 < z20.l - 1) {
                    z20.p = i2 + 1;
                } else {
                    z20.p = 0;
                }
            }
            linkedHashMap2.put(this, c0683a303);
            linkedHashMap3.put(c0683a303, this);
        }
        C0683a30 c0683a305 = c0683a303;
        int iD = C2887xC.D(f);
        long jA = this.C.a();
        this.D.a();
        c0683a305.b(ay, this.A, j, iD, jA, new C1164f5(0, this));
        this.K = c0683a305;
        AbstractC2461sm0.A(this);
    }

    @Override // o.InterfaceC1905mt
    public final void r(C2610uK c2610uK) {
        C3113zg c3113zg = c2610uK.l;
        c2610uK.a();
        C2398s4 c2398s4 = this.E;
        if (c2398s4 != null) {
            float f = this.F;
            long jA = this.C.a();
            float fFloatValue = ((Number) ((C1738l6) c2398s4.c).c()).floatValue();
            if (fFloatValue > 0.0f) {
                long jB = C0190Hi.b(fFloatValue, jA);
                if (c2398s4.a) {
                    float fD = T80.d(c3113zg.f());
                    float fB = T80.b(c3113zg.f());
                    C3126zm0 c3126zm0 = c3113zg.m;
                    long jD = c3126zm0.D();
                    c3126zm0.x().n();
                    try {
                        ((C3126zm0) ((OD) c3126zm0.m).m).x().i(0.0f, 0.0f, fD, fB, 1);
                        InterfaceC2095ot.m0(c2610uK, jB, f, 0L, 124);
                    } finally {
                        AbstractC2462sn.t(c3126zm0, jD);
                    }
                } else {
                    InterfaceC2095ot.m0(c2610uK, jB, f, 0L, 124);
                }
            }
        }
        InterfaceC2923xg interfaceC2923xgX = c3113zg.m.x();
        C0683a30 c0683a30 = this.K;
        if (c0683a30 != null) {
            long j = this.G;
            int iD = C2887xC.D(this.F);
            long jA2 = this.C.a();
            this.D.a();
            c0683a30.e(iD, j, jA2);
            Canvas canvas = U2.a;
            c0683a30.draw(((T2) interfaceC2923xgX).a);
        }
    }

    @Override // o.InterfaceC0993dK
    public final void v(long j) {
        float fB;
        this.H = true;
        InterfaceC2281qr interfaceC2281qr = AbstractC2539te.S(this).I;
        this.G = C1884mi0.O(j);
        float f = this.B;
        if (Float.isNaN(f)) {
            long j2 = this.G;
            float f2 = X20.a;
            float fD = T80.d(j2);
            float fB2 = T80.b(j2);
            fB = C1765lT.c((Float.floatToRawIntBits(fB2) & 4294967295L) | (Float.floatToRawIntBits(fD) << 32)) / 2.0f;
            if (this.A) {
                fB += interfaceC2281qr.B(X20.a);
            }
        } else {
            fB = interfaceC2281qr.B(f);
        }
        this.F = fB;
        UQ uq = this.I;
        Object[] objArr = uq.a;
        int i = uq.b;
        for (int i2 = 0; i2 < i; i2++) {
            H0((CY) objArr[i2]);
        }
        uq.c();
    }

    @Override // o.LP
    public final boolean w0() {
        return false;
    }

    @Override // o.LP
    public final void z0() {
        AbstractC1692kh0.C(v0(), null, new C1857mQ(this, (InterfaceC0220Im) null, 4), 3);
    }
}
