package o;

import android.graphics.Rect;
import android.view.Choreographer;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import java.lang.ref.WeakReference;
import java.util.ArrayList;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Ge0 implements InterfaceC2813wX {
    public final View a;
    public final C3126zm0 b;
    public final He0 c;
    public boolean d;
    public OC e;
    public OC f;
    public C2730ve0 g;
    public HG h;
    public final ArrayList i;
    public final Object j;
    public Rect k;
    public final C0248Jo l;
    public final C1479iR m;
    public RunnableC2108p1 n;

    public Ge0(View view, C2207q3 c2207q3) {
        C3126zm0 c3126zm0 = new C3126zm0(view);
        He0 he0 = new He0(Choreographer.getInstance());
        this.a = view;
        this.b = c3126zm0;
        this.c = he0;
        this.e = C2291qw.M;
        this.f = C2291qw.N;
        this.g = new C2730ve0("", 4, Ue0.b);
        this.h = HG.g;
        this.i = new ArrayList();
        this.j = AbstractC2001nt0.y(3, new U4(25, this));
        this.l = new C0248Jo(c2207q3, c3126zm0);
        this.m = new C1479iR(new Fe0[16]);
    }

    @Override // o.InterfaceC2813wX
    public final void a(C2730ve0 c2730ve0, HG hg, C1358h6 c1358h6, C0661Zm c0661Zm) {
        this.d = true;
        this.g = c2730ve0;
        this.h = hg;
        this.e = c1358h6;
        this.f = c0661Zm;
        i(Fe0.l);
    }

    @Override // o.InterfaceC2813wX
    public final void b() {
        i(Fe0.l);
    }

    @Override // o.InterfaceC2813wX
    public final void c(T00 t00) {
        Rect rect;
        this.k = new Rect(C2887xC.D(t00.a), C2887xC.D(t00.b), C2887xC.D(t00.c), C2887xC.D(t00.d));
        if (!this.i.isEmpty() || (rect = this.k) == null) {
            return;
        }
        this.a.requestRectangleOnScreen(new Rect(rect));
    }

    /* JADX WARN: Type inference failed for: r14v14, types: [java.lang.Object, o.zK] */
    /* JADX WARN: Type inference failed for: r14v22, types: [java.lang.Object, o.zK] */
    /* JADX WARN: Type inference failed for: r14v8, types: [java.lang.Object, o.zK] */
    /* JADX WARN: Type inference failed for: r5v1, types: [java.lang.Object, o.zK] */
    @Override // o.InterfaceC2813wX
    public final void d(C2730ve0 c2730ve0, C2730ve0 c2730ve02) {
        boolean z = (Ue0.b(this.g.b, c2730ve02.b) && F3.c(this.g.c, c2730ve02.c)) ? false : true;
        this.g = c2730ve02;
        int size = this.i.size();
        for (int i = 0; i < size; i++) {
            Q00 q00 = (Q00) ((WeakReference) this.i.get(i)).get();
            if (q00 != null) {
                q00.d = c2730ve02;
            }
        }
        C0248Jo c0248Jo = this.l;
        synchronized (c0248Jo.c) {
            c0248Jo.j = null;
            c0248Jo.l = null;
            c0248Jo.k = null;
            c0248Jo.m = C1160f3.L;
            c0248Jo.n = null;
            c0248Jo.f178o = null;
        }
        if (F3.c(c2730ve0, c2730ve02)) {
            if (z) {
                C3126zm0 c3126zm0 = this.b;
                int iF = Ue0.f(c2730ve02.b);
                int iE = Ue0.e(c2730ve02.b);
                Ue0 ue0 = this.g.c;
                int iF2 = ue0 != null ? Ue0.f(ue0.a) : -1;
                Ue0 ue02 = this.g.c;
                ((InputMethodManager) c3126zm0.n.getValue()).updateSelection((View) c3126zm0.m, iF, iE, iF2, ue02 != null ? Ue0.e(ue02.a) : -1);
                return;
            }
            return;
        }
        if (c2730ve0 != null && (!F3.c(c2730ve0.a.m, c2730ve02.a.m) || (Ue0.b(c2730ve0.b, c2730ve02.b) && !F3.c(c2730ve0.c, c2730ve02.c)))) {
            C3126zm0 c3126zm02 = this.b;
            ((InputMethodManager) c3126zm02.n.getValue()).restartInput((View) c3126zm02.m);
            return;
        }
        int size2 = this.i.size();
        for (int i2 = 0; i2 < size2; i2++) {
            Q00 q002 = (Q00) ((WeakReference) this.i.get(i2)).get();
            if (q002 != null) {
                C2730ve0 c2730ve03 = this.g;
                C3126zm0 c3126zm03 = this.b;
                if (q002.h) {
                    q002.d = c2730ve03;
                    if (q002.f) {
                        ((InputMethodManager) c3126zm03.n.getValue()).updateExtractedText((View) c3126zm03.m, q002.e, AbstractC1904ms0.B(c2730ve03));
                    }
                    Ue0 ue03 = c2730ve03.c;
                    long j = c2730ve03.b;
                    int iF3 = ue03 != null ? Ue0.f(ue03.a) : -1;
                    Ue0 ue04 = c2730ve03.c;
                    ((InputMethodManager) c3126zm03.n.getValue()).updateSelection((View) c3126zm03.m, Ue0.f(j), Ue0.e(j), iF3, ue04 != null ? Ue0.e(ue04.a) : -1);
                }
            }
        }
    }

    @Override // o.InterfaceC2813wX
    public final void e() {
        i(Fe0.n);
    }

    @Override // o.InterfaceC2813wX
    public final void f() {
        i(Fe0.f121o);
    }

    @Override // o.InterfaceC2813wX
    public final void g() {
        this.d = false;
        this.e = C2291qw.O;
        this.f = C2291qw.P;
        this.k = null;
        i(Fe0.m);
    }

    @Override // o.InterfaceC2813wX
    public final void h(C2730ve0 c2730ve0, InterfaceC1955nT interfaceC1955nT, Ne0 ne0, C1513in c1513in, T00 t00, T00 t002) {
        C0248Jo c0248Jo = this.l;
        synchronized (c0248Jo.c) {
            try {
                c0248Jo.j = c2730ve0;
                c0248Jo.l = interfaceC1955nT;
                c0248Jo.k = ne0;
                c0248Jo.m = c1513in;
                c0248Jo.n = t00;
                c0248Jo.f178o = t002;
                if (c0248Jo.e || c0248Jo.d) {
                    c0248Jo.a();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void i(Fe0 fe0) {
        this.m.b(fe0);
        if (this.n == null) {
            RunnableC2108p1 runnableC2108p1 = new RunnableC2108p1(22, this);
            this.c.execute(runnableC2108p1);
            this.n = runnableC2108p1;
        }
    }
}
