package T;

import B.B0;
import B.V;
import C0.B;
import F1.k0;
import G0.InterfaceC0279y;
import J0.j1;
import K.C0464l0;
import K.S0;
import K.Y;
import T0.C0596g;
import T0.C0604o;
import T0.J;
import T0.K;
import T0.L;
import T0.N;
import V.i0;
import Z0.C0860a;
import Z0.C0864e;
import Z0.C0865f;
import Z0.InterfaceC0866g;
import android.R;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
import android.view.inputmethod.DeleteGesture;
import android.view.inputmethod.DeleteRangeGesture;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.HandwritingGesture;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputContentInfo;
import android.view.inputmethod.InsertGesture;
import android.view.inputmethod.JoinOrSplitGesture;
import android.view.inputmethod.PreviewableHandwritingGesture;
import android.view.inputmethod.RemoveSpaceGesture;
import android.view.inputmethod.SelectGesture;
import android.view.inputmethod.SelectRangeGesture;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.concurrent.Executor;
import java.util.function.IntConsumer;
import kotlin.jvm.internal.A;
import o0.C2632c;
import p0.AbstractC2686D;
import x4.AbstractC3251q;

/* JADX INFO: loaded from: classes.dex */
public final class y implements InputConnection {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final B f6387a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final boolean f6388b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final C0464l0 f6389c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final i0 f6390d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final j1 f6391e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f6392f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public Z0.y f6393g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f6394h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public boolean f6395i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final ArrayList f6396j = new ArrayList();

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public boolean f6397k = true;

    public y(Z0.y yVar, B b5, boolean z6, C0464l0 c0464l0, i0 i0Var, j1 j1Var) {
        this.f6387a = b5;
        this.f6388b = z6;
        this.f6389c = c0464l0;
        this.f6390d = i0Var;
        this.f6391e = j1Var;
        this.f6393g = yVar;
    }

    public final void a(InterfaceC0866g interfaceC0866g) {
        this.f6392f++;
        try {
            this.f6396j.add(interfaceC0866g);
        } finally {
            b();
        }
    }

