package androidx.compose.ui.viewinterop;

import android.content.Context;
import android.os.Parcelable;
import android.util.SparseArray;
import android.view.View;
import androidx.compose.ui.platform.e3;
import dn.l;
import i1.g;
import j2.j1;
import kotlin.jvm.internal.k;
import kotlin.jvm.internal.v;
import rm.n0;
import y0.r;

/* loaded from: classes.dex */
public final class i extends androidx.compose.ui.viewinterop.c implements e3 {
    private final View P;
    private final c2.b Q;
    private final i1.g R;
    private final int S;
    private final String T;
    private g.a U;
    private l V;
    private l W;

    /* renamed from: a0, reason: collision with root package name */
    private l f2889a0;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class a extends v implements dn.a {
        a() {
            super(0);
        }

        @Override // dn.a
        public final Object invoke() {
            SparseArray<Parcelable> sparseArray = new SparseArray<>();
            i.this.P.saveHierarchyState(sparseArray);
            return sparseArray;
        }
    }

    /* loaded from: classes.dex */
    static final class b extends v implements dn.a {
        b() {
            super(0);
        }

        @Override // dn.a
        public /* bridge */ /* synthetic */ Object invoke() {
            m30invoke();
            return n0.f34904a;
        }

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m30invoke() {
            i.this.getReleaseBlock().invoke(i.this.P);
            i.this.z();
        }
    }

    /* loaded from: classes.dex */
    static final class c extends v implements dn.a {
        c() {
            super(0);
        }

        @Override // dn.a
        public /* bridge */ /* synthetic */ Object invoke() {
            m31invoke();
            return n0.f34904a;
        }

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m31invoke() {
            i.this.getResetBlock().invoke(i.this.P);
        }
    }

    /* loaded from: classes.dex */
    static final class d extends v implements dn.a {
        d() {
            super(0);
        }

        @Override // dn.a
        public /* bridge */ /* synthetic */ Object invoke() {
            m32invoke();
            return n0.f34904a;
        }

        /* renamed from: invoke, reason: collision with other method in class */
        public final void m32invoke() {
            i.this.getUpdateBlock().invoke(i.this.P);
        }
    }

    /* synthetic */ i(Context context, r rVar, View view, c2.b bVar, i1.g gVar, int i10, j1 j1Var, int i11, k kVar) {
        this(context, (i11 & 2) != 0 ? null : rVar, view, (i11 & 8) != 0 ? new c2.b() : bVar, gVar, i10, j1Var);
    }

    private final void setSavableRegistryEntry(g.a aVar) {
        g.a aVar2 = this.U;
        if (aVar2 != null) {
            aVar2.unregister();
        }
        this.U = aVar;
    }

    private final void y() {
        i1.g gVar = this.R;
        if (gVar != null) {
            setSavableRegistryEntry(gVar.e(this.T, new a()));
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void z() {
        setSavableRegistryEntry(null);
    }

    public final c2.b getDispatcher() {
        return this.Q;
    }

    public final l getReleaseBlock() {
        return this.f2889a0;
    }

    public final l getResetBlock() {
        return this.W;
    }

    @Override // androidx.compose.ui.platform.e3
    public /* bridge */ /* synthetic */ androidx.compose.ui.platform.a getSubCompositionView() {
        return super.getSubCompositionView();
    }

    public final l getUpdateBlock() {
        return this.V;
    }

    @Override // androidx.compose.ui.platform.e3
    public View getViewRoot() {
        return this;
    }

    public final void setReleaseBlock(l lVar) {
        this.f2889a0 = lVar;
        setRelease(new b());
    }

    public final void setResetBlock(l lVar) {
        this.W = lVar;
        setReset(new c());
    }

    public final void setUpdateBlock(l lVar) {
        this.V = lVar;
        setUpdate(new d());
    }

    private i(Context context, r rVar, View view, c2.b bVar, i1.g gVar, int i10, j1 j1Var) {
        super(context, rVar, i10, bVar, view, j1Var);
        this.P = view;
        this.Q = bVar;
        this.R = gVar;
        this.S = i10;
        setClipChildren(false);
        String valueOf = String.valueOf(i10);
        this.T = valueOf;
        Object d10 = gVar != null ? gVar.d(valueOf) : null;
        SparseArray<Parcelable> sparseArray = d10 instanceof SparseArray ? (SparseArray) d10 : null;
        if (sparseArray != null) {
            view.restoreHierarchyState(sparseArray);
        }
        y();
        this.V = e.e();
        this.W = e.e();
        this.f2889a0 = e.e();
    }

    public i(Context context, l lVar, r rVar, i1.g gVar, int i10, j1 j1Var) {
        this(context, rVar, (View) lVar.invoke(context), null, gVar, i10, j1Var, 8, null);
    }
}
