package com.bytedance.sdk.openadsdk.duv.fm;

import android.text.TextUtils;
import androidx.media3.exoplayer.rtsp.SessionDescription;
import com.bytedance.sdk.openadsdk.core.model.lse;
import com.bytedance.sdk.openadsdk.core.mon;
import java.util.Arrays;
import java.util.HashSet;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public class wey extends com.bytedance.sdk.component.fm.gof<JSONObject, JSONObject> {
    public static final HashSet<String> fm = new HashSet<>(Arrays.asList("setStorageItem", "getStorageItem", "removeAllStorage", "removeStorageItem"));
    private lse ro;

    public wey(lse lseVar) {
        this.ro = lseVar;
    }

    public static void fm(com.bytedance.sdk.component.fm.fhx fhxVar, lse lseVar) {
        fhxVar.fm(fm, new wey(lseVar));
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    @Override // com.bytedance.sdk.component.fm.yz
    public JSONObject fm(String str, JSONObject jSONObject, com.bytedance.sdk.component.fm.jnr jnrVar) throws Exception {
        String strWf;
        lse lseVar = this.ro;
        if (lseVar == null || (strWf = lseVar.wf()) == null) {
            return null;
        }
        JSONObject jSONObject2 = new JSONObject();
        str.getClass();
        byte b10 = -1;
        switch (str.hashCode()) {
            case -1166163208:
                if (str.equals("getStorageItem")) {
                    b10 = 0;
                }
                break;
            case 541948222:
                if (str.equals("removeAllStorage")) {
                    b10 = 1;
                }
                break;
            case 1357067884:
                if (str.equals("setStorageItem")) {
                    b10 = 2;
                }
                break;
            case 1498706186:
                if (str.equals("removeStorageItem")) {
                    b10 = 3;
                }
                break;
        }
        switch (b10) {
            case 0:
                String strOptString = jSONObject.optString("key");
                if (!TextUtils.isEmpty(strOptString) && mon.fm().ro(strWf, strOptString)) {
                    jSONObject2.put("value", mon.fm().fm(strWf, strOptString));
                    jSONObject2.put("code", SessionDescription.SUPPORTED_SDP_VERSION);
                } else {
                    jSONObject2.put("code", "1");
                }
                return jSONObject2;
            case 1:
                mon.fm().fm(strWf);
                jSONObject2.put("code", SessionDescription.SUPPORTED_SDP_VERSION);
                return jSONObject2;
            case 2:
                String strOptString2 = jSONObject.optString("key");
                String strOptString3 = jSONObject.optString("value");
                if (strOptString2 != null) {
                    mon.fm().fm(strWf, strOptString2, strOptString3);
                    jSONObject2.put("code", SessionDescription.SUPPORTED_SDP_VERSION);
                } else {
                    jSONObject2.put("code", "1");
                }
                return jSONObject2;
            case 3:
                String strOptString4 = jSONObject.optString("key");
                if (!TextUtils.isEmpty(strOptString4)) {
                    jSONObject2.put("code", mon.fm().lb(strWf, strOptString4) ? SessionDescription.SUPPORTED_SDP_VERSION : "1");
                } else {
                    jSONObject2.put("code", "1");
                }
                return jSONObject2;
            default:
                return jSONObject2;
        }
    }
}
