package com.ss.android.ugc.aweme.ecommerce.pdp.jsb.service;

import X.C0755ITa;
import X.C0756ITb;
import X.CYI;
import X.CYO;
import X.CYz;
import X.CZ8;
import X.Kek;
import X.Kem;
import X.M12;
import android.content.Context;
import android.view.ViewParent;
import com.bytedance.covode.number.Covode;
import com.lynx.jsbridge.LynxModule;
import com.lynx.react.bridge.JavaOnlyMap;
import com.lynx.react.bridge.ReadableMap;
import com.lynx.react.bridge.WritableMap;
import com.ss.android.ugc.aweme.ecommerce.pdp.PdpViewModel;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import kotlin.h.b.n;

public final class PdpLepusBridgeModule extends LynxModule {
    public static final C0755ITa Companion = new C0755ITa((byte) 0);
    public final Context context;
    public final CYI paramModel;

    static {
        Covode.recordClassIndex(71414);
    }

    public final Context getContext() {
        return this.context;
    }

    private final CZ8 node() {
        WeakReference weakReference;
        CYI cyi = this.paramModel;
        if (cyi == null || (weakReference = cyi.LIZIZ) == null) {
            return null;
        }
        return (CZ8) weakReference.get();
    }

    private final Kek view() {
        WeakReference weakReference;
        CYI cyi = this.paramModel;
        if (cyi == null || (weakReference = cyi.LIZ) == null) {
            return null;
        }
        return (Kek) weakReference.get();
    }

    private final PdpViewModel viewModel() {
        WeakReference weakReference;
        CYI cyi = this.paramModel;
        if (cyi == null || (weakReference = cyi.LIZJ) == null) {
            return null;
        }
        return (PdpViewModel) weakReference.get();
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public PdpLepusBridgeModule(Context context2, Object obj) {
        super(context2);
        M12.LIZ(context2, obj);
        this.context = context2;
        this.paramModel = (CYI) (!(obj instanceof CYI) ? null : obj);
    }

    @C0756ITb
    public final WritableMap callSync(String str, ReadableMap readableMap) {
        ViewParent viewParent;
        Kem kitView;
        ViewParent parent;
        M12.LIZ(str, readableMap);
        JavaOnlyMap javaOnlyMap = new JavaOnlyMap();
        javaOnlyMap.put("code", 1);
        switch (str.hashCode()) {
            case 91242765:
                if (str.equals("ec_page_get_distance")) {
                    PdpViewModel viewModel = viewModel();
                    Kek view = view();
                    ViewParent viewParent2 = null;
                    if (view == null || (kitView = view.getKitView()) == null || (parent = kitView.LIZ().getParent()) == null) {
                        viewParent = null;
                    } else {
                        viewParent = parent.getParent();
                    }
                    if (viewParent instanceof CYz) {
                        viewParent2 = viewParent;
                    }
                    CYO LIZ = PdpCardBridgeServiceImpl.LIZ().LIZ(viewModel, (CYz) viewParent2);
                    JavaOnlyMap javaOnlyMap2 = new JavaOnlyMap();
                    javaOnlyMap2.put("is_bottom", Boolean.valueOf(LIZ.LIZ));
                    javaOnlyMap2.put("distance", Integer.valueOf(LIZ.LIZIZ));
                    javaOnlyMap.put("data", javaOnlyMap2);
                    break;
                }
                break;
            case 266463344:
                if (str.equals("ec_fetch_item_data")) {
                    String LIZ2 = PdpCardBridgeServiceImpl.LIZ().LIZ(viewModel(), readableMap.getInt("brick_name"));
                    JavaOnlyMap javaOnlyMap3 = new JavaOnlyMap();
                    javaOnlyMap3.put("raw_data", LIZ2);
                    javaOnlyMap.put("data", javaOnlyMap3);
                    break;
                }
                break;
            case 813019925:
                if (str.equals("ec_open_schema")) {
                    String string = readableMap.getString("schema");
                    HashMap hashMap = readableMap.getMap("params").toHashMap();
                    IPdpCardBridgeService LIZ3 = PdpCardBridgeServiceImpl.LIZ();
                    CZ8 node = node();
                    Context context2 = this.context;
                    n.LIZIZ(string, "");
                    LIZ3.LIZ(node, context2, string, hashMap);
                    break;
                }
                break;
            case 1278371700:
                if (str.equals("ec_refresh_page")) {
                    PdpCardBridgeServiceImpl.LIZ().LIZ(viewModel());
                    break;
                }
                break;
            case 1564484234:
                if (str.equals("ec_send_page_log")) {
                    String string2 = readableMap.getString("eventName");
                    HashMap hashMap2 = readableMap.getMap("params").toHashMap();
                    IPdpCardBridgeService LIZ4 = PdpCardBridgeServiceImpl.LIZ();
                    CZ8 node2 = node();
                    n.LIZIZ(string2, "");
                    LIZ4.LIZ(node2, string2, hashMap2);
                    break;
                }
                break;
            case 1571971608:
                if (str.equals("ec_fetch_common_data")) {
                    HashMap<String, Object> LIZ5 = PdpCardBridgeServiceImpl.LIZ().LIZ(node());
                    JavaOnlyMap javaOnlyMap4 = new JavaOnlyMap();
                    javaOnlyMap4.put("data", LIZ5);
                    javaOnlyMap.put("data", javaOnlyMap4);
                    break;
                }
                break;
        }
        return javaOnlyMap;
    }
}
