导航菜单

页面标题

页面副标题

Housing v14.7.8 - HtmlJavaScriptInterface.java 源代码

正在查看: Housing v14.7.8 应用的 HtmlJavaScriptInterface.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.moengage.inapp.internal.html;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.webkit.JavascriptInterface;
import com.facebook.internal.c;
import com.facebook.react.bridge.a;
import com.moengage.core.Properties;
import com.moengage.core.analytics.MoEAnalyticsHelper;
import com.moengage.core.internal.CoreConstants;
import com.moengage.core.internal.logger.Logger;
import com.moengage.core.internal.model.SdkInstance;
import com.moengage.core.internal.storage.database.contract.DeprecatedContractsKt;
import com.moengage.core.internal.utils.CoreUtils;
import com.moengage.core.model.GeoLocation;
import com.moengage.core.model.UserGender;
import com.moengage.enum_models.reachability.Channel;
import com.moengage.inapp.internal.ActionHandler;
import com.moengage.inapp.internal.ConstantsKt;
import com.moengage.inapp.internal.StatsTrackerKt;
import com.moengage.inapp.internal.UtilsKt;
import com.moengage.inapp.internal.model.HtmlCampaignPayload;
import com.moengage.inapp.internal.model.actions.CallAction;
import com.moengage.inapp.internal.model.actions.CopyAction;
import com.moengage.inapp.internal.model.actions.DismissAction;
import com.moengage.inapp.internal.model.actions.NavigateToSettingsAction;
import com.moengage.inapp.internal.model.actions.ShareAction;
import com.moengage.inapp.internal.model.actions.SmsAction;
import com.moengage.inapp.model.CampaignData;
import com.moengage.inapp.model.actions.Action;
import com.moengage.inapp.model.actions.CustomAction;
import com.moengage.inapp.model.actions.NavigationAction;
import com.moengage.inapp.model.actions.RequestNotificationAction;
import com.moengage.inapp.model.enums.ActionType;
import com.moengage.inapp.model.enums.NavigationType;
import com.moengage.pushbase.MoEPushConstants;
import java.util.Locale;
import java.util.Map;
import kotlin.Metadata;
import kotlin.collections.t0;
import kotlin.jvm.internal.r;
import kotlin.text.q;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONArray;
import org.json.JSONObject;

@Metadata(d1 = {"\u0000b\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b5\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010%\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0000\u0018\u00002\u00020\u0001B)\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0006\u0010\u0005\u001a\u00020\u0004\u0012\b\u0010\u0007\u001a\u0004\u0018\u00010\u0006\u0012\u0006\u0010\t\u001a\u00020\b¢\u0006\u0004\b\n\u0010\u000bJG\u0010\u0015\u001a\u00020\u00142\b\u0010\r\u001a\u0004\u0018\u00010\f2\b\u0010\u000e\u001a\u0004\u0018\u00010\f2\b\u0010\u000f\u001a\u0004\u0018\u00010\f2\b\u0010\u0010\u001a\u0004\u0018\u00010\f2\u0006\u0010\u0012\u001a\u00020\u00112\u0006\u0010\u0013\u001a\u00020\u0011H\u0007¢\u0006\u0004\b\u0015\u0010\u0016J\u0019\u0010\u0017\u001a\u00020\u00142\b\u0010\u0005\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b\u0017\u0010\u0018J\u000f\u0010\u0019\u001a\u00020\u0014H\u0007¢\u0006\u0004\b\u0019\u0010\u001aJ\u0019\u0010\u001b\u001a\u00020\u00142\b\u0010\u0005\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b\u001b\u0010\u0018J\u0019\u0010\u001d\u001a\u00020\u00142\b\u0010\u001c\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b\u001d\u0010\u0018J\u0019\u0010\u001f\u001a\u00020\u00142\b\u0010\u001e\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b\u001f\u0010\u0018J\u0019\u0010!\u001a\u00020\u00142\b\u0010 \u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b!\u0010\u0018J\u0019\u0010#\u001a\u00020\u00142\b\u0010\"\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b#\u0010\u0018J\u0019\u0010%\u001a\u00020\u00142\b\u0010$\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b%\u0010\u0018J\u0019\u0010'\u001a\u00020\u00142\b\u0010&\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b'\u0010\u0018J\u0019\u0010)\u001a\u00020\u00142\b\u0010(\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b)\u0010\u0018J\u0019\u0010+\u001a\u00020\u00142\b\u0010*\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b+\u0010\u0018J\u0019\u0010-\u001a\u00020\u00142\b\u0010,\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b-\u0010\u0018J\u0019\u0010.\u001a\u00020\u00142\b\u0010\u0005\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b.\u0010\u0018J\u0019\u00100\u001a\u00020\u00142\b\u0010/\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b0\u0010\u0018J#\u00103\u001a\u00020\u00142\b\u00101\u001a\u0004\u0018\u00010\f2\b\u00102\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b3\u00104J\u0019\u00105\u001a\u00020\u00142\b\u0010\u0005\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b5\u0010\u0018J#\u00108\u001a\u00020\u00142\b\u00106\u001a\u0004\u0018\u00010\f2\b\u00107\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b8\u00104J#\u0010:\u001a\u00020\u00142\b\u00109\u001a\u0004\u0018\u00010\f2\b\u00107\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b:\u00104J#\u0010<\u001a\u00020\u00142\b\u0010;\u001a\u0004\u0018\u00010\f2\b\u00107\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b<\u00104J#\u0010>\u001a\u00020\u00142\b\u0010=\u001a\u0004\u0018\u00010\f2\b\u00107\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\b>\u00104J\u000f\u0010?\u001a\u00020\u0014H\u0007¢\u0006\u0004\b?\u0010\u001aJ#\u0010B\u001a\u00020\u00142\b\u0010@\u001a\u0004\u0018\u00010\f2\b\u0010A\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\bB\u00104J\u0019\u0010C\u001a\u00020\u00142\b\u0010(\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\bC\u0010\u0018J#\u0010D\u001a\u00020\u00142\b\u0010(\u001a\u0004\u0018\u00010\f2\b\u0010A\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\bD\u00104J\u0019\u0010F\u001a\u00020\u00142\b\u0010E\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\bF\u0010\u0018J\u0019\u0010G\u001a\u00020\u00142\b\u00107\u001a\u0004\u0018\u00010\fH\u0007¢\u0006\u0004\bG\u0010\u0018J\u000f\u0010H\u001a\u00020\u0014H\u0007¢\u0006\u0004\bH\u0010\u001aJ\u000f\u0010I\u001a\u00020\u0014H\u0007¢\u0006\u0004\bI\u0010\u001aJ\u0017\u0010L\u001a\u00020\u00142\u0006\u0010K\u001a\u00020JH\u0002¢\u0006\u0004\bL\u0010MJ'\u0010O\u001a\u0010\u0012\u0004\u0012\u00020\f\u0012\u0004\u0012\u00020\u0001\u0018\u00010N2\b\u00107\u001a\u0004\u0018\u00010\fH\u0002¢\u0006\u0004\bO\u0010PR\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0003\u0010QR\u0014\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0005\u0010RR\u0016\u0010\u0007\u001a\u0004\u0018\u00010\u00068\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0007\u0010SR\u0014\u0010\t\u001a\u00020\b8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\t\u0010TR\u0014\u0010U\u001a\u00020\f8\u0002X\u0082D¢\u0006\u0006\n\u0004\bU\u0010VR\u0014\u0010X\u001a\u00020W8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bX\u0010YR\u0014\u0010[\u001a\u00020Z8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b[\u0010\\R\u001c\u0010_\u001a\n ^*\u0004\u0018\u00010]0]8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b_\u0010`R\u0014\u0010a\u001a\u00020\f8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\ba\u0010V¨\u0006b"}, d2 = {"Lcom/moengage/inapp/internal/html/HtmlJavaScriptInterface;", "", "Landroid/app/Activity;", "activity", "Lcom/moengage/inapp/internal/model/HtmlCampaignPayload;", "payload", "Landroid/view/View;", "htmlInAppView", "Lcom/moengage/core/internal/model/SdkInstance;", "sdkInstance", "<init>", "(Landroid/app/Activity;Lcom/moengage/inapp/internal/model/HtmlCampaignPayload;Landroid/view/View;Lcom/moengage/core/internal/model/SdkInstance;)V", "", "eventName", "generalAttrJson", "locationAttrJson", "dateAttrJson", "", "isNonInteractive", "shouldAttachCampaignMeta", "Lzp/j0;", "trackEvent", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)V", "trackClick", "(Ljava/lang/String;)V", "trackDismiss", "()V", "trackRating", "alias", "setAlias", "uniqueId", "setUniqueId", "userName", "setUserName", "firstName", "setFirstName", "lastName", "setLastName", "emailId", "setEmailId", "mobileNumber", "setMobileNumber", "gender", "setGender", "birthDate", "setBirthDate", "setUserLocation", "userAttrJson", "setUserAttribute", "name", "isoDate", "setUserAttributeDate", "(Ljava/lang/String;Ljava/lang/String;)V", "setUserAttributeLocation", "screenName", "dataJson", "navigateToScreen", "deepLinkUrl", "openDeepLink", "url", "openRichLanding", "webUrl", "openWebURL", "dismissMessage", "textToCopy", "message", "copyText", "call", Channel.SMS, DeprecatedContractsKt.INAPP_V2_MSG_CONTENT, MoEPushConstants.ACTION_SHARE, "customAction", "requestNotificationPermission", "navigateToNotificationSettings", "Lcom/moengage/inapp/model/actions/Action;", a.GA_ACTION, "processAction", "(Lcom/moengage/inapp/model/actions/Action;)V", "", "toKeyValuePairs", "(Ljava/lang/String;)Ljava/util/Map;", "Landroid/app/Activity;", "Lcom/moengage/inapp/internal/model/HtmlCampaignPayload;", "Landroid/view/View;", "Lcom/moengage/core/internal/model/SdkInstance;", "tag", "Ljava/lang/String;", "Lcom/moengage/inapp/internal/html/WebPayloadParser;", "webCallbackParser", "Lcom/moengage/inapp/internal/html/WebPayloadParser;", "Lcom/moengage/inapp/internal/ActionHandler;", "actionHandler", "Lcom/moengage/inapp/internal/ActionHandler;", "Landroid/content/Context;", "kotlin.jvm.PlatformType", "context", "Landroid/content/Context;", "instanceId", "inapp_defaultRelease"}, k = 1, mv = {1, 9, 0}, xi = 48)
public final class HtmlJavaScriptInterface {

    @NotNull
    private final ActionHandler actionHandler;

    @NotNull
    private final Activity activity;
    private final Context context;

    @Nullable
    private final View htmlInAppView;

    @NotNull
    private final String instanceId;

    @NotNull
    private final HtmlCampaignPayload payload;

    @NotNull
    private final SdkInstance sdkInstance;

    @NotNull
    private final String tag;

    @NotNull
    private final WebPayloadParser webCallbackParser;

    public HtmlJavaScriptInterface(@NotNull Activity activity, @NotNull HtmlCampaignPayload htmlCampaignPayload, @Nullable View view, @NotNull SdkInstance sdkInstance) {
        r.k(activity, "activity");
        r.k(htmlCampaignPayload, "payload");
        r.k(sdkInstance, "sdkInstance");
        this.activity = activity;
        this.payload = htmlCampaignPayload;
        this.htmlInAppView = view;
        this.sdkInstance = sdkInstance;
        this.tag = "InApp_8.7.0_HtmlJavaScriptInterface";
        this.webCallbackParser = new WebPayloadParser();
        this.actionHandler = new ActionHandler(activity, sdkInstance);
        this.context = activity.getApplicationContext();
        this.instanceId = sdkInstance.getInstanceMeta().getInstanceId();
    }

    public static final void dismissMessage$lambda$0(HtmlJavaScriptInterface htmlJavaScriptInterface) {
        r.k(htmlJavaScriptInterface, "this$0");
        htmlJavaScriptInterface.processAction(new DismissAction(ActionType.DISMISS));
    }

    private final void processAction(Action action) {
        View view = this.htmlInAppView;
        if (view == null) {
            return;
        }
        this.actionHandler.onActionPerformed(view, action, this.payload);
    }

    private final Map<String, Object> toKeyValuePairs(String dataJson) {
        if (!UtilsKt.isValidJavaScriptString(dataJson) || dataJson == null || q.D(dataJson)) {
            return null;
        }
        return t0.t(CoreUtils.jsonToMap(new JSONObject(dataJson)));
    }

    @JavascriptInterface
    public final void call(@Nullable String mobileNumber) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$call$1(this, mobileNumber), 7, null);
            if (mobileNumber != null && !q.D(mobileNumber) && UtilsKt.isValidJavaScriptString(mobileNumber)) {
                processAction(new CallAction(ActionType.CALL, mobileNumber));
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$call$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void copyText(@Nullable String textToCopy, @Nullable String message) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$copyText$1(this, textToCopy, message), 7, null);
            if (textToCopy != null && !q.D(textToCopy) && UtilsKt.isValidJavaScriptString(textToCopy)) {
                ActionType actionType = ActionType.COPY_TEXT;
                if (!UtilsKt.isValidJavaScriptString(message)) {
                    message = null;
                }
                processAction(new CopyAction(actionType, message, textToCopy));
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$copyText$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void customAction(@Nullable String dataJson) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$customAction$1(this, dataJson), 7, null);
            if (UtilsKt.isValidJavaScriptString(dataJson)) {
                processAction(new CustomAction(ActionType.CUSTOM_ACTION, toKeyValuePairs(dataJson)));
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$customAction$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void dismissMessage() {
        try {
            this.activity.runOnUiThread(new c(this, 24));
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$dismissMessage$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void navigateToNotificationSettings() {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$navigateToNotificationSettings$1(this), 7, null);
            processAction(new NavigateToSettingsAction(ActionType.NAVIGATE_SETTINGS_NOTIFICATIONS));
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$navigateToNotificationSettings$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void navigateToScreen(@Nullable String screenName, @Nullable String dataJson) {
        if (screenName != null) {
            try {
                if (!q.D(screenName) && UtilsKt.isValidJavaScriptString(screenName)) {
                    processAction(new NavigationAction(ActionType.NAVIGATE, NavigationType.SCREEN, screenName, toKeyValuePairs(dataJson)));
                    return;
                }
            } catch (Throwable th) {
                Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$navigateToScreen$2(this), 4, null);
                return;
            }
        }
        Logger.log$default(this.sdkInstance.logger, 1, null, null, new HtmlJavaScriptInterface$navigateToScreen$1(this, screenName), 6, null);
    }

    @JavascriptInterface
    public final void openDeepLink(@Nullable String deepLinkUrl, @Nullable String dataJson) {
        if (deepLinkUrl != null) {
            try {
                if (!q.D(deepLinkUrl) && UtilsKt.isValidJavaScriptString(deepLinkUrl)) {
                    processAction(new NavigationAction(ActionType.NAVIGATE, NavigationType.DEEP_LINKING, deepLinkUrl, toKeyValuePairs(dataJson)));
                    return;
                }
            } catch (Throwable th) {
                Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$openDeepLink$2(this), 4, null);
                return;
            }
        }
        Logger.log$default(this.sdkInstance.logger, 1, null, null, new HtmlJavaScriptInterface$openDeepLink$1(this, deepLinkUrl), 6, null);
    }

    @JavascriptInterface
    public final void openRichLanding(@Nullable String url, @Nullable String dataJson) {
        if (url != null) {
            try {
                if (!q.D(url) && UtilsKt.isValidJavaScriptString(url)) {
                    processAction(new NavigationAction(ActionType.NAVIGATE, NavigationType.RICH_LANDING, url, toKeyValuePairs(dataJson)));
                    return;
                }
            } catch (Throwable th) {
                Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$openRichLanding$2(this), 4, null);
                return;
            }
        }
        Logger.log$default(this.sdkInstance.logger, 1, null, null, new HtmlJavaScriptInterface$openRichLanding$1(this, url), 6, null);
    }

    @JavascriptInterface
    public final void openWebURL(@Nullable String webUrl, @Nullable String dataJson) {
        if (webUrl != null) {
            try {
                if (!q.D(webUrl) && UtilsKt.isValidJavaScriptString(webUrl)) {
                    processAction(new NavigationAction(ActionType.NAVIGATE, NavigationType.DEEP_LINKING, webUrl, toKeyValuePairs(dataJson)));
                    return;
                }
            } catch (Throwable th) {
                Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$openWebURL$2(this), 4, null);
                return;
            }
        }
        Logger.log$default(this.sdkInstance.logger, 1, null, null, new HtmlJavaScriptInterface$openWebURL$1(this, webUrl), 6, null);
    }

    @JavascriptInterface
    public final void requestNotificationPermission() {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$requestNotificationPermission$1(this), 7, null);
            processAction(new RequestNotificationAction(ActionType.REQUEST_NOTIFICATION_PERMISSION, -1));
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$requestNotificationPermission$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void setAlias(@Nullable String alias) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$setAlias$1(this, alias), 7, null);
            if (alias != null && !q.D(alias) && UtilsKt.isValidJavaScriptString(alias)) {
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                moEAnalyticsHelper.setAlias(context, alias, this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$setAlias$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void setBirthDate(@Nullable String birthDate) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$setBirthDate$1(this, birthDate), 7, null);
            if (birthDate != null && !q.D(birthDate) && UtilsKt.isValidJavaScriptString(birthDate)) {
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                moEAnalyticsHelper.setUserAttributeISODate(context, CoreConstants.USER_ATTRIBUTE_USER_BDAY, birthDate, this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$setBirthDate$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void setEmailId(@Nullable String emailId) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$setEmailId$1(this, emailId), 7, null);
            if (emailId != null && !q.D(emailId) && UtilsKt.isValidJavaScriptString(emailId)) {
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                moEAnalyticsHelper.setEmailId(context, emailId, this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$setEmailId$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void setFirstName(@Nullable String firstName) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$setFirstName$1(this, firstName), 7, null);
            if (firstName != null && !q.D(firstName) && UtilsKt.isValidJavaScriptString(firstName)) {
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                moEAnalyticsHelper.setFirstName(context, firstName, this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$setFirstName$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void setGender(@Nullable String gender) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$setGender$1(this, gender), 7, null);
            if (gender != null && !q.D(gender) && UtilsKt.isValidJavaScriptString(gender)) {
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                String upperCase = gender.toUpperCase(Locale.ROOT);
                r.j(upperCase, "toUpperCase(...)");
                moEAnalyticsHelper.setGender(context, UserGender.valueOf(upperCase), this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$setGender$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void setLastName(@Nullable String lastName) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$setLastName$1(this, lastName), 7, null);
            if (lastName != null && !q.D(lastName) && UtilsKt.isValidJavaScriptString(lastName)) {
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                moEAnalyticsHelper.setLastName(context, lastName, this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$setLastName$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void setMobileNumber(@Nullable String mobileNumber) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$setMobileNumber$1(this, mobileNumber), 7, null);
            if (mobileNumber != null && !q.D(mobileNumber) && UtilsKt.isValidJavaScriptString(mobileNumber)) {
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                moEAnalyticsHelper.setMobileNumber(context, mobileNumber, this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$setMobileNumber$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void setUniqueId(@Nullable String uniqueId) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$setUniqueId$1(this, uniqueId), 7, null);
            if (uniqueId != null && !q.D(uniqueId) && UtilsKt.isValidJavaScriptString(uniqueId)) {
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                moEAnalyticsHelper.setUniqueId(context, uniqueId, this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$setUniqueId$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void setUserAttribute(@Nullable String userAttrJson) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$setUserAttribute$1(this, userAttrJson), 7, null);
            if (userAttrJson != null && !q.D(userAttrJson) && UtilsKt.isValidJavaScriptString(userAttrJson) && UtilsKt.isValidJavaScriptValue(userAttrJson)) {
                JSONObject jSONObject = new JSONObject(userAttrJson);
                String string = jSONObject.getString("name");
                Object obj = jSONObject.get("value");
                boolean z = true;
                if (!(obj instanceof Integer ? true : obj instanceof Boolean ? true : obj instanceof Double ? true : obj instanceof Float ? true : obj instanceof Long ? true : obj instanceof String ? true : obj instanceof JSONObject)) {
                    z = obj instanceof JSONArray;
                }
                if (!z) {
                    Logger.log$default(this.sdkInstance.logger, 1, null, null, new HtmlJavaScriptInterface$setUserAttribute$2(this, string, obj), 6, null);
                    return;
                }
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                r.h(string);
                moEAnalyticsHelper.setUserAttribute(context, string, obj, this.sdkInstance.getInstanceMeta().getInstanceId());
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$setUserAttribute$3(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void setUserAttributeDate(@Nullable String name, @Nullable String isoDate) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$setUserAttributeDate$1(this, name, isoDate), 7, null);
            if (name != null && !q.D(name) && UtilsKt.isValidJavaScriptString(name) && isoDate != null && !q.D(isoDate) && UtilsKt.isValidJavaScriptString(isoDate)) {
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                moEAnalyticsHelper.setUserAttributeISODate(context, name, isoDate, this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$setUserAttributeDate$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void setUserAttributeLocation(@Nullable String payload) {
        JSONObject jSONObject;
        String string;
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$setUserAttributeLocation$1(this, payload), 7, null);
            if (payload != null && !q.D(payload) && UtilsKt.isValidJavaScriptString(payload) && (string = (jSONObject = new JSONObject(payload)).getString("name")) != null && !q.D(string) && UtilsKt.isValidJavaScriptString(string)) {
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                r.h(string);
                moEAnalyticsHelper.setUserAttribute(context, string, new GeoLocation(jSONObject.getDouble("latitude"), jSONObject.getDouble("longitude")), this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$setUserAttributeLocation$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void setUserLocation(@Nullable String payload) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$setUserLocation$1(this, payload), 7, null);
            if (payload != null && !q.D(payload) && UtilsKt.isValidJavaScriptString(payload) && UtilsKt.isValidJavaScriptValue(payload)) {
                JSONObject jSONObject = new JSONObject(payload);
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                moEAnalyticsHelper.setLocation(context, jSONObject.getDouble("latitude"), jSONObject.getDouble("longitude"), this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$setUserLocation$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void setUserName(@Nullable String userName) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$setUserName$1(this, userName), 7, null);
            if (userName != null && !q.D(userName) && UtilsKt.isValidJavaScriptString(userName)) {
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                moEAnalyticsHelper.setUserName(context, userName, this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$setUserName$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void share(@Nullable String content) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$share$1(this, content), 7, null);
            if (content != null && !q.D(content) && UtilsKt.isValidJavaScriptString(content)) {
                processAction(new ShareAction(ActionType.SHARE, content));
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$share$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void sms(@Nullable String mobileNumber, @Nullable String message) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$sms$1(this, mobileNumber, message), 7, null);
            if (mobileNumber != null && !q.D(mobileNumber) && UtilsKt.isValidJavaScriptString(mobileNumber) && message != null && !q.D(message) && UtilsKt.isValidJavaScriptString(message)) {
                processAction(new SmsAction(ActionType.SMS, mobileNumber, message));
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$sms$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void trackClick(@Nullable String payload) {
        Object obj;
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$trackClick$1(this, payload), 7, null);
            if (UtilsKt.isValidJavaScriptValue(payload)) {
                if (payload != null && !q.D(payload)) {
                    obj = new JSONObject(payload).opt("widgetId");
                    Context context = this.context;
                    r.j(context, "context");
                    StatsTrackerKt.trackInAppClicked(context, this.sdkInstance, new CampaignData(this.payload.getCampaignId(), this.payload.getCampaignName(), this.payload.getCampaignContext()), obj);
                }
                obj = null;
                Context context2 = this.context;
                r.j(context2, "context");
                StatsTrackerKt.trackInAppClicked(context2, this.sdkInstance, new CampaignData(this.payload.getCampaignId(), this.payload.getCampaignName(), this.payload.getCampaignContext()), obj);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$trackClick$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void trackDismiss() {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$trackDismiss$1(this), 7, null);
            Context context = this.context;
            r.j(context, "context");
            StatsTrackerKt.trackInAppDismissed(context, this.sdkInstance, new CampaignData(this.payload.getCampaignId(), this.payload.getCampaignName(), this.payload.getCampaignContext()));
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$trackDismiss$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void trackEvent(@Nullable String eventName, @Nullable String generalAttrJson, @Nullable String locationAttrJson, @Nullable String dateAttrJson, boolean isNonInteractive, boolean shouldAttachCampaignMeta) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$trackEvent$1(this, eventName, generalAttrJson, locationAttrJson, dateAttrJson, isNonInteractive, shouldAttachCampaignMeta), 7, null);
            if (eventName != null && !q.D(eventName) && UtilsKt.isValidJavaScriptString(eventName)) {
                Properties properties$inapp_defaultRelease = this.webCallbackParser.toProperties$inapp_defaultRelease(generalAttrJson, locationAttrJson, dateAttrJson, isNonInteractive);
                if (shouldAttachCampaignMeta) {
                    UtilsKt.addAttributesToProperties(properties$inapp_defaultRelease, this.payload.getCampaignId(), this.payload.getCampaignName(), this.payload.getCampaignContext());
                }
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                moEAnalyticsHelper.trackEvent(context, eventName, properties$inapp_defaultRelease, this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$trackEvent$2(this), 4, null);
        }
    }

    @JavascriptInterface
    public final void trackRating(@Nullable String payload) {
        try {
            Logger.log$default(this.sdkInstance.logger, 0, null, null, new HtmlJavaScriptInterface$trackRating$1(this, payload), 7, null);
            if (payload != null && !q.D(payload) && UtilsKt.isValidJavaScriptString(payload) && UtilsKt.isValidJavaScriptValue(payload)) {
                Properties addAttribute = new Properties().addAttribute(ConstantsKt.IN_APP_RATING_ATTRIBUTE, Double.valueOf(new JSONObject(payload).getDouble(ConstantsKt.IN_APP_RATING_ATTRIBUTE)));
                UtilsKt.addAttributesToProperties(addAttribute, this.payload.getCampaignId(), this.payload.getCampaignName(), this.payload.getCampaignContext());
                MoEAnalyticsHelper moEAnalyticsHelper = MoEAnalyticsHelper.INSTANCE;
                Context context = this.context;
                r.j(context, "context");
                moEAnalyticsHelper.trackEvent(context, CoreConstants.EVENT_APP_RATED, addAttribute, this.instanceId);
            }
        } catch (Throwable th) {
            Logger.log$default(this.sdkInstance.logger, 1, th, null, new HtmlJavaScriptInterface$trackRating$2(this), 4, null);
        }
    }
}