package o;

import android.content.Context;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.common.R;
import java.lang.ref.WeakReference;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.z, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public abstract class AbstractC3054z extends ViewGroup {
    public WeakReference l;
    public IBinder m;
    public Qm0 n;

    /* renamed from: o, reason: collision with root package name */
    public AbstractC0425Qk f817o;
    public C2391s00 p;
    public boolean q;
    public boolean r;
    public boolean s;

    public AbstractC3054z(Context context) {
        super(context, null, 0);
        setClipChildren(false);
        setClipToPadding(false);
        setImportantForAccessibility(1);
        ViewOnAttachStateChangeListenerC2491t3 viewOnAttachStateChangeListenerC2491t3 = new ViewOnAttachStateChangeListenerC2491t3(6, this);
        addOnAttachStateChangeListener(viewOnAttachStateChangeListenerC2491t3);
        C0387Oy c0387Oy = new C0387Oy(29);
        F3.A(this).a.add(c0387Oy);
        this.p = new C2391s00(this, viewOnAttachStateChangeListenerC2491t3, c0387Oy, 1);
    }

    private final void setParentContext(AbstractC0425Qk abstractC0425Qk) {
        if (this.f817o != abstractC0425Qk) {
            this.f817o = abstractC0425Qk;
            if (abstractC0425Qk != null) {
                this.l = null;
            }
            Qm0 qm0 = this.n;
            if (qm0 != null) {
                qm0.a();
                this.n = null;
                if (isAttachedToWindow()) {
                    c();
                }
            }
        }
    }

    private final void setPreviousAttachedWindowToken(IBinder iBinder) {
        if (this.m != iBinder) {
            this.m = iBinder;
            this.l = null;
        }
    }

    public abstract void a(int i, C0321Mk c0321Mk);

    @Override // android.view.ViewGroup
    public final void addView(View view) {
        b();
        super.addView(view);
    }

    @Override // android.view.ViewGroup
    public final boolean addViewInLayout(View view, int i, ViewGroup.LayoutParams layoutParams) {
        b();
        return super.addViewInLayout(view, i, layoutParams);
    }

    public final void b() {
        if (this.r) {
            return;
        }
        throw new UnsupportedOperationException("Cannot add views to " + getClass().getSimpleName() + "; only Compose content is supported");
    }

    public final void c() {
        if (this.n == null) {
            try {
                this.r = true;
                this.n = Tm0.a(this, f(), new C0554Vj(-656146368, true, new C2959y(0, this)));
            } finally {
                this.r = false;
            }
        }
    }

    public void d(boolean z, int i, int i2, int i3, int i4) {
        View childAt = getChildAt(0);
        if (childAt != null) {
            childAt.layout(getPaddingLeft(), getPaddingTop(), (i3 - i) - getPaddingRight(), (i4 - i2) - getPaddingBottom());
        }
    }

    public void e(int i, int i2) {
        View childAt = getChildAt(0);
        if (childAt == null) {
            super.onMeasure(i, i2);
            return;
        }
        childAt.measure(View.MeasureSpec.makeMeasureSpec(Math.max(0, (View.MeasureSpec.getSize(i) - getPaddingLeft()) - getPaddingRight()), View.MeasureSpec.getMode(i)), View.MeasureSpec.makeMeasureSpec(Math.max(0, (View.MeasureSpec.getSize(i2) - getPaddingTop()) - getPaddingBottom()), View.MeasureSpec.getMode(i2)));
        setMeasuredDimension(getPaddingRight() + getPaddingLeft() + childAt.getMeasuredWidth(), getPaddingBottom() + getPaddingTop() + childAt.getMeasuredHeight());
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final AbstractC0425Qk f() {
        P00 p00;
        InterfaceC2747vn interfaceC2747vn;
        N5 n5;
        AbstractC0425Qk abstractC0425QkB = this.f817o;
        if (abstractC0425QkB == null) {
            abstractC0425QkB = Yl0.b(this);
            if (abstractC0425QkB == null) {
                Object parent = getParent();
                while (abstractC0425QkB == null && (parent instanceof View)) {
                    View view = (View) parent;
                    abstractC0425QkB = Yl0.b(view);
                    parent = view.getParent();
                }
            }
            if (abstractC0425QkB != null) {
                AbstractC0425Qk abstractC0425Qk = (!(abstractC0425QkB instanceof P00) || ((M00) ((P00) abstractC0425QkB).t.getValue()).compareTo(M00.m) > 0) ? abstractC0425QkB : null;
                if (abstractC0425Qk != null) {
                    this.l = new WeakReference(abstractC0425Qk);
                }
            } else {
                abstractC0425QkB = null;
            }
            if (abstractC0425QkB == null) {
                WeakReference weakReference = this.l;
                if (weakReference == null || (abstractC0425QkB = (AbstractC0425Qk) weakReference.get()) == null || ((abstractC0425QkB instanceof P00) && ((M00) ((P00) abstractC0425QkB).t.getValue()).compareTo(M00.m) <= 0)) {
                    abstractC0425QkB = null;
                }
                if (abstractC0425QkB == null) {
                    if (!isAttachedToWindow()) {
                        AbstractC2133pH.b("Cannot locate windowRecomposer; View " + this + " is not attached to a window");
                    }
                    Object parent2 = getParent();
                    View view2 = this;
                    while (parent2 instanceof View) {
                        View view3 = (View) parent2;
                        if (view3.getId() == 16908290) {
                            break;
                        }
                        view2 = view3;
                        parent2 = view3.getParent();
                    }
                    AbstractC0425Qk abstractC0425QkB2 = Yl0.b(view2);
                    if (abstractC0425QkB2 == null) {
                        ((Tl0) Ul0.a.get()).getClass();
                        C0281Kv c0281Kv = C0281Kv.l;
                        C1014dc0 c1014dc0 = L5.w;
                        if (Looper.myLooper() == Looper.getMainLooper()) {
                            interfaceC2747vn = (InterfaceC2747vn) L5.w.getValue();
                        } else {
                            interfaceC2747vn = (InterfaceC2747vn) L5.x.get();
                            if (interfaceC2747vn == null) {
                                throw new IllegalStateException("no AndroidUiDispatcher for this thread");
                            }
                        }
                        InterfaceC2747vn interfaceC2747vnM = interfaceC2747vn.M(c0281Kv);
                        SP sp = (SP) interfaceC2747vnM.m(ME.w);
                        if (sp != null) {
                            N5 n52 = new N5(sp);
                            C0949cs c0949cs = (C0949cs) n52.n;
                            synchronized (c0949cs.b) {
                                c0949cs.a = false;
                                n5 = n52;
                            }
                        } else {
                            n5 = 0;
                        }
                        B10 b10 = new B10();
                        InterfaceC2747vn wp = (VP) interfaceC2747vnM.m(C0669Zu.N);
                        if (wp == null) {
                            wp = new WP();
                            b10.l = wp;
                        }
                        if (n5 != 0) {
                            c0281Kv = n5;
                        }
                        InterfaceC2747vn interfaceC2747vnM2 = interfaceC2747vnM.M(c0281Kv).M(wp);
                        P00 p002 = new P00(interfaceC2747vnM2);
                        synchronized (p002.b) {
                            p002.s = true;
                        }
                        C0168Gm c0168GmE = C80.e(interfaceC2747vnM2);
                        InterfaceC0898cL interfaceC0898cLP = AbstractC2461sm0.p(view2);
                        WK lifecycle = interfaceC0898cLP != null ? interfaceC0898cLP.getLifecycle() : null;
                        if (lifecycle == null) {
                            AbstractC2133pH.c("ViewTreeLifecycleOwner not found from " + view2);
                            throw new C2170pj();
                        }
                        view2.addOnAttachStateChangeListener(new Vl0(view2, p002));
                        lifecycle.a(new Xl0(c0168GmE, n5, p002, b10, view2));
                        view2.setTag(R.id.androidx_compose_ui_view_composition_context, p002);
                        UD ud = UD.l;
                        Handler handler = view2.getHandler();
                        int i = CE.a;
                        view2.addOnAttachStateChangeListener(new ViewOnAttachStateChangeListenerC2491t3(7, AbstractC1692kh0.C(ud, new BE(handler, "windowRecomposer cleanup", false).p, new C1857mQ(p002, view2, interfaceC0220Im, 10), 2)));
                        p00 = p002;
                    } else {
                        if (!(abstractC0425QkB2 instanceof P00)) {
                            throw new IllegalStateException("root viewTreeParentCompositionContext is not a Recomposer");
                        }
                        p00 = (P00) abstractC0425QkB2;
                    }
                    interfaceC0220Im = ((M00) p00.t.getValue()).compareTo(M00.m) > 0 ? p00 : null;
                    if (interfaceC0220Im != null) {
                        this.l = new WeakReference(interfaceC0220Im);
                    }
                    return p00;
                }
            }
        }
        return abstractC0425QkB;
    }

    public final boolean getHasComposition() {
        return this.n != null;
    }

    public boolean getShouldCreateCompositionOnAttachedToWindow() {
        return true;
    }

    public final boolean getShowLayoutBounds() {
        return this.q;
    }

    @Override // android.view.ViewGroup
    public final boolean isTransitionGroup() {
        return !this.s || super.isTransitionGroup();
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        setPreviousAttachedWindowToken(getWindowToken());
        if (getShouldCreateCompositionOnAttachedToWindow()) {
            c();
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onLayout(boolean z, int i, int i2, int i3, int i4) {
        d(z, i, i2, i3, i4);
    }

    @Override // android.view.View
    public final void onMeasure(int i, int i2) {
        c();
        e(i, i2);
    }

    @Override // android.view.View
    public final void onRtlPropertiesChanged(int i) {
        View childAt = getChildAt(0);
        if (childAt != null) {
            childAt.setLayoutDirection(i);
        }
    }

    public final void setParentCompositionContext(AbstractC0425Qk abstractC0425Qk) {
        setParentContext(abstractC0425Qk);
    }

    public final void setShowLayoutBounds(boolean z) {
        this.q = z;
        KeyEvent.Callback childAt = getChildAt(0);
        if (childAt != null) {
            ((C2207q3) ((InterfaceC1577jV) childAt)).setShowLayoutBounds(z);
        }
    }

    @Override // android.view.ViewGroup
    public void setTransitionGroup(boolean z) {
        super.setTransitionGroup(z);
        this.s = true;
    }

    public final void setViewCompositionStrategy(Pj0 pj0) {
        C2391s00 c2391s00 = this.p;
        if (c2391s00 != null) {
            c2391s00.a();
        }
        ((C2887xC) pj0).getClass();
        ViewOnAttachStateChangeListenerC2491t3 viewOnAttachStateChangeListenerC2491t3 = new ViewOnAttachStateChangeListenerC2491t3(6, this);
        addOnAttachStateChangeListener(viewOnAttachStateChangeListenerC2491t3);
        C0387Oy c0387Oy = new C0387Oy(29);
        F3.A(this).a.add(c0387Oy);
        this.p = new C2391s00(this, viewOnAttachStateChangeListenerC2491t3, c0387Oy, 1);
    }

    @Override // android.view.ViewGroup
    public final boolean shouldDelayChildPressedState() {
        return false;
    }

    @Override // android.view.ViewGroup
    public final void addView(View view, int i) {
        b();
        super.addView(view, i);
    }

    @Override // android.view.ViewGroup
    public final boolean addViewInLayout(View view, int i, ViewGroup.LayoutParams layoutParams, boolean z) {
        b();
        return super.addViewInLayout(view, i, layoutParams, z);
    }

    @Override // android.view.ViewGroup
    public final void addView(View view, int i, int i2) {
        b();
        super.addView(view, i, i2);
    }

    @Override // android.view.ViewGroup, android.view.ViewManager
    public final void addView(View view, ViewGroup.LayoutParams layoutParams) {
        b();
        super.addView(view, layoutParams);
    }

    @Override // android.view.ViewGroup
    public final void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
        b();
        super.addView(view, i, layoutParams);
    }

    private static /* synthetic */ void getDisposeViewCompositionStrategy$annotations() {
    }

    public static /* synthetic */ void getShowLayoutBounds$annotations() {
    }
}
