package o;

import android.graphics.Matrix;
import android.os.Build;
import android.view.View;
import android.view.inputmethod.CursorAnchorInfo;
import android.view.inputmethod.InputMethodManager;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.Jo, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0248Jo {
    public final C2207q3 a;
    public final C3126zm0 b;
    public boolean d;
    public boolean e;
    public boolean f;
    public boolean g;
    public boolean h;
    public boolean i;
    public C2730ve0 j;
    public Ne0 k;
    public InterfaceC1955nT l;
    public T00 n;

    /* renamed from: o, reason: collision with root package name */
    public T00 f178o;
    public final Object c = new Object();
    public OC m = C1160f3.M;
    public final CursorAnchorInfo.Builder p = new CursorAnchorInfo.Builder();
    public final float[] q = C1570jO.a();
    public final Matrix r = new Matrix();

    public C0248Jo(C2207q3 c2207q3, C3126zm0 c3126zm0) {
        this.a = c2207q3;
        this.b = c3126zm0;
    }

    /* JADX WARN: Type inference failed for: r2v0, types: [java.lang.Object, o.zK] */
    public final void a() {
        InterfaceC3085zK interfaceC3085zK;
        C3126zm0 c3126zm0 = this.b;
        ?? r2 = c3126zm0.n;
        InputMethodManager inputMethodManager = (InputMethodManager) r2.getValue();
        View view = (View) c3126zm0.m;
        if (inputMethodManager.isActive(view)) {
            OC oc = this.m;
            float[] fArr = this.q;
            oc.g(new C1570jO(fArr));
            this.a.t(fArr);
            Matrix matrix = this.r;
            F3.P(matrix, fArr);
            C2730ve0 c2730ve0 = this.j;
            InterfaceC1955nT interfaceC1955nT = this.l;
            Ne0 ne0 = this.k;
            T00 t00 = this.n;
            T00 t002 = this.f178o;
            boolean z = this.f;
            boolean z2 = this.g;
            boolean z3 = this.h;
            boolean z4 = this.i;
            CursorAnchorInfo.Builder builder = this.p;
            builder.reset();
            builder.setMatrix(matrix);
            long j = c2730ve0.b;
            Ue0 ue0 = c2730ve0.c;
            int iF = Ue0.f(j);
            builder.setSelectionRange(iF, Ue0.e(c2730ve0.b));
            if (!z || iF < 0) {
                interfaceC3085zK = r2;
            } else {
                int iP = interfaceC1955nT.p(iF);
                T00 t00C = ne0.c(iP);
                interfaceC3085zK = r2;
                float fJ = AbstractC0940cn0.j(t00C.a, 0.0f, (int) (ne0.c >> 32));
                boolean zM = AbstractC0940cn0.m(t00, fJ, t00C.b);
                boolean zM2 = AbstractC0940cn0.m(t00, fJ, t00C.d);
                boolean z5 = ne0.a(iP) == 2;
                int i = (zM || zM2) ? 1 : 0;
                if (!zM || !zM2) {
                    i |= 2;
                }
                if (z5) {
                    i |= 4;
                }
                float f = t00C.b;
                float f2 = t00C.d;
                builder.setInsertionMarkerLocation(fJ, f, f2, f2, i);
            }
            if (z2) {
                int iF2 = ue0 != null ? Ue0.f(ue0.a) : -1;
                int iE = ue0 != null ? Ue0.e(ue0.a) : -1;
                if (iF2 >= 0 && iF2 < iE) {
                    builder.setComposingText(iF2, c2730ve0.a.m.subSequence(iF2, iE));
                    int iP2 = interfaceC1955nT.p(iF2);
                    int iP3 = interfaceC1955nT.p(iE);
                    float[] fArr2 = new float[(iP3 - iP2) * 4];
                    ne0.b.a(AbstractC2378rs0.u(iP2, iP3), fArr2);
                    int i2 = iF2;
                    while (i2 < iE) {
                        int iP4 = interfaceC1955nT.p(i2);
                        int i3 = (iP4 - iP2) * 4;
                        float f3 = fArr2[i3];
                        float f4 = fArr2[i3 + 1];
                        int i4 = iE;
                        float f5 = fArr2[i3 + 2];
                        float f6 = fArr2[i3 + 3];
                        int i5 = iP2;
                        int i6 = (t00.a < f5 ? 1 : 0) & (f3 < t00.c ? 1 : 0) & (t00.b < f6 ? 1 : 0) & (f4 < t00.d ? 1 : 0);
                        if (!AbstractC0940cn0.m(t00, f3, f4) || !AbstractC0940cn0.m(t00, f5, f6)) {
                            i6 |= 2;
                        }
                        if (ne0.a(iP4) == 2) {
                            i6 |= 4;
                        }
                        builder.addCharacterBounds(i2, f3, f4, f5, f6, i6);
                        i2++;
                        iE = i4;
                        iP2 = i5;
                    }
                }
            }
            int i7 = Build.VERSION.SDK_INT;
            if (i7 >= 33 && z3) {
                builder.setEditorBoundsInfo(B0.k().setEditorBounds(As0.X(t002)).setHandwritingBounds(As0.X(t002)).build());
            }
            if (i7 >= 34 && z4 && !t00.e()) {
                float f7 = t00.b;
                C2331rQ c2331rQ = ne0.b;
                int iE2 = c2331rQ.e(f7);
                int iE3 = c2331rQ.e(t00.d);
                if (iE2 <= iE3) {
                    while (true) {
                        builder.addVisibleLineBounds(ne0.e(iE2), c2331rQ.f(iE2), ne0.f(iE2), c2331rQ.b(iE2));
                        if (iE2 == iE3) {
                            break;
                        } else {
                            iE2++;
                        }
                    }
                }
            }
            ((InputMethodManager) interfaceC3085zK.getValue()).updateCursorAnchorInfo(view, builder.build());
            this.e = false;
        }
    }
}
