导航菜单

页面标题

页面副标题

Bhakti v5.4.0 - V.java 源代码

正在查看: Bhakti v5.4.0 应用的 V.java JAVA 源代码文件

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


package com.vlv.aravali.payments.legacy.ui.fragment;

import Ik.loeP.IMGwo;
import Kp.p0;
import Qn.AbstractC0210b;
import Vj.D0;
import Vj.T4;
import android.R;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.webkit.CookieManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.FrameLayout;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.i0;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.truecaller.android.sdk.common.models.TrueProfile;
import com.vlv.aravali.KukuFMApplication;
import com.vlv.aravali.coins.ui.fragments.F1;
import com.vlv.aravali.common.models.FreeTrialResponse;
import com.vlv.aravali.common.models.FreeTrialResponseFromWeb;
import com.vlv.aravali.common.models.Language;
import com.vlv.aravali.common.models.User;
import com.vlv.aravali.common.models.payments.PlanDetailItem;
import com.vlv.aravali.master.ui.MasterActivity;
import com.vlv.aravali.model.ByPassLoginData;
import com.vlv.aravali.model.FaqItem;
import com.vlv.aravali.model.WebViewData;
import com.vlv.aravali.payments.common.data.SubscriptionMeta;
import com.vlv.aravali.views.activities.WebViewActivity;
import com.vlv.aravali.views.activities.g0;
import com.vlv.aravali.views.activities.m0;
import com.vlv.aravali.views.fragments.C1830p;
import in.juspay.hyper.constants.LogSubCategory;
import io.X;
import java.io.Serializable;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CancellationException;
import jj.AbstractC2062a;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt;
import nl.C2198b;
import org.json.JSONObject;

@Metadata
public final class V extends AbstractC1485h implements m0 {
    static final Gp.j[] $$delegatedProperties;
    public static final int $stable;
    public static final String APP_LANGUAGE = "app_language";
    public static final String CONTENT_LANGUAGE = "content_language";
    public static final K Companion;
    public static final String PATH_SUBSCRIPTION = "subscription";
    private static final String TAG;
    private final Ri.g binding$delegate;
    private final Map<String, String> customHeaders;
    private ol.a disposable;
    private Integer episodeId;
    private String finalUrlBeforeDeeplink;
    private String firstLevelSource;
    public Qn.t freshChat;
    private final SimpleDateFormat hourFormat;
    private boolean isEventFired;
    private String languageSelectionMedium;
    private X mobileVerificationDialog;
    private Qn.x permissionHandler;
    private p0 playPauseJob;
    private boolean showContentLangOnSubsPage;
    private Integer showId;
    private final SimpleDateFormat simpleDateFormat;
    private String source;
    private long startTime;
    private String subscriptionBaseUrl;
    private SubscriptionMeta subscriptionMeta;
    private String utmCampaign;
    private String utmMedium;
    private String utmSource;

    static {
        Gp.j a = new kotlin.jvm.internal.A(V.class, "binding", "getBinding()Lcom/vlv/aravali/databinding/FragmentSubscriptionBinding;", 0);
        kotlin.jvm.internal.J.a.getClass();
        $$delegatedProperties = new Gp.j[]{a};
        Companion = new K();
        $stable = 8;
        String simpleName = V.class.getSimpleName();
        Intrinsics.checkNotNullExpressionValue(simpleName, "getSimpleName(...)");
        TAG = simpleName;
    }

    public V() {
        super(2131558698);
        this.binding$delegate = new Ri.g(T4.class, this);
        this.source = "";
        this.showId = -1;
        this.episodeId = -1;
        this.utmSource = "";
        this.utmMedium = "";
        this.utmCampaign = "";
        this.disposable = new ol.a();
        this.subscriptionMeta = new SubscriptionMeta(null, null, null, null, null, null, null, null, null, null, null, null, null, false, null, null, null, null, null, 524287, null);
        this.firstLevelSource = "";
        this.languageSelectionMedium = APP_LANGUAGE;
        this.finalUrlBeforeDeeplink = "";
        this.customHeaders = new HashMap();
        this.simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        this.hourFormat = new SimpleDateFormat("HH");
        this.showContentLangOnSubsPage = Pk.j.a("content_lang_on_subs_page");
        X.Companion.getClass();
        X x = new X();
        Bundle bundle = new Bundle();
        bundle.putBoolean("start_bundle", false);
        x.setArguments(bundle);
        this.mobileVerificationDialog = x;
    }

    public final java.lang.Object getCouponCount(pp.c<? super java.lang.Integer> r20) {
        throw new UnsupportedOperationException("Method not decompiled: com.vlv.aravali.payments.legacy.ui.fragment.V.getCouponCount(pp.c):java.lang.Object");
    }

    private final void getUserContactAndContinue() {
        if (this.mobileVerificationDialog.isVisible()) {
            return;
        }
        this.mobileVerificationDialog.setCancelable(false);
        if (!isVisible() || this.mobileVerificationDialog.isAdded()) {
            return;
        }
        this.mobileVerificationDialog.show(requireActivity().getSupportFragmentManager(), "");
    }

    private final void initObservers() {
        ol.a aVar = this.disposable;
        Qo.b subscribe = nl.a.a(C2198b.class).subscribe(new com.vlv.aravali.downloadsV2.ui.f(new co.l(this, 18), 22), new com.vlv.aravali.downloadsV2.ui.f(new F1(20), 23));
        Intrinsics.checkNotNullExpressionValue(subscribe, "subscribe(...)");
        aVar.a(subscribe);
    }

