package com.tencent.mm.plugin.appbrand.jsapi.d;

import com.google.firebase.analytics.FirebaseAnalytics$b;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.appbrand.jsapi.d.h.a;
import com.tencent.mm.plugin.appbrand.page.u;
import com.tencent.mm.plugin.appbrand.s.e;
import com.tencent.mm.plugin.appbrand.widget.input.h;
import com.tencent.mm.plugin.appbrand.widget.input.i;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import org.json.JSONException;
import org.json.JSONObject;

class h$6 extends i {
    final /* synthetic */ int eIl;
    final /* synthetic */ WeakReference hKr;
    final /* synthetic */ String hKs;
    final /* synthetic */ h hKz;

    h$6(h hVar, WeakReference weakReference, int i, String str) {
        this.hKz = hVar;
        this.hKr = weakReference;
        this.eIl = i;
        this.hKs = str;
    }

    public final void b(String str, int i, boolean z, boolean z2) {
        AppMethodBeat.i(123550);
        if (this.hKr.get() != null) {
            try {
                String jSONObject = new JSONObject().put(FirebaseAnalytics$b.VALUE, e.Ei(str)).put("inputId", this.jdU).put("cursor", i).toString();
                if (z) {
                    ((u) this.hKr.get()).h("onKeyboardConfirm", jSONObject, 0);
                }
                if (!z2) {
                    ((u) this.hKr.get()).h("onKeyboardComplete", jSONObject, 0);
                }
            } catch (JSONException e) {
                ab.e("MicroMsg.JsApiShowKeyboard", "dispatch input done, exp = %s", new Object[]{bo.l(e)});
            }
            if (!z2) {
                aDC();
            }
        }
        AppMethodBeat.o(123550);
    }

    public final void aDA() {
        AppMethodBeat.i(123551);
        if (this.hKr.get() != null) {
            int i = this.jdU;
            HashMap hashMap = new HashMap(1);
            hashMap.put("inputId", Integer.valueOf(i));
            ((u) this.hKr.get()).M(this.eIl, this.hKz.j("ok", hashMap));
            h.S(i, this.hKs);
            h.a(i, (u) this.hKr.get());
        }
        AppMethodBeat.o(123551);
    }

    public final void aDB() {
        AppMethodBeat.i(123552);
        if (this.hKr.get() != null) {
            ((u) this.hKr.get()).M(this.eIl, this.hKz.j("fail", null));
            aDC();
        }
        AppMethodBeat.o(123552);
    }

    public final void Ba(String str) {
        AppMethodBeat.i(123553);
        u uVar = (u) this.hKr.get();
        if (uVar == null) {
            AppMethodBeat.o(123553);
            return;
        }
        try {
            int i = this.jdU;
            new a().a(uVar.getRuntime().xT(), uVar.hashCode()).AL(new JSONObject().put(FirebaseAnalytics$b.VALUE, e.Ei(str)).put("data", h.ol(i)).put("cursor", 0).put("inputId", i).put("keyCode", 8).toString()).aCj();
            AppMethodBeat.o(123553);
        } catch (Exception e) {
            ab.e("MicroMsg.JsApiShowKeyboard", "onBackspacePressedWhileValueNoChange, e = %s", new Object[]{e});
            AppMethodBeat.o(123553);
        }
    }

    private void aDC() {
        AppMethodBeat.i(123554);
        u uVar = (u) this.hKr.get();
        if (uVar == null || uVar.aJz() == null) {
            AppMethodBeat.o(123554);
            return;
        }
        h.aQx().d(uVar.aJz());
        AppMethodBeat.o(123554);
    }
}