    public final boolean b() {
        int i6 = this.f6392f - 1;
        this.f6392f = i6;
        if (i6 == 0) {
            ArrayList arrayList = this.f6396j;
            if (!arrayList.isEmpty()) {
                ((x) this.f6387a.f506b).f6377c.invoke(AbstractC3251q.E0(arrayList));
                arrayList.clear();
            }
        }
        return this.f6392f > 0;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean beginBatchEdit() {
        boolean z6 = this.f6397k;
        if (!z6) {
            return z6;
        }
        this.f6392f++;
        return true;
    }

    public final void c(int i6) {
        sendKeyEvent(new KeyEvent(0, i6));
        sendKeyEvent(new KeyEvent(1, i6));
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean clearMetaKeyStates(int i6) {
        boolean z6 = this.f6397k;
        if (z6) {
            return false;
        }
        return z6;
    }

    @Override // android.view.inputmethod.InputConnection
    public final void closeConnection() {
        this.f6396j.clear();
        this.f6392f = 0;
        this.f6397k = false;
        x xVar = (x) this.f6387a.f506b;
        int size = xVar.f6384j.size();
        for (int i6 = 0; i6 < size; i6++) {
            ArrayList arrayList = xVar.f6384j;
            if (kotlin.jvm.internal.o.c(((WeakReference) arrayList.get(i6)).get(), this)) {
                arrayList.remove(i6);
                return;
            }
        }
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean commitCompletion(CompletionInfo completionInfo) {
        boolean z6 = this.f6397k;
        if (z6) {
            return false;
        }
        return z6;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean commitContent(InputContentInfo inputContentInfo, int i6, Bundle bundle) {
        boolean z6 = this.f6397k;
        if (z6) {
            return false;
        }
        return z6;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean commitCorrection(CorrectionInfo correctionInfo) {
        boolean z6 = this.f6397k;
        return z6 ? this.f6388b : z6;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean commitText(CharSequence charSequence, int i6) {
        boolean z6 = this.f6397k;
        if (z6) {
            a(new C0860a(String.valueOf(charSequence), i6));
        }
        return z6;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean deleteSurroundingText(int i6, int i7) {
        boolean z6 = this.f6397k;
        if (!z6) {
            return z6;
        }
        a(new C0864e(i6, i7));
        return true;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean deleteSurroundingTextInCodePoints(int i6, int i7) {
        boolean z6 = this.f6397k;
        if (!z6) {
            return z6;
        }
        a(new C0865f(i6, i7));
        return true;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean endBatchEdit() {
        return b();
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean finishComposingText() {
        boolean z6 = this.f6397k;
        if (!z6) {
            return z6;
        }
        a(new Z0.i());
        return true;
    }

    @Override // android.view.inputmethod.InputConnection
    public final int getCursorCapsMode(int i6) {
        Z0.y yVar = this.f6393g;
        return TextUtils.getCapsMode(yVar.f9136a.f6510b, N.f(yVar.f9137b), i6);
    }

    @Override // android.view.inputmethod.InputConnection
    public final ExtractedText getExtractedText(ExtractedTextRequest extractedTextRequest, int i6) {
        boolean z6 = (i6 & 1) != 0;
        this.f6395i = z6;
        if (z6) {
            this.f6394h = extractedTextRequest != null ? extractedTextRequest.token : 0;
        }
        return t.d(this.f6393g);
    }

    @Override // android.view.inputmethod.InputConnection
    public final Handler getHandler() {
        return null;
    }

    @Override // android.view.inputmethod.InputConnection
    public final CharSequence getSelectedText(int i6) {
        if (N.c(this.f6393g.f9137b)) {
            return null;
        }
        return W.b.j0(this.f6393g).f6510b;
    }

    @Override // android.view.inputmethod.InputConnection
    public final CharSequence getTextAfterCursor(int i6, int i7) {
        return W.b.m0(this.f6393g, i6).f6510b;
    }

    @Override // android.view.inputmethod.InputConnection
    public final CharSequence getTextBeforeCursor(int i6, int i7) {
        return W.b.n0(this.f6393g, i6).f6510b;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean performContextMenuAction(int i6) {
        boolean z6 = this.f6397k;
        if (z6) {
            z6 = false;
            switch (i6) {
                case R.id.selectAll:
                    a(new Z0.x(0, this.f6393g.f9136a.f6510b.length()));
                    break;
                case R.id.cut:
                    c(277);
                    return false;
                case R.id.copy:
                    c(278);
                    return false;
                case R.id.paste:
                    c(279);
                    return false;
                default:
                    return false;
            }
        }
        return z6;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean performEditorAction(int i6) {
        int i7;
        boolean z6 = this.f6397k;
        if (z6) {
            z6 = true;
            if (i6 != 0) {
                switch (i6) {
                    case 2:
                        i7 = 2;
                        break;
                    case 3:
                        i7 = 3;
                        break;
                    case 4:
                        i7 = 4;
                        break;
                    case 5:
                        i7 = 6;
                        break;
                    case 6:
                        i7 = 7;
                        break;
                    case 7:
                        i7 = 5;
                        break;
                    default:
                        Log.w("RecordingIC", "IME sends unsupported Editor Action: " + i6);
                        i7 = 1;
                        break;
                }
                ((x) this.f6387a.f506b).f6378d.invoke(new Z0.j(i7));
            } else {
                i7 = 1;
                ((x) this.f6387a.f506b).f6378d.invoke(new Z0.j(i7));
            }
        }
        return z6;
    }

    /* JADX WARN: Removed duplicated region for block: B:8:0x001f A[PHI: r8
      0x001f: PHI (r8v36 int) = (r8v0 int), (r8v0 int), (r8v12 int) binds: [B:7:0x001d, B:16:0x0037, B:139:0x0315] A[DONT_GENERATE, DONT_INLINE]] */
    @Override // android.view.inputmethod.InputConnection
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void performHandwritingGesture(HandwritingGesture handwritingGesture, Executor executor, IntConsumer intConsumer) {
        char c6;
        long jH;
        int i6;
        int iA;
        S0 s0D;
        int iA2;
        S0 s0D2;
        K k6;
        int iG = 2;
        if (Build.VERSION.SDK_INT >= 34) {
            V v3 = new V(this, 22);
            C0464l0 c0464l0 = this.f6389c;
            int i7 = 3;
            if (c0464l0 != null) {
                C0596g c0596g = c0464l0.f3898j;
                if (c0596g == null) {
                    iG = i7;
                    i7 = iG;
                } else {
                    S0 s0D3 = c0464l0.d();
                    if (c0596g.equals((s0D3 == null || (k6 = s0D3.f3742a.f6471a) == null) ? null : k6.f6461a)) {
                        boolean zS = k0.s(handwritingGesture);
                        i0 i0Var = this.f6390d;
                        if (zS) {
                            SelectGesture selectGestureK = k0.k(handwritingGesture);
                            long jI = t.i(c0464l0, AbstractC2686D.L(selectGestureK.getSelectionArea()), selectGestureK.getGranularity() != 1 ? 0 : 1);
                            if (N.c(jI)) {
                                iG = t.g(n.l(selectGestureK), v3);
                                i7 = iG;
                            } else {
                                v3.invoke(new Z0.x((int) (jI >> 32), (int) (jI & 4294967295L)));
                                if (i0Var != null) {
                                    i0Var.j(true);
                                }
                                iG = 1;
                                i7 = iG;
                            }
                        } else if (k0.x(handwritingGesture)) {
                            DeleteGesture deleteGestureJ = k0.j(handwritingGesture);
                            int i8 = deleteGestureJ.getGranularity() != 1 ? 0 : 1;
                            long jI2 = t.i(c0464l0, AbstractC2686D.L(deleteGestureJ.getDeletionArea()), i8);
                            if (N.c(jI2)) {
                                iG = t.g(n.l(deleteGestureJ), v3);
                                i7 = iG;
                            } else {
                                t.n(jI2, c0596g, i8 == 1, v3);
                                iG = 1;
                                i7 = iG;
                            }
                        } else if (k0.z(handwritingGesture)) {
                            SelectRangeGesture selectRangeGestureL = k0.l(handwritingGesture);
                            long jB = t.b(c0464l0, AbstractC2686D.L(selectRangeGestureL.getSelectionStartArea()), AbstractC2686D.L(selectRangeGestureL.getSelectionEndArea()), selectRangeGestureL.getGranularity() != 1 ? 0 : 1);
                            if (N.c(jB)) {
                                iG = t.g(n.l(selectRangeGestureL), v3);
                                i7 = iG;
                            } else {
                                v3.invoke(new Z0.x((int) (jB >> 32), (int) (jB & 4294967295L)));
                                if (i0Var != null) {
                                    i0Var.j(true);
                                }
                                iG = 1;
                                i7 = iG;
                            }
                        } else if (n.w(handwritingGesture)) {
                            DeleteRangeGesture deleteRangeGestureK = n.k(handwritingGesture);
                            int i9 = deleteRangeGestureK.getGranularity() != 1 ? 0 : 1;
                            long jB2 = t.b(c0464l0, AbstractC2686D.L(deleteRangeGestureK.getDeletionStartArea()), AbstractC2686D.L(deleteRangeGestureK.getDeletionEndArea()), i9);
                            if (N.c(jB2)) {
                                iG = t.g(n.l(deleteRangeGestureK), v3);
                                i7 = iG;
                            } else {
                                t.n(jB2, c0596g, i9 == 1, v3);
                                iG = 1;
                                i7 = iG;
                            }
                        } else {
                            boolean zD = n.D(handwritingGesture);
                            j1 j1Var = this.f6391e;
                            if (zD) {
                                JoinOrSplitGesture joinOrSplitGestureN = n.n(handwritingGesture);
                                if (j1Var == null || (iA2 = t.a(c0464l0, t.e(joinOrSplitGestureN.getJoinOrSplitPoint()), j1Var)) == -1 || ((s0D2 = c0464l0.d()) != null && t.c(s0D2.f3742a, iA2))) {
                                    iG = t.g(n.l(joinOrSplitGestureN), v3);
                                    i7 = iG;
                                } else {
                                    int iCharCount = iA2;
                                    while (iCharCount > 0) {
                                        int iCodePointBefore = Character.codePointBefore(c0596g, iCharCount);
                                        if (!t.k(iCodePointBefore)) {
                                            break;
                                        } else {
                                            iCharCount -= Character.charCount(iCodePointBefore);
                                        }
                                    }
                                    while (iA2 < c0596g.f6510b.length()) {
                                        int iCodePointAt = Character.codePointAt(c0596g, iA2);
                                        if (!t.k(iCodePointAt)) {
                                            break;
                                        } else {
                                            iA2 += Character.charCount(iCodePointAt);
                                        }
                                    }
                                    long jG = android.support.v4.media.session.b.g(iCharCount, iA2);
                                    if (N.c(jG)) {
                                        int i10 = (int) (jG >> 32);
                                        v3.invoke(new o(new InterfaceC0866g[]{new Z0.x(i10, i10), new C0860a(" ", 1)}));
                                    } else {
                                        t.n(jG, c0596g, false, v3);
                                    }
                                    iG = 1;
                                    i7 = iG;
                                }
                            } else {
                                if (n.B(handwritingGesture)) {
                                    InsertGesture insertGestureM = n.m(handwritingGesture);
                                    if (j1Var == null || (iA = t.a(c0464l0, t.e(insertGestureM.getInsertionPoint()), j1Var)) == -1 || ((s0D = c0464l0.d()) != null && t.c(s0D.f3742a, iA))) {
                                        iG = t.g(n.l(insertGestureM), v3);
                                    } else {
                                        v3.invoke(new o(new InterfaceC0866g[]{new Z0.x(iA, iA), new C0860a(insertGestureM.getTextToInsert(), 1)}));
                                        iG = 1;
                                    }
                                } else if (n.C(handwritingGesture)) {
                                    RemoveSpaceGesture removeSpaceGestureO = n.o(handwritingGesture);
                                    S0 s0D4 = c0464l0.d();
                                    L l = s0D4 != null ? s0D4.f3742a : null;
                                    long jE = t.e(removeSpaceGestureO.getStartPoint());
                                    long jE2 = t.e(removeSpaceGestureO.getEndPoint());
                                    InterfaceC0279y interfaceC0279yC = c0464l0.c();
                                    if (l == null || interfaceC0279yC == null) {
                                        c6 = ' ';
                                        jH = N.f6481b;
                                    } else {
                                        long jC0 = interfaceC0279yC.c0(jE);
                                        long jC02 = interfaceC0279yC.c0(jE2);
                                        C0604o c0604o = l.f6472b;
                                        int iH = t.h(c0604o, jC0, j1Var);
                                        int iH2 = t.h(c0604o, jC02, j1Var);
                                        if (iH != -1) {
                                            if (iH2 != -1) {
                                                iH = Math.min(iH, iH2);
                                            }
                                            iH2 = iH;
                                        } else if (iH2 == -1) {
                                            jH = N.f6481b;
                                            c6 = ' ';
                                        }
                                        float fB = (c0604o.b(iH2) + c0604o.f(iH2)) / 2;
                                        int i11 = (int) (jC0 >> 32);
                                        int i12 = (int) (jC02 >> 32);
                                        c6 = ' ';
                                        jH = c0604o.h(new C2632c(Math.min(Float.intBitsToFloat(i11), Float.intBitsToFloat(i12)), fB - 0.1f, Math.max(Float.intBitsToFloat(i11), Float.intBitsToFloat(i12)), fB + 0.1f), 0, J.f6459a);
                                    }
                                    if (N.c(jH)) {
                                        iG = t.g(n.l(removeSpaceGestureO), v3);
                                    } else {
                                        A a6 = new A();
                                        a6.f20113a = -1;
                                        A a7 = new A();
                                        a7.f20113a = -1;
                                        String strE = new S4.m("\\s+").e(c0596g.subSequence(N.f(jH), N.e(jH)).f6510b, new B0(15, a6, a7));
                                        int i13 = a6.f20113a;
                                        if (i13 == -1 || (i6 = a7.f20113a) == -1) {
                                            iG = t.g(n.l(removeSpaceGestureO), v3);
                                        } else {
                                            int i14 = (int) (jH >> c6);
                                            String strSubstring = strE.substring(i13, strE.length() - (N.d(jH) - a7.f20113a));
                                            kotlin.jvm.internal.o.g(strSubstring, "substring(...)");
                                            Z0.x xVar = new Z0.x(i14 + i13, i14 + i6);
                                            i7 = 1;
                                            v3.invoke(new o(new InterfaceC0866g[]{xVar, new C0860a(strSubstring, 1)}));
                                            iG = i7;
                                        }
                                    }
                                }
                                i7 = iG;
                            }
                        }
                    }
                }
            }
            if (intConsumer == null) {
                return;
            }
            if (executor != null) {
                executor.execute(new f(i7, 0, intConsumer));
            } else {
                intConsumer.accept(i7);
            }
        }
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean performPrivateCommand(String str, Bundle bundle) {
        boolean z6 = this.f6397k;
        if (z6) {
            return true;
        }
        return z6;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean previewHandwritingGesture(PreviewableHandwritingGesture previewableHandwritingGesture, CancellationSignal cancellationSignal) {
        C0464l0 c0464l0;
        C0596g c0596g;
        K k6;
        if (Build.VERSION.SDK_INT >= 34 && (c0464l0 = this.f6389c) != null && (c0596g = c0464l0.f3898j) != null) {
            S0 s0D = c0464l0.d();
            if (c0596g.equals((s0D == null || (k6 = s0D.f3742a.f6471a) == null) ? null : k6.f6461a)) {
                boolean zS = k0.s(previewableHandwritingGesture);
                i0 i0Var = this.f6390d;
                if (zS) {
                    SelectGesture selectGestureK = k0.k(previewableHandwritingGesture);
                    if (i0Var != null) {
                        long jI = t.i(c0464l0, AbstractC2686D.L(selectGestureK.getSelectionArea()), selectGestureK.getGranularity() != 1 ? 0 : 1);
                        C0464l0 c0464l02 = i0Var.f7084d;
                        if (c0464l02 != null) {
                            c0464l02.f3887A.setValue(new N(jI));
                        }
                        C0464l0 c0464l03 = i0Var.f7084d;
                        if (c0464l03 != null) {
                            c0464l03.f3888B.setValue(new N(N.f6481b));
                        }
                        if (!N.c(jI)) {
                            i0Var.v(false);
                            i0Var.s(Y.f3765a);
                        }
                    }
                } else if (k0.x(previewableHandwritingGesture)) {
                    DeleteGesture deleteGestureJ = k0.j(previewableHandwritingGesture);
                    if (i0Var != null) {
                        long jI2 = t.i(c0464l0, AbstractC2686D.L(deleteGestureJ.getDeletionArea()), deleteGestureJ.getGranularity() != 1 ? 0 : 1);
                        C0464l0 c0464l04 = i0Var.f7084d;
                        if (c0464l04 != null) {
                            c0464l04.f3888B.setValue(new N(jI2));
                        }
                        C0464l0 c0464l05 = i0Var.f7084d;
                        if (c0464l05 != null) {
                            c0464l05.f3887A.setValue(new N(N.f6481b));
                        }
                        if (!N.c(jI2)) {
                            i0Var.v(false);
                            i0Var.s(Y.f3765a);
                        }
                    }
                } else if (k0.z(previewableHandwritingGesture)) {
                    SelectRangeGesture selectRangeGestureL = k0.l(previewableHandwritingGesture);
                    if (i0Var != null) {
                        long jB = t.b(c0464l0, AbstractC2686D.L(selectRangeGestureL.getSelectionStartArea()), AbstractC2686D.L(selectRangeGestureL.getSelectionEndArea()), selectRangeGestureL.getGranularity() != 1 ? 0 : 1);
                        C0464l0 c0464l06 = i0Var.f7084d;
                        if (c0464l06 != null) {
                            c0464l06.f3887A.setValue(new N(jB));
                        }
                        C0464l0 c0464l07 = i0Var.f7084d;
                        if (c0464l07 != null) {
                            c0464l07.f3888B.setValue(new N(N.f6481b));
                        }
                        if (!N.c(jB)) {
                            i0Var.v(false);
                            i0Var.s(Y.f3765a);
                        }
                    }
                } else if (n.w(previewableHandwritingGesture)) {
                    DeleteRangeGesture deleteRangeGestureK = n.k(previewableHandwritingGesture);
                    if (i0Var != null) {
                        long jB2 = t.b(c0464l0, AbstractC2686D.L(deleteRangeGestureK.getDeletionStartArea()), AbstractC2686D.L(deleteRangeGestureK.getDeletionEndArea()), deleteRangeGestureK.getGranularity() != 1 ? 0 : 1);
                        C0464l0 c0464l08 = i0Var.f7084d;
                        if (c0464l08 != null) {
                            c0464l08.f3888B.setValue(new N(jB2));
                        }
                        C0464l0 c0464l09 = i0Var.f7084d;
                        if (c0464l09 != null) {
                            c0464l09.f3887A.setValue(new N(N.f6481b));
                        }
                        if (!N.c(jB2)) {
                            i0Var.v(false);
                            i0Var.s(Y.f3765a);
                        }
                    }
                }
                if (cancellationSignal != null) {
                    cancellationSignal.setOnCancelListener(new P0.g(i0Var, 1));
                }
                return true;
            }
        }
        return false;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean reportFullscreenMode(boolean z6) {
        return false;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean requestCursorUpdates(int i6) {
        boolean z6;
        boolean z7;
        boolean z8;
        boolean z9 = this.f6397k;
        if (!z9) {
            return z9;
        }
        boolean z10 = false;
        boolean z11 = (i6 & 1) != 0;
        boolean z12 = (i6 & 2) != 0;
        int i7 = Build.VERSION.SDK_INT;
        if (i7 >= 33) {
            z6 = (i6 & 16) != 0;
            z7 = (i6 & 8) != 0;
            boolean z13 = (i6 & 4) != 0;
            if (i7 >= 34 && (i6 & 32) != 0) {
                z10 = true;
            }
            if (z6 || z7 || z13 || z10) {
                z8 = z10;
                z10 = z13;
            } else if (i7 >= 34) {
                z8 = true;
                z10 = true;
                z6 = true;
                z7 = true;
            } else {
                z6 = true;
                z7 = true;
                z8 = z10;
                z10 = true;
            }
        } else {
            z6 = true;
            z7 = true;
            z8 = false;
        }
        u uVar = ((x) this.f6387a.f506b).f6386m;
        synchronized (uVar.f6359c) {
            try {
                uVar.f6362f = z6;
                uVar.f6363g = z7;
                uVar.f6364h = z10;
                uVar.f6365i = z8;
                if (z11) {
                    uVar.f6361e = true;
                    if (uVar.f6366j != null) {
                        uVar.a();
                    }
                }
                uVar.f6360d = z12;
            } catch (Throwable th) {
                throw th;
            }
        }
        return true;
    }

    /* JADX WARN: Type inference failed for: r0v4, types: [java.lang.Object, w4.h] */
    @Override // android.view.inputmethod.InputConnection
    public final boolean sendKeyEvent(KeyEvent keyEvent) {
        boolean z6 = this.f6397k;
        if (!z6) {
            return z6;
        }
        ((BaseInputConnection) ((x) this.f6387a.f506b).f6385k.getValue()).sendKeyEvent(keyEvent);
        return true;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean setComposingRegion(int i6, int i7) {
        boolean z6 = this.f6397k;
        if (z6) {
            a(new Z0.v(i6, i7));
        }
        return z6;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean setComposingText(CharSequence charSequence, int i6) {
        boolean z6 = this.f6397k;
        if (z6) {
            a(new Z0.w(String.valueOf(charSequence), i6));
        }
        return z6;
    }

    @Override // android.view.inputmethod.InputConnection
    public final boolean setSelection(int i6, int i7) {
        boolean z6 = this.f6397k;
        if (!z6) {
            return z6;
        }
        a(new Z0.x(i6, i7));
        return true;
    }
}