    public static final Unit initObservers$lambda$1(V v, C2198b c2198b) {
        T4 binding;
        ConstraintLayout constraintLayout;
        User t;
        int i = L.a[c2198b.a.ordinal()];
        Object[] objArr = c2198b.b;
        if (i != 1) {
            if (i != 2) {
                if (i == 3 && ((t = io.sentry.config.d.t(KukuFMApplication.x)) == null || !t.isPremium())) {
                    v.postLoginEventProcess(c2198b, null, new Am.U(v, 14));
                }
            } else if (objArr.length != 0 && (objArr[0] instanceof TrueProfile) && (binding = v.getBinding()) != null && (constraintLayout = binding.M) != null) {
                constraintLayout.setVisibility(0);
            }
        } else if (objArr.length != 0 && (kotlin.collections.v.A(objArr) instanceof String)) {
            Object A = kotlin.collections.v.A(objArr);
            Intrinsics.f(A, "null cannot be cast to non-null type kotlin.String");
            v.reloadWebViewWithCouponCode((String) A);
        }
        return Unit.a;
    }

    public static final Unit initObservers$lambda$1$lambda$0(V v, String str, Object obj) {
        Intrinsics.checkNotNullParameter(str, "it");
        Intrinsics.checkNotNullParameter(obj, "any");
        if (Intrinsics.c(str, "login_navigate_to_payment_flow")) {
            v.navigateToPaymentFlow((PlanDetailItem) obj);
            v.setAndLoadWebView();
        } else if (Intrinsics.c(str, "login_for_web_view_feedback") && (obj instanceof String)) {
            SubscriptionMeta subscriptionMeta = v.subscriptionMeta;
            if (subscriptionMeta != null) {
                subscriptionMeta.setWebViewFeedback((String) obj);
            }
            v.setAndLoadWebView();
        }
        return Unit.a;
    }

    public static final Unit initObservers$lambda$3(Throwable th) {
        th.printStackTrace();
        return Unit.a;
    }

    public static final Unit navigateToPaymentFlow$lambda$20(V v, PlanDetailItem planDetailItem) {
        v.showConfirmationDialog(planDetailItem);
        return Unit.a;
    }

    private final void openPaymentScreen(PlanDetailItem planDetailItem) {
        Al.l.f(this, planDetailItem, this.subscriptionMeta);
    }

    public final void openUrlInWebView(String str) {
        FragmentActivity activity = getActivity();
        if (activity != null) {
            g0 g0Var = WebViewActivity.Companion;
            WebViewData webViewData = new WebViewData(str, "", "", "referral", null, 16, null);
            g0Var.getClass();
            startActivity(g0.a(activity, webViewData, this));
            FragmentActivity activity2 = getActivity();
            if (activity2 != null) {
                activity2.overridePendingTransition(2130772068, R.anim.fade_out);
            }
        }
    }

    private final void pauseFreeTrialVideo() {
        FreeTrialResponse freeTrialResponse;
        ArrayList arrayList = Qn.e.a;
        if (Qn.e.K() && (freeTrialResponse = Qn.e.k) != null && freeTrialResponse.getEnableFreeTrial()) {
            p0 p0Var = this.playPauseJob;
            if (p0Var != null) {
                p0Var.cancel((CancellationException) null);
            }
            this.playPauseJob = Kp.p.w(i0.i(this), (CoroutineContext) null, (Kp.J) null, new Q(this, null), 3);
        }
    }

    private final void reloadWebViewWithCouponCode(String str) {
        Object obj;
        String str2 = this.subscriptionBaseUrl;
        if (str2 == null) {
            str2 = "https://kukufm.com/subscription/";
        }
        SubscriptionMeta subscriptionMeta = this.subscriptionMeta;
        if (subscriptionMeta == null || (obj = subscriptionMeta.getForWebSource()) == null) {
            obj = "";
        }
        String f = j.e.f(this.finalUrlBeforeDeeplink, "&deeplinkUrl=", URLEncoder.encode(str2 + "?action=pre_apply_coupon&couponCode=" + str + "&planId=1&sub_source=" + obj, "UTF-8"));
        FragmentActivity activity = getActivity();
        if (activity != null) {
            activity.runOnUiThread(new U8.b(22, this, f, false));
        }
    }

    public static final void reloadWebViewWithCouponCode$lambda$6(V v, String str) {
        WebView webView;
        T4 binding = v.getBinding();
        if (binding != null && (webView = binding.Q) != null) {
            webView.loadUrl(str, v.customHeaders);
        }
        xq.d.a.d(Ai.o.h("weburl : ", str), new Object[0]);
    }

    public static final Unit setAndLoadWebView$lambda$11$lambda$10(V v, String str, CookieManager cookieManager, kotlin.jvm.internal.I i) {
        WebView webView;
        v.customHeaders.put("Authorization", "Bearer " + str);
        cookieManager.setCookie("https://kukufm.com/", "firebaseToken=" + str + "; path=/; domain=.kukufm.com");
        if (Pk.j.a("enable_coupon_scarcity")) {
            androidx.lifecycle.G viewLifecycleOwner = v.getViewLifecycleOwner();
            Intrinsics.checkNotNullExpressionValue(viewLifecycleOwner, "getViewLifecycleOwner(...)");
            Kp.p.w(i0.i(viewLifecycleOwner), (CoroutineContext) null, (Kp.J) null, new S(i, v, null), 3);
        } else {
            T4 binding = v.getBinding();
            if (binding != null && (webView = binding.Q) != null) {
                webView.loadUrl((String) i.a, v.customHeaders);
            }
        }
        return Unit.a;
    }

    public static final Unit setAndLoadWebView$lambda$16$lambda$15(V v, CookieManager cookieManager, kotlin.jvm.internal.I i, String str) {
        if (str == null || str.length() == 0) {
            String str2 = KukuFMApplication.x.B().e().e;
            if (str2 != null) {
                v.ui(new Jj.b((Object) v, str2, cookieManager, (Object) str, (Object) i, 7));
            }
        } else {
            v.ui(new J(v, str, cookieManager, i, 1));
        }
        return Unit.a;
    }

