<?php


namespace OTP\Handler;

if (defined("\101\x42\x53\120\x41\124\x48")) {
    goto Df;
}
die;
Df:
use OTP\Helper\FormSessionVars;
use OTP\Helper\GatewayFunctions;
use OTP\Helper\MoConstants;
use OTP\Helper\MoMessages;
use OTP\Helper\MoUtility;
use OTP\Helper\SessionUtils;
use OTP\Objects\FormSessionData;
use OTP\Objects\VerificationLogic;
use OTP\Traits\Instance;
final class PhoneVerificationLogic extends VerificationLogic
{
    use Instance;
    public function _handle_logic($te, $j4, $sP, $c2, $DF)
    {
        $HX = MoUtility::validatePhoneNumber($sP);
        switch ($HX) {
            case 0:
                $this->_handle_not_matched($sP, $c2, $DF);
                goto By;
            case 1:
                $this->_handle_matched($te, $j4, $sP, $c2, $DF);
                goto By;
        }
        he:
        By:
    }
    public function _handle_matched($te, $j4, $sP, $c2, $DF)
    {
        $Kl = str_replace("\x23\43\x70\150\x6f\156\x65\43\43", $sP, $this->_get_is_blocked_message());
        if ($this->_is_blocked($j4, $sP)) {
            goto D9;
        }
        $this->_start_otp_verification($te, $j4, $sP, $c2, $DF);
        goto vY;
        D9:
        if ($this->_is_ajax_form()) {
            goto SL;
        }
        miniorange_site_otp_validation_form(null, null, null, $Kl, $c2, $DF);
        goto Xl;
        SL:
        wp_send_json(MoUtility::createJson($Kl, MoConstants::ERROR_JSON_TYPE));
        Xl:
        vY:
    }
    public function _start_otp_verification($te, $j4, $sP, $c2, $DF)
    {
        $c6 = GatewayFunctions::instance();
        $PA = $c6->mo_send_otp_token("\x53\115\123", '', $sP);
        switch ($PA["\x73\164\x61\164\x75\x73"]) {
            case "\123\x55\103\x43\105\123\123":
                $this->_handle_otp_sent($te, $j4, $sP, $c2, $DF, $PA);
                goto vw;
            default:
                $this->_handle_otp_sent_failed($te, $j4, $sP, $c2, $DF, $PA);
                goto vw;
        }
        RS:
        vw:
    }
    public function _handle_not_matched($sP, $c2, $DF)
    {
        $Kl = str_replace("\x23\x23\x70\x68\157\x6e\145\x23\x23", $sP, $this->_get_otp_invalid_format_message());
        if ($this->_is_ajax_form()) {
            goto vg;
        }
        miniorange_site_otp_validation_form(null, null, null, $Kl, $c2, $DF);
        goto xx;
        vg:
        wp_send_json(MoUtility::createJson($Kl, MoConstants::ERROR_JSON_TYPE));
        xx:
    }
    public function _handle_otp_sent_failed($te, $j4, $sP, $c2, $DF, $PA)
    {
        $Kl = str_replace("\43\x23\x70\150\157\x6e\145\x23\x23", $sP, $this->_get_otp_sent_failed_message());
        if ($this->_is_ajax_form()) {
            goto cE;
        }
        miniorange_site_otp_validation_form(null, null, null, $Kl, $c2, $DF);
        goto Na;
        cE:
        wp_send_json(MoUtility::createJson($Kl, MoConstants::ERROR_JSON_TYPE));
        Na:
    }
    public function _handle_otp_sent($te, $j4, $sP, $c2, $DF, $PA)
    {
        SessionUtils::setPhoneTransactionID($PA["\x74\x78\x49\x64"]);
        if (!(MoUtility::micr() && MoUtility::isMG())) {
            goto YR;
        }
        $uo = get_mo_option("\160\150\x6f\x6e\x65\137\164\x72\x61\156\163\x61\x63\x74\151\157\156\x73\137\162\x65\155\141\151\x6e\151\156\x67");
        if (!($uo > 0)) {
            goto u0;
        }
        update_mo_option("\160\x68\157\x6e\145\137\164\162\x61\x6e\x73\141\x63\164\151\x6f\x6e\x73\x5f\162\145\x6d\x61\x69\x6e\151\156\x67", $uo - 1);
        u0:
        YR:
        $Kl = str_replace("\43\43\160\x68\x6f\156\145\x23\43", $sP, $this->_get_otp_sent_message());
        if ($this->_is_ajax_form()) {
            goto oZ;
        }
        miniorange_site_otp_validation_form($te, $j4, $sP, $Kl, $c2, $DF);
        goto qN;
        oZ:
        wp_send_json(MoUtility::createJson($Kl, MoConstants::SUCCESS_JSON_TYPE));
        qN:
    }
    public function _get_otp_sent_message()
    {
        $Lv = get_mo_option("\163\x75\x63\143\x65\163\x73\137\160\150\x6f\x6e\145\x5f\155\145\163\x73\141\x67\145", "\155\x6f\x5f\x6f\164\x70\137");
        return $Lv ? $Lv : MoMessages::showMessage(MoMessages::OTP_SENT_PHONE);
    }
    public function _get_otp_sent_failed_message()
    {
        $Yi = get_mo_option("\145\x72\x72\x6f\162\x5f\x70\150\157\x6e\145\137\155\x65\x73\163\x61\147\x65", "\x6d\157\137\x6f\x74\160\x5f");
        return $Yi ? $Yi : MoMessages::showMessage(MoMessages::ERROR_OTP_PHONE);
    }
    public function _get_otp_invalid_format_message()
    {
        $Ym = get_mo_option("\151\156\166\x61\x6c\151\144\x5f\x70\150\x6f\156\x65\x5f\x6d\145\x73\x73\x61\147\145", "\155\157\137\x6f\x74\160\137");
        return $Ym ? $Ym : MoMessages::showMessage(MoMessages::ERROR_PHONE_FORMAT);
    }
    public function _is_blocked($j4, $sP)
    {
        $Li = explode("\73", get_mo_option("\142\154\x6f\x63\153\x65\x64\137\160\150\x6f\x6e\x65\x5f\x6e\165\x6d\142\x65\x72\x73"));
        $Li = apply_filters("\155\x6f\x5f\x62\x6c\x6f\143\x6b\x65\x64\137\x70\150\157\x6e\145\x73", $Li);
        return in_array($sP, $Li);
    }
    public function _get_is_blocked_message()
    {
        $Bl = get_mo_option("\x62\154\x6f\x63\x6b\x65\x64\137\160\150\157\x6e\145\137\x6d\145\163\163\141\x67\x65", "\155\157\137\157\164\x70\137");
        return $Bl ? $Bl : MoMessages::showMessage(MoMessages::ERROR_PHONE_BLOCKED);
    }
}