    public static final Unit setAndLoadWebView$lambda$16$lambda$15$lambda$12(V v, String str, CookieManager cookieManager, kotlin.jvm.internal.I i) {
        WebView webView;
        v.customHeaders.put("Authorization", "jwt " + str);
        cookieManager.setCookie("https://kukufm.com/", "jwtToken=" + str + "; path=/; domain=.kukufm.com");
        if (Pk.j.a("enable_coupon_scarcity")) {
            androidx.lifecycle.G viewLifecycleOwner = v.getViewLifecycleOwner();
            Intrinsics.checkNotNullExpressionValue(viewLifecycleOwner, "getViewLifecycleOwner(...)");
            Kp.p.w(i0.i(viewLifecycleOwner), (CoroutineContext) null, (Kp.J) null, new T(i, v, null), 3);
        } else {
            T4 binding = v.getBinding();
            if (binding != null && (webView = binding.Q) != null) {
                webView.loadUrl((String) i.a, v.customHeaders);
            }
        }
        return Unit.a;
    }

    public static final Unit setAndLoadWebView$lambda$16$lambda$15$lambda$14$lambda$13(V v, String str, CookieManager cookieManager, String str2, kotlin.jvm.internal.I i) {
        WebView webView;
        v.customHeaders.put("Authorization", "Bearer " + str);
        cookieManager.setCookie("https://kukufm.com/", "firebaseToken=" + str2 + "; path=/; domain=.kukufm.com");
        if (Pk.j.a("enable_coupon_scarcity")) {
            androidx.lifecycle.G viewLifecycleOwner = v.getViewLifecycleOwner();
            Intrinsics.checkNotNullExpressionValue(viewLifecycleOwner, "getViewLifecycleOwner(...)");
            Kp.p.w(i0.i(viewLifecycleOwner), (CoroutineContext) null, (Kp.J) null, new U(i, v, null), 3);
        } else {
            T4 binding = v.getBinding();
            if (binding != null && (webView = binding.Q) != null) {
                webView.loadUrl((String) i.a, v.customHeaders);
            }
        }
        return Unit.a;
    }

    private final void showConfirmationDialog(PlanDetailItem planDetailItem) {
        FragmentActivity activity = getActivity();
        if (activity != null) {
            jb.f fVar = new jb.f(activity, com.vlv.aravali.audiobooks.ui.fragments.p.x(KukuFMApplication.x) ? 2132082998 : 2132082997);
            x2.m b = x2.e.b(LayoutInflater.from(activity), 2131558508, (ViewGroup) null, false);
            Intrinsics.checkNotNullExpressionValue(b, "inflate(...)");
            D0 d0 = (D0) b;
            d0.Q.setText(getResources().getString(2132017418));
            d0.L.setOnClickListener(new Ik.n(this, planDetailItem, fVar, 9));
            d0.M.setOnClickListener(new Pm.c(fVar, 9));
            fVar.setContentView(((x2.m) d0).d);
            fVar.show();
            FrameLayout frameLayout = (FrameLayout) fVar.findViewById(2131362766);
            if (frameLayout != null) {
                BottomSheetBehavior D = BottomSheetBehavior.D(frameLayout);
                Intrinsics.checkNotNullExpressionValue(D, "from(...)");
                D.N(3);
            }
        }
    }

    public static final void showConfirmationDialog$lambda$27$lambda$24(V v, PlanDetailItem planDetailItem, jb.f fVar, View view) {
        v.openPaymentScreen(planDetailItem);
        fVar.dismiss();
    }

    public final void copyToClipboard(String str) {
        Intrinsics.checkNotNullParameter(str, "text");
        FragmentActivity activity = getActivity();
        Object systemService = activity != null ? activity.getSystemService("clipboard") : null;
        Intrinsics.f(systemService, "null cannot be cast to non-null type android.content.ClipboardManager");
        ((ClipboardManager) systemService).setPrimaryClip(ClipData.newPlainText("Referral Link", str));
        String string = getString(2132017876);
        Intrinsics.checkNotNullExpressionValue(string, "getString(...)");
        showToast(string, 0);
    }

    public final T4 getBinding() {
        return this.binding$delegate.a(this, $$delegatedProperties[0]);
    }

    public final Qn.t getFreshChat() {
        Qn.t tVar = this.freshChat;
        if (tVar != null) {
            return tVar;
        }
        Intrinsics.m("freshChat");
        throw null;
    }

    public final void navigateToPaymentFlow(PlanDetailItem planDetailItem) {
        PlanDetailItem planDetailItem2;
        FreeTrialResponse freeTrialResponse;
        FreeTrialResponse.FreeTrialData freeTrialData;
        FreeTrialResponse.FreeTrialData freeTrialData2;
        FreeTrialResponse freeTrialResponse2;
        FreeTrialResponse.FreeTrialData freeTrialData3;
        FreeTrialResponse.FreeTrialData freeTrialData4;
        FreeTrialResponse.FreeTrialData freeTrialData5;
        FreeTrialResponse.FreeTrialData freeTrialData6;
        ConstraintLayout constraintLayout;
        FreeTrialResponse freeTrialResponse3;
        Intrinsics.checkNotNullParameter(planDetailItem, "plan");
        ArrayList arrayList = Qn.e.a;
        FreeTrialResponse freeTrialResponse4 = Qn.e.k;
        if (freeTrialResponse4 != null && freeTrialResponse4.getEnableFreeTrial() && !Qn.e.K()) {
            I5.g.U(this);
            return;
        }
        if (!Qn.e.K() || (freeTrialResponse3 = Qn.e.k) == null || !freeTrialResponse3.getEnableFreeTrial() || planDetailItem.getFreeTrialResponseFromWeb() == null) {
            if (Qn.e.K() && (freeTrialResponse2 = Qn.e.k) != null && freeTrialResponse2.getEnableFreeTrial()) {
                FreeTrialResponse freeTrialResponse5 = Qn.e.k;
                if (((freeTrialResponse5 == null || (freeTrialData6 = freeTrialResponse5.getFreeTrialData()) == null) ? null : freeTrialData6.getFreeTrialEligiblePlans()) != null) {
                    FreeTrialResponse freeTrialResponse6 = Qn.e.k;
                    List<FreeTrialResponse.FreeTrialData.FreeTrialPlan> freeTrialEligiblePlans = (freeTrialResponse6 == null || (freeTrialData5 = freeTrialResponse6.getFreeTrialData()) == null) ? null : freeTrialData5.getFreeTrialEligiblePlans();
                    Intrinsics.e(freeTrialEligiblePlans);
                    if (!freeTrialEligiblePlans.isEmpty()) {
                        FreeTrialResponse freeTrialResponse7 = Qn.e.k;
                        List<FreeTrialResponse.FreeTrialData.FreeTrialPlan> freeTrialEligiblePlans2 = (freeTrialResponse7 == null || (freeTrialData4 = freeTrialResponse7.getFreeTrialData()) == null) ? null : freeTrialData4.getFreeTrialEligiblePlans();
                        Intrinsics.e(freeTrialEligiblePlans2);
                        PlanDetailItem planDetailItem3 = null;
                        for (FreeTrialResponse.FreeTrialData.FreeTrialPlan freeTrialPlan : freeTrialEligiblePlans2) {
                            if (kotlin.text.y.h(planDetailItem.getId(), String.valueOf(freeTrialPlan.getPlanId()), false)) {
                                FreeTrialResponse freeTrialResponse8 = Qn.e.k;
                                planDetailItem3 = com.vlv.aravali.common.models.m.a(freeTrialPlan, freeTrialResponse8 != null ? freeTrialResponse8.isRazorpayEnable() : false);
                            }
                        }
                        if (planDetailItem3 == null) {
                            FreeTrialResponse freeTrialResponse9 = Qn.e.k;
                            List<FreeTrialResponse.FreeTrialData.FreeTrialPlan> freeTrialEligiblePlans3 = (freeTrialResponse9 == null || (freeTrialData3 = freeTrialResponse9.getFreeTrialData()) == null) ? null : freeTrialData3.getFreeTrialEligiblePlans();
                            Intrinsics.e(freeTrialEligiblePlans3);
                            FreeTrialResponse.FreeTrialData.FreeTrialPlan freeTrialPlan2 = freeTrialEligiblePlans3.get(0);
                            FreeTrialResponse freeTrialResponse10 = Qn.e.k;
                            planDetailItem2 = com.vlv.aravali.common.models.m.a(freeTrialPlan2, freeTrialResponse10 != null ? freeTrialResponse10.isRazorpayEnable() : false);
                        } else {
                            planDetailItem2 = planDetailItem3;
                        }
                    }
                }
            }
            if (Qn.e.K() && (freeTrialResponse = Qn.e.k) != null && freeTrialResponse.getEnableFreeTrial()) {
                FreeTrialResponse freeTrialResponse11 = Qn.e.k;
                if (((freeTrialResponse11 == null || (freeTrialData2 = freeTrialResponse11.getFreeTrialData()) == null) ? null : freeTrialData2.getFreeTrialPlan()) != null) {
                    FreeTrialResponse freeTrialResponse12 = Qn.e.k;
                    FreeTrialResponse.FreeTrialData.FreeTrialPlan freeTrialPlan3 = (freeTrialResponse12 == null || (freeTrialData = freeTrialResponse12.getFreeTrialData()) == null) ? null : freeTrialData.getFreeTrialPlan();
                    Intrinsics.e(freeTrialPlan3);
                    FreeTrialResponse freeTrialResponse13 = Qn.e.k;
                    planDetailItem2 = com.vlv.aravali.common.models.m.a(freeTrialPlan3, freeTrialResponse13 != null ? freeTrialResponse13.isRazorpayEnable() : false);
                }
            }
            planDetailItem2 = planDetailItem;
        } else {
            FreeTrialResponseFromWeb freeTrialResponseFromWeb = planDetailItem.getFreeTrialResponseFromWeb();
            planDetailItem2 = freeTrialResponseFromWeb != null ? D8.i.U0(freeTrialResponseFromWeb) : new PlanDetailItem(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, false, null, null, false, null, null, null, Integer.MAX_VALUE, null);
        }
        xq.b bVar = xq.d.a;
        bVar.m("Plan Data");
        if (planDetailItem2 == null) {
            Intrinsics.m("newPlan");
            throw null;
        }
        bVar.a(planDetailItem2.toString(), new Object[0]);
        T4 binding = getBinding();
        if (binding != null && (constraintLayout = binding.M) != null) {
            constraintLayout.setVisibility(8);
        }
        Integer couponDiscountAmount = planDetailItem2.getCouponDiscountAmount();
        if (couponDiscountAmount != null) {
            int intValue = couponDiscountAmount.intValue();
            Float discountedPrice = planDetailItem2.getDiscountedPrice() != null ? planDetailItem2.getDiscountedPrice() : planDetailItem2.getPrice();
            Intrinsics.e(discountedPrice);
            planDetailItem2.setFinalPrice(Float.valueOf(discountedPrice.floatValue() - intValue));
        } else {
            planDetailItem2.setFinalPrice(planDetailItem2.getDiscountedPrice() != null ? planDetailItem2.getDiscountedPrice() : planDetailItem2.getPrice());
        }
        Qn.e.b = planDetailItem2;
        androidx.lifecycle.G viewLifecycleOwner = getViewLifecycleOwner();
        Intrinsics.checkNotNullExpressionValue(viewLifecycleOwner, "getViewLifecycleOwner(...)");
        androidx.lifecycle.B i = i0.i(viewLifecycleOwner);
        Sp.f fVar = Kp.V.a;
        Kp.p.w(i, Qp.m.a, (Kp.J) null, new O(this, null), 2);
        kp.b bVar2 = nl.a.a;
        nl.a.b(new C2198b(ij.i.STOP_AND_CLEAR_PLAYER_THINGS, new Object[0]));
        if (Intrinsics.a(planDetailItem2.getFinalPrice(), 0.0f)) {
            ui(new com.moe.pushlibrary.activities.b(10, this, planDetailItem));
        } else {
            openPaymentScreen(planDetailItem);
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.disposable.b();
    }

    public void onPause() {
        super.onPause();
        xq.d.a.d("Subscription page is paused", new Object[0]);
        pauseFreeTrialVideo();
    }

    @Override
    public void onResume() {
        FreeTrialResponse freeTrialResponse;
        super.onResume();
        FragmentActivity activity = getActivity();
        if (activity != null) {
            ArrayList arrayList = Qn.e.a;
            Qn.e.O(false, activity);
        }
        ArrayList arrayList2 = Qn.e.a;
        if (Qn.e.K() && (freeTrialResponse = Qn.e.k) != null && freeTrialResponse.getEnableFreeTrial()) {
            p0 p0Var = this.playPauseJob;
            if (p0Var != null) {
                p0Var.cancel((CancellationException) null);
            }
            this.playPauseJob = Kp.p.w(i0.i(this), (CoroutineContext) null, (Kp.J) null, new P(this, null), 3);
        }
    }

    @Override
    public void onSaveInstanceState(Bundle bundle) {
        WebView webView;
        Intrinsics.checkNotNullParameter(bundle, "outState");
        super.onSaveInstanceState(bundle);
        T4 binding = getBinding();
        if (binding == null || (webView = binding.Q) == null) {
            return;
        }
        webView.saveState(bundle);
    }

    public void onStart() {
        super.onStart();
        xq.d.a.d("Subscription page is onStart called", new Object[0]);
        pauseFreeTrialVideo();
    }

    @Override
    public void onViewCreated(View view, Bundle bundle) {
        String str;
        int i;
        int i2;
        String str2;
        WebView webView;
        WebView webView2;
        WebView webView3;
        WebView webView4;
        Intrinsics.checkNotNullParameter(view, "view");
        xq.d.a.d("Subscription page is onViewCreated called", new Object[0]);
        super.onViewCreated(view, bundle);
        Intrinsics.checkNotNullParameter(this, "fragment");
        Context requireContext = requireContext();
        Intrinsics.checkNotNullExpressionValue(requireContext, "requireContext(...)");
        Qn.x xVar = new Qn.x(requireContext);
        xVar.b = registerForActivityResult(new L8.n(4), new Qn.v(xVar, 0));
        this.permissionHandler = xVar;
        T4 binding = getBinding();
        if (binding != null && (webView4 = binding.Q) != null) {
            webView4.setBackgroundColor(Color.parseColor("#000000"));
        }
        Bundle arguments = getArguments();
        WebSettings webSettings = null;
        if (arguments != null && arguments.containsKey("subscription_meta")) {
            Bundle arguments2 = getArguments();
            Serializable serializable = arguments2 != null ? arguments2.getSerializable("subscription_meta") : null;
            Intrinsics.f(serializable, "null cannot be cast to non-null type com.vlv.aravali.payments.common.data.SubscriptionMeta");
            this.subscriptionMeta = (SubscriptionMeta) serializable;
        }
        Bundle arguments3 = getArguments();
        if (arguments3 != null && arguments3.containsKey("subscription_url")) {
            Bundle arguments4 = getArguments();
            this.subscriptionBaseUrl = arguments4 != null ? arguments4.getString("subscription_url", null) : null;
        }
        SubscriptionMeta subscriptionMeta = this.subscriptionMeta;
        if (subscriptionMeta == null || (str = subscriptionMeta.getSource()) == null) {
            str = "";
        }
        this.source = str;
        SubscriptionMeta subscriptionMeta2 = this.subscriptionMeta;
        if (subscriptionMeta2 == null || (i = subscriptionMeta2.getShowId()) == null) {
            i = -1;
        }
        this.showId = i;
        SubscriptionMeta subscriptionMeta3 = this.subscriptionMeta;
        if (subscriptionMeta3 == null || (i2 = subscriptionMeta3.getEpisodeId()) == null) {
            i2 = -1;
        }
        this.episodeId = i2;
        SubscriptionMeta subscriptionMeta4 = this.subscriptionMeta;
        String firstLevelSource = subscriptionMeta4 != null ? subscriptionMeta4.getFirstLevelSource() : null;
        if (firstLevelSource == null || StringsKt.H(firstLevelSource)) {
            str2 = this.source;
        } else {
            SubscriptionMeta subscriptionMeta5 = this.subscriptionMeta;
            str2 = subscriptionMeta5 != null ? subscriptionMeta5.getFirstLevelSource() : null;
        }
        this.firstLevelSource = String.valueOf(str2);
        SubscriptionMeta subscriptionMeta6 = this.subscriptionMeta;
        if (subscriptionMeta6 != null) {
            subscriptionMeta6.setFirstLevelSource("subscription_screen");
        }
        T4 binding2 = getBinding();
        if (binding2 != null && (webView3 = binding2.Q) != null) {
            webSettings = webView3.getSettings();
        }
        if (webSettings != null) {
            webSettings.setDomStorageEnabled(true);
        }
        if (webSettings != null) {
            webSettings.setJavaScriptEnabled(true);
        }
        if (webSettings != null) {
            webSettings.setDatabaseEnabled(true);
        }
        if (webSettings != null) {
            webSettings.setAllowFileAccess(true);
        }
        if (webSettings != null) {
            webSettings.setAllowContentAccess(true);
        }
        if (webSettings != null) {
            webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        }
        if (webSettings != null) {
            webSettings.setMediaPlaybackRequiresUserGesture(false);
        }
        if (webSettings != null) {
            webSettings.setUserAgentString(webSettings.getUserAgentString() + "KukuFMWebView");
        }
        T4 binding3 = getBinding();
        if (binding3 != null && (webView2 = binding3.Q) != null) {
            webView2.addJavascriptInterface(new C1478a(this), LogSubCategory.LifeCycle.ANDROID);
        }
        WebView.setWebContentsDebuggingEnabled(false);
        T4 binding4 = getBinding();
        if (binding4 != null && (webView = binding4.Q) != null) {
            webView.setWebViewClient(new Bk.C(this, 8));
        }
        initObservers();
    }

    public void onViewStateRestored(Bundle bundle) {
        WebView webView;
        super.onViewStateRestored(bundle);
        if (bundle == null) {
            setAndLoadWebView();
            return;
        }
        T4 binding = getBinding();
        if (binding == null || (webView = binding.Q) == null) {
            return;
        }
        webView.restoreState(bundle);
    }

    public final void openChat() {
        Qn.x xVar = this.permissionHandler;
        if (xVar != null) {
            xVar.b(new String[]{"android.permission.CAMERA"}, new Yl.m(this, 21));
        } else {
            Intrinsics.m("permissionHandler");
            throw null;
        }
    }

    public final void postMessage(String str) {
        String firebaseSignInProvider;
        Intrinsics.checkNotNullParameter(str, "message");
        Ai.p pVar = KukuFMApplication.x;
        SharedPreferences.Editor edit = pVar.B().h().a.a.edit();
        edit.putBoolean("is_buy_now_clicked", true);
        edit.apply();
        PlanDetailItem planDetailItem = (PlanDetailItem) new com.google.gson.e().a().c(PlanDetailItem.class, str);
        uj.d h = pVar.B().h();
        Intrinsics.checkNotNullParameter(str, "message");
        SharedPreferences.Editor edit2 = h.a.a.edit();
        edit2.putString("plan_detail_string", str);
        edit2.apply();
        uj.d h2 = pVar.B().h();
        Intrinsics.checkNotNullParameter(str, "planString");
        SharedPreferences.Editor edit3 = h2.a.a.edit();
        edit3.putString("last_selected_plan", str);
        edit3.apply();
        ByPassLoginData byPassLoginData = new ByPassLoginData("login_navigate_to_payment_flow", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 131070, null);
        byPassLoginData.setPaymentPlanData(planDetailItem);
        Bi.k l = pVar.B().d().l("subscription_screen_pay_clicked");
        l.c(this.source, "source");
        l.c(this.firstLevelSource, "first_level_source");
        l.c(this.utmSource, "utm_source");
        String str2 = this.utmMedium;
        if (str2 == null) {
            str2 = "";
        }
        l.c(str2, "utm_medium");
        String str3 = this.utmCampaign;
        l.c(str3 != null ? str3 : "", "utm_campaign");
        Integer num = this.showId;
        l.c(Integer.valueOf(num != null ? num.intValue() : -1), "show_id");
        Integer num2 = this.episodeId;
        l.c(Integer.valueOf(num2 != null ? num2.intValue() : -1), "episode_id");
        l.c(planDetailItem.getTitle(), "plan_name");
        l.c(planDetailItem.getId(), "plan_id");
        l.c(String.valueOf(System.currentTimeMillis() - this.startTime), "time_spent");
        l.g(false);
        pauseFreeTrialVideo();
        if (C1830p.loginRequest$default(this, byPassLoginData, "subscription_buy_now_tab", null, 4, null)) {
            if (!Pk.j.a("fb_user_auth_using_otp")) {
                navigateToPaymentFlow(planDetailItem);
                return;
            }
            User t = io.sentry.config.d.t(pVar);
            String email = t != null ? t.getEmail() : null;
            if (email == null || StringsKt.H(email)) {
                String mobile = t != null ? t.getMobile() : null;
                if ((mobile == null || StringsKt.H(mobile)) && t != null && (firebaseSignInProvider = t.getFirebaseSignInProvider()) != null && firebaseSignInProvider.equals("facebook.com")) {
                    getUserContactAndContinue();
                    return;
                }
            }
            navigateToPaymentFlow(planDetailItem);
        }
    }

    public final void sendEvent(String str, String str2) {
        Intrinsics.checkNotNullParameter(str, "eventName");
        xq.d.a.a(Ai.o.j("SubscriptionFragment ", str, ", ", str2), new Object[0]);
        try {
            Bi.k l = KukuFMApplication.x.B().d().l(str);
            String str3 = "";
            if (str2 == null) {
                str2 = "";
            }
            JSONObject jSONObject = new JSONObject(str2);
            ArrayList arrayList = Qn.e.a;
            Bundle d = Qn.e.d(jSONObject);
            l.a(d);
            l.c(this.firstLevelSource, "first_level_source");
            Integer num = this.showId;
            l.c(Integer.valueOf(num != null ? num.intValue() : -1), "show_id");
            String str4 = this.utmSource;
            if (str4 == null) {
                str4 = "";
            }
            l.c(str4, "utm_source");
            String str5 = this.utmMedium;
            if (str5 == null) {
                str5 = "";
            }
            l.c(str5, "utm_medium");
            String str6 = this.utmCampaign;
            if (str6 == null) {
                str6 = "";
            }
            l.c(str6, "utm_campaign");
            if (!d.containsKey("source")) {
                String str7 = this.source;
                if (str7 != null) {
                    str3 = str7;
                }
                l.c(str3, "source");
            }
            l.d();
        } catch (Exception unused) {
            androidx.datastore.preferences.protobuf.o.r(KukuFMApplication.x, "send_event_exception");
        }
    }

    public final void setAndLoadWebView() {
        String str;
        String s;
        String str2;
        Object forWebSource;
        User.PageInfo pageInfo;
        String params;
        List<String> pathSegments;
        CookieManager cookieManager = CookieManager.getInstance();
        Ai.p pVar = KukuFMApplication.x;
        User t = io.sentry.config.d.t(pVar);
        pVar.B().e();
        boolean z = il.f.f() || (t != null && t.isAnonymous());
        Uri uri = Qn.e.c;
        this.utmSource = uri != null ? uri.getQueryParameter("utm_source") : null;
        this.utmMedium = uri != null ? uri.getQueryParameter("utm_medium") : null;
        this.utmCampaign = uri != null ? uri.getQueryParameter("utm_campaign") : null;
        xq.d.a.a(AbstractC0210b.m(uri, "Util Link Subs: "), new Object[0]);
        String slug = pVar.B().h().e().getSlug();
        if (this.showContentLangOnSubsPage) {
            ArrayList<Language> n = androidx.datastore.preferences.protobuf.o.n(pVar);
            ArrayList arrayList = new ArrayList();
            for (Language language : n) {
                if (language.isSelected()) {
                    arrayList.add(language);
                }
            }
            if (arrayList.size() == 1) {
                slug = String.valueOf(((Language) CollectionsKt.N(arrayList)).getSlug());
                this.languageSelectionMedium = CONTENT_LANGUAGE;
            }
        }
        kotlin.jvm.internal.I i = new kotlin.jvm.internal.I();
        String str3 = this.subscriptionBaseUrl;
        if (str3 == null) {
            str3 = "https://kukufm.com/subscription/";
        }
        i.a = j.e.e(str3, slug);
        if (!Pk.j.a("should_show_new_subscription_page")) {
            User t2 = io.sentry.config.d.t(KukuFMApplication.x);
            i.a = (t2 == null || !t2.isPremium()) ? i.a + "/false" : i.a + "/true";
        }
        SubscriptionMeta subscriptionMeta = this.subscriptionMeta;
        Object obj = "";
        if (subscriptionMeta == null || (str = subscriptionMeta.getWebViewFeedback()) == null) {
            str = "";
        }
        ArrayList arrayList2 = Qn.e.a;
        if (Qn.e.S(str)) {
            str = "&feedback=".concat(str);
        }
        if (Pk.j.a("should_show_new_subscription_page")) {
            s = i.a + "?buildNumber=" + AbstractC2062a.a + "&isAnonymous=" + z + str;
        } else {
            Object obj2 = i.a;
            int i2 = AbstractC2062a.a;
            String b = KukuFMApplication.x.B().e().b();
            if (b == null) {
                b = "";
            }
            StringBuilder sb = new StringBuilder();
            sb.append(obj2);
            sb.append("?buildNumber=");
            sb.append(i2);
            sb.append("&isAnonymous=");
            sb.append(z);
            s = Ai.o.s(sb, "&uid=", b, str);
        }
        i.a = s;
        this.finalUrlBeforeDeeplink = s;
        if (uri != null && (pathSegments = uri.getPathSegments()) != null && pathSegments.contains(PATH_SUBSCRIPTION)) {
            i.a = i.a + "&deeplinkUrl=" + URLEncoder.encode(uri.toString(), "UTF-8");
        }
        Integer num = this.showId;
        if (num != null && num.intValue() != -1) {
            i.a = i.a + "&showId=" + this.showId;
        }
        SubscriptionMeta subscriptionMeta2 = this.subscriptionMeta;
        String showImageUrl = subscriptionMeta2 != null ? subscriptionMeta2.getShowImageUrl() : null;
        if (showImageUrl != null && !StringsKt.H(showImageUrl)) {
            Object obj3 = i.a;
            SubscriptionMeta subscriptionMeta3 = this.subscriptionMeta;
            i.a = obj3 + "&showImageUrl=" + (subscriptionMeta3 != null ? subscriptionMeta3.getShowImageUrl() : null);
        }
        String str4 = this.utmSource;
        if (str4 != null && str4.length() > 0) {
            i.a = i.a + "&utmSource=" + this.utmSource;
        }
        String str5 = this.source;
        if (str5 != null && str5.length() > 0) {
            i.a = i.a + "&source=" + this.source;
        }
        Ai.p pVar2 = KukuFMApplication.x;
        User t3 = io.sentry.config.d.t(pVar2);
        if (t3 != null && (pageInfo = t3.getPageInfo()) != null && (params = pageInfo.getParams()) != null) {
            i.a = i.a + params;
        }
        FragmentActivity activity = getActivity();
        if (activity != null) {
            String str6 = i.a + "&isPhonePeAppAvailable=" + Qn.e.I(activity, "com.phonepe.app");
            i.a = str6;
            i.a = ((Object) str6) + "&isPaytmAppAvailable=" + Qn.e.I(activity, "net.one97.paytm");
        }
        Object obj4 = i.a;
        if (t == null || (str2 = t.getName()) == null) {
            str2 = "";
        }
        i.a = obj4 + "&userName=" + URLEncoder.encode(str2, "UTF-8");
        String string = pVar2.B().h().a.a.getString("referral_code", "");
        Intrinsics.e(string);
        if (string.length() > 0) {
            Object obj5 = i.a;
            String string2 = pVar2.B().h().a.a.getString("referral_code", "");
            Intrinsics.e(string2);
            i.a = obj5 + "&referral_code=" + string2;
            uj.d h = pVar2.B().h();
            Intrinsics.checkNotNullParameter("", "code");
            Ai.o.B(h.a.a, "referral_code", "");
        }
        Object obj6 = i.a;
        SubscriptionMeta subscriptionMeta4 = this.subscriptionMeta;
        if (subscriptionMeta4 != null && (forWebSource = subscriptionMeta4.getForWebSource()) != null) {
            obj = forWebSource;
        }
        i.a = obj6 + "&sub_source=" + obj;
        xq.b bVar = xq.d.a;
        bVar.m("subscriptionUrl");
        bVar.a((String) i.a, new Object[0]);
        cookieManager.setCookie("https://kukufm.com/", "KukufmWebview=true; path=/; domain=.kukufm.com");
        cookieManager.setCookie("https://kukufm.com/", "AppName=com.vlv.aravali.bhakti; path=/; domain=.kukufm.com");
        String str7 = pVar2.B().e().e;
        if (str7 != null) {
            ui(new J(this, str7, cookieManager, i, 0));
        } else {
            pVar2.B().e().c(new Hm.r(this, cookieManager, i, 12));
        }
        bVar.d(androidx.datastore.preferences.protobuf.o.j(i.a, "weburl : "), new Object[0]);
        getLogs();
    }

    public final void setFreshChat(Qn.t tVar) {
        Intrinsics.checkNotNullParameter(tVar, "<set-?>");
        this.freshChat = tVar;
    }

    public final void trackFaqEvent(String str) {
        String str2;
        Boolean isExpanded;
        Boolean isHindi;
        Intrinsics.checkNotNullParameter(str, "message");
        xq.b bVar = xq.d.a;
        bVar.m("webview command");
        boolean z = false;
        bVar.a(str, new Object[0]);
        FaqItem faqItem = (FaqItem) new com.google.gson.e().a().c(FaqItem.class, str);
        Bi.k r = io.sentry.config.d.r(KukuFMApplication.x, "subscription_page_faqs_clicked");
        r.c(this.source, "source");
        Integer num = this.showId;
        r.c(Integer.valueOf(num != null ? num.intValue() : -1), "show_id");
        Integer num2 = this.episodeId;
        r.c(Integer.valueOf(num2 != null ? num2.intValue() : -1), "episode_id");
        if (faqItem == null || (str2 = faqItem.getQuestion()) == null) {
            str2 = "";
        }
        r.c(str2, "faq_question");
        r.c(Boolean.valueOf((faqItem == null || (isHindi = faqItem.isHindi()) == null) ? false : isHindi.booleanValue()), "is_hindi");
        if (faqItem != null && (isExpanded = faqItem.isExpanded()) != null) {
            z = isExpanded.booleanValue();
        }
        r.c(Boolean.valueOf(z), "is_expanded");
        r.d();
    }

    public final void trackPlanEvent(String str) {
        Intrinsics.checkNotNullParameter(str, "message");
        PlanDetailItem planDetailItem = (PlanDetailItem) new com.google.gson.e().a().c(PlanDetailItem.class, str);
        Bi.k r = io.sentry.config.d.r(KukuFMApplication.x, "plan_selected");
        r.c(planDetailItem != null ? planDetailItem.getId() : null, "plan_id");
        r.c(planDetailItem != null ? planDetailItem.getTitle() : null, "plan_name");
        r.c(planDetailItem != null ? planDetailItem.getType() : null, "plan_type");
        r.c(planDetailItem != null ? planDetailItem.getValidity() : null, "validity");
        r.c(planDetailItem != null ? planDetailItem.getDiscount() : null, "discount_amount");
        r.c(planDetailItem != null ? planDetailItem.getPrice() : null, "plan_price");
        Integer num = this.showId;
        r.c(Integer.valueOf(num != null ? num.intValue() : -1), "show_id");
        Integer num2 = this.episodeId;
        r.c(Integer.valueOf(num2 != null ? num2.intValue() : -1), "episode_id");
        r.c(this.source, "source");
        r.d();
    }

    @Override
    public void webViewOnPostLogin(PlanDetailItem planDetailItem) {
        Intrinsics.checkNotNullParameter(planDetailItem, "planDetails");
        User t = io.sentry.config.d.t(KukuFMApplication.x);
        if (t == null || !t.isPremium()) {
            navigateToPaymentFlow(planDetailItem);
            setAndLoadWebView();
        } else if (getActivity() instanceof MasterActivity) {
            MasterActivity activity = getActivity();
            Intrinsics.f(activity, "null cannot be cast to non-null type com.vlv.aravali.master.ui.MasterActivity");
            activity.navigateToHome();
        }
    }

    @Override
    public void webViewPostMessage(String str) {
        Intrinsics.checkNotNullParameter(str, "msg");
        xq.d.a.d(Ai.o.h("SubscriptionFragment - Webview PostMessage received: ", str), new Object[0]);
        postMessage(str);
    }

    public final void makeUserLoginForWebView(String str) {
        Intrinsics.checkNotNullParameter(str, IMGwo.uGdPQnIG);
        ByPassLoginData byPassLoginData = new ByPassLoginData("login_for_web_view_feedback", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 131070, null);
        byPassLoginData.setWebviewPostMessage(str);
        FragmentActivity activity = getActivity();
        if (activity != null) {
            ArrayList arrayList = Qn.e.a;
            Intrinsics.checkNotNullParameter(activity, "activity");
            View findViewById = activity.findViewById(R.id.content);
            Intrinsics.checkNotNullExpressionValue(findViewById, "findViewById(...)");
            Object systemService = activity.getSystemService("input_method");
            Intrinsics.f(systemService, "null cannot be cast to non-null type android.view.inputmethod.InputMethodManager");
            ((InputMethodManager) systemService).hideSoftInputFromWindow(findViewById.getWindowToken(), 0);
        }
        new Handler(Looper.getMainLooper()).postDelayed(new U8.b(21, this, byPassLoginData), 300L);
    }
}