Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php declare (strict_types=1); namespace OneTeamSoftware\WC\Shipping; use OneTeamS..

Decoded Output download

<?php 
declare (strict_types=1); 
 
namespace OneTeamSoftware\WC\Shipping; 
 
use OneTeamSoftware\LazyClassProxy\LazyClassProxy; 
use OneTeamSoftware\WC\Shipping\Form\SettingsForm; 
use OneTeamSoftware\WC\Shipping\ParcelInfoFormatter\ParcelInfoFormatter; 
use OneTeamSoftware\WC\Shipping\SettingsValidator\AdapterRequirements; 
use OneTeamSoftware\WC\Shipping\SettingsValidator\CacheRequirements; 
use OneTeamSoftware\WC\Shipping\SettingsValidator\OriginRequirements; 
use OneTeamSoftware\WC\Shipping\SettingsValidator\ProductShippingRequirements; 
use OneTeamSoftware\WC\Shipping\SettingsValidator\SettingsValidators; 
use OneTeamSoftware\WC\Shipping\SettingsValidator\ShippingZones; 
use OneTeamSoftware\WC\Shipping\SettingsValidator\ShippingZonesWithUseSellerAddress; 
 
class ShippingMethod extends AbstractShippingMethod 
{ 
    protected $plugin; 
    protected $pluginPath; 
    protected $version; 
    protected $adapter; 
    protected $cache; 
    protected $keyGenerator; 
    protected $ratesFinder; 
    protected $parcelPacker; 
    protected $shipmentBuilder; 
    protected $cartProxy; 
    protected $countriesProxy; 
    protected $customerProxy; 
    protected $sessionProxy; 
    protected $logger; 
    protected $weightConverter; 
    protected $dimensionConverter; 
    protected $settingsForm; 
    protected $packagePropertiesBuilder; 
    protected $ratesFilter; 
    protected $settingsValidators; 
    protected $ratesMerger; 
    protected $rateMetaDataBuilder; 
    protected $parcelInfoFormatter; 
 
    public function __construct(int $Q_ExN = 0) 
    { 
        $this->plugin = null; 
        $saD2e = Plugin::getInstance($this->getPluginId()); 
        if (is_null($saD2e)) { 
            return; 
        } 
        parent::__construct($Q_ExN); 
        $this->instance_id = $Q_ExN; 
        $this->plugin = $saD2e; 
        $this->id = $saD2e->getPluginId(); 
        $this->pluginPath = $saD2e->getPluginPath(); 
        $this->version = $saD2e->getVersion(); 
        $this->adapter = $saD2e->getAdapter(); 
        $this->cache = $saD2e->getCache(); 
        $this->keyGenerator = $saD2e->getKeyGenerator(); 
        $this->method_title = $saD2e->getTitle(); 
        $this->method_description = $saD2e->getDescription(); 
        $this->logger = $saD2e->getLogger(); 
        $this->weightConverter = $saD2e->getWeightConverter(); 
        $this->dimensionConverter = $saD2e->getDimensionConverter(); 
        $this->parcelPacker = $saD2e->getParcelPacker(); 
        $this->shipmentBuilder = $saD2e->getShipmentBuilder(); 
        $this->supports = ["settings"]; 
        $this->settingsForm = new SettingsForm($this->id, $saD2e->getLogExporter()); 
        $this->ratesMerger = new RatesMerger(); 
        $this->rateMetaDataBuilder = new RateMetaDataBuilder(); 
        $this->cartProxy = new LazyClassProxy("WC_Cart", WC()->cart); 
        $this->countriesProxy = new LazyClassProxy("WC_Countries", WC()->countries); 
        $this->customerProxy = new LazyClassProxy("WC_Customer", WC()->customer); 
        $this->sessionProxy = new LazyClassProxy(apply_filters("woocommerce_session_handler", "WC_Session_Handler"), WC()->session); 
        $this->init(); 
    } 
 
    public function enqueueScripts(): void 
    { 
        if (!$this->isSettingsPage()) { 
            return; 
        } 
        $Ptc5J = "min.css"; 
        $R3SKf = "min.js"; 
        if (defined("WP_DEBUG") && WP_DEBUG) { 
            $Ptc5J = "css"; 
            $R3SKf = "js"; 
        } 
        wp_register_style($this->id . "-switchify", plugins_url("assets/css/switchify." . $Ptc5J, str_replace("phar://", '', $this->pluginPath)), [], $this->version); 
        wp_enqueue_style($this->id . "-switchify"); 
        wp_register_script($this->id . "-switchify", plugins_url("assets/js/switchify." . $R3SKf, str_replace("phar://", '', $this->pluginPath)), ["jquery"], $this->version); 
        wp_enqueue_script($this->id . "-switchify"); 
        wp_register_style($this->id . "-shippingmethod", plugins_url("assets/css/ShippingMethod." . $Ptc5J, str_replace("phar://", '', $this->pluginPath)), ["wp-jquery-ui-dialog"], $this->version); 
        wp_enqueue_style($this->id . "-shippingmethod"); 
        wp_register_script($this->id . "-shippingmethod", plugins_url("assets/js/ShippingMethod." . $R3SKf, str_replace("phar://", '', $this->pluginPath)), ["jquery", "jquery-blockui", "jquery-ui-dialog"], $this->version); 
        wp_enqueue_script($this->id . "-shippingmethod"); 
        wp_register_script($this->id . "-form-navigation-tabs", plugins_url("assets/js/FormNavigationTabs." . $R3SKf, str_replace("phar://", '', $this->pluginPath)), [], $this->version); 
        wp_enqueue_script($this->id . "-form-navigation-tabs"); 
        wp_register_script($this->id . "-form-navigation-tabs-loader", plugins_url("assets/js/FormNavigationTabsLoader." . $R3SKf, str_replace("phar://", '', $this->pluginPath)), [], $this->version); 
        wp_enqueue_script($this->id . "-form-navigation-tabs-loader"); 
    } 
 
    protected function getProFeatureSuffix(): string 
    { 
        $hDW6r = sprintf(" <strong>(%s <a href="%s" target="_blank">%s</a>)</strong>", __("Requires", $this->id), "https://1teamsoftware.com/product/" . preg_replace("/wc/", "woocommerce", $this->id) . "-pro/", __("PRO Version", $this->id)); 
        return $hDW6r; 
    } 
 
    protected function getProFeatureAttributes(): array 
    { 
        $RJ20H = ["disabled" => "yes"]; 
        return $RJ20H; 
    } 
 
    protected function init(): void 
    { 
        if (!function_exists("is_plugin_active")) { 
            require_once ABSPATH . "/wp-admin/includes/plugin.php"; 
        } 
        $this->initRatesFilter(); 
        $this->initPackagePropertiesBuilder(); 
        do_action($this->id . "_setInstanceId", $this->instance_id); 
        $this->initFormFields(); 
        $this->init_settings(); 
        $this->enqueueScripts(); 
        remove_all_actions("woocommerce_update_options_shipping_" . $this->id); 
        add_action("woocommerce_update_options_shipping_" . $this->id, [$this, "process_admin_options"]); 
        $this->title = $this->get_option("title", $this->method_title); 
        $this->enabled = "yes"; 
        if ("yes" === $this->get_option("shippingZones", "no")) { 
            $this->supports[] = "shipping-zones"; 
        } 
        $this->initRatesFinder(); 
        $this->initFormFields(); 
        $this->initParcelPacker(); 
        $this->parcelInfoFormatter = new ParcelInfoFormatter($this->id, $this->settings["dimension_unit"] ?? '', $this->settings["weight_unit"] ?? ''); 
    } 
 
    protected function initRatesFinder(): void 
    { 
        $this->ratesFinder = new ApiRatesFinder($this->id, $this->adapter, $this->shipmentBuilder, $this->logger, $this->get_settings()); 
    } 
 
    protected function initParcelPacker(): void 
    { 
        $this->parcelPacker->setSettings($this->get_settings()); 
    } 
 
    protected function initFormFields(): void 
    { 
        if (!function_exists("is_plugin_active")) { 
            require_once ABSPATH . "/wp-admin/includes/plugin.php"; 
        } 
        $this->instance_form_fields = []; 
        $this->settingsForm->setSettings($this->settings); 
        $this->settingsForm->setProFeatureSuffix($this->getProFeatureSuffix()); 
        $this->settingsForm->setProFeatureAttributes($this->getProFeatureAttributes()); 
        $this->form_fields = $this->settingsForm->getFields(); 
        $this->form_fields = apply_filters($this->id . "_init_form_fields", $this->form_fields); 
    } 
 
    protected function tryToFixPackage(array $xECMj): array 
    { 
        if (false === empty($xECMj) && false === empty($xECMj["contents"])) { 
            return $xECMj; 
        } 
        $this->logger->debug(__FILE__, 392, "Package contents is empty, lets try to use contents of the cart"); 
        if (empty($xECMj)) { 
            $xECMj = []; 
        } 
        $xECMj["contents"] = $this->cartProxy->get_cart(); 
        return $xECMj; 
    } 
 
    protected function syncSettings(): void 
    { 
        $this->logger->debug(__FILE__, 410, "syncSettings"); 
        $this->logger->debug(__FILE__, 412, "General Settings: %s", print_r($this->settings, true)); 
        if (false === empty($this->instance_id) && is_array($this->instance_settings)) { 
            $this->logger->debug(__FILE__, 414, "Instance Settings: %s", print_r($this->instance_settings, true)); 
        } 
        $dK4bD = $this->get_settings(); 
        $this->adapter->init($dK4bD)->wait(); 
        $this->parcelPacker->setSettings($dK4bD); 
        $this->packagePropertiesBuilder->setSettings($dK4bD); 
        $this->ratesFilter->setSettings($dK4bD); 
        $this->ratesFinder->setSettings($dK4bD); 
    } 
 
    protected function displayValidationErrors(?array $fOhpy): void 
    { 
        $this->logger->debug(__FILE__, 434, "Display Validation Errors"); 
        if (empty($fOhpy)) { 
            return; 
        } 
        foreach ($fOhpy as $BqmGR => $GxTN_) { 
            $sIY2U = ''; 
            if ("origin" === $BqmGR) { 
                $sIY2U = __("From Address: ", $this->id); 
            } elseif ("destination" === $BqmGR) { 
                $sIY2U = __("To Address: ", $this->id); 
            } 
            foreach ($GxTN_ as $uuWop) { 
                wc_add_notice($sIY2U . $uuWop, "error"); 
                EHKKQ: 
            } 
            QxO60: OZsdd: 
        } 
        AGMyl: 
    } 
 
    protected function findShippingRatesForParcels(array $xECMj, array $LLX65): array 
    { 
        $this->logger->debug(__FILE__, 463, "findShippingRatesForParcels"); 
        $Hdu1c = []; 
        foreach ($LLX65 as $AACCr => $pLlsY) { 
            $this->logger->debug(__FILE__, 467, "Find shipping rate for parcel #" . $AACCr); 
            $this->debug(sprintf("<br><strong>%s #%s:</strong><br/>%s</br>", __("Parcel", $this->id), $AACCr + 1, $this->parcelInfoFormatter->formatParcel($pLlsY))); 
            $pLlsY = $this->prepareParcel($xECMj, $pLlsY); 
            $NGhdD = $this->findShippingRates($xECMj, $pLlsY); 
            if ($AACCr > 0) { 
                $Hdu1c = $this->combineRates($Hdu1c, $NGhdD); 
            } else { 
                $Hdu1c = $NGhdD; 
            } 
            gulsF: 
        } 
        a6Ntx: 
        return $Hdu1c; 
    } 
 
    protected function findShippingRates(array $xECMj, array $pLlsY): array 
    { 
        $this->logger->debug(__FILE__, 499, "findShippingRates: %s", print_r($pLlsY, true)); 
        $this->rateMetaDataBuilder->withParcel($pLlsY); 
        $T_PFB = $this->keyGenerator->getKey($pLlsY); 
        $Hdu1c = $this->cache->get($T_PFB); 
        $LGayx = $T_PFB . "_errorMessage"; 
        $CvFbJ = $this->cache->get($LGayx); 
        $icEC5 = $T_PFB . "_validationErrors"; 
        $fOhpy = $this->cache->get($icEC5); 
        if (is_array($Hdu1c)) { 
            $this->logger->debug(__FILE__, 513, "Cached shipping rates have been found"); 
        } else { 
            $Hdu1c = $this->ratesFinder->findShippingRates($pLlsY); 
            $this->cache->set($T_PFB, $Hdu1c); 
            $CvFbJ = $this->ratesFinder->getError(); 
            $this->cache->set($LGayx, $CvFbJ); 
            $fOhpy = $this->ratesFinder->getValidationErrors(); 
            $this->cache->set($icEC5, $fOhpy); 
        } 
        if (empty($Hdu1c)) { 
            $this->logger->debug(__FILE__, 526, "No shipping rates have been found"); 
        } 
        if (false === empty($CvFbJ)) { 
            $this->logger->debug(__FILE__, 530, "Error Message: %s", $CvFbJ); 
            $this->debug($CvFbJ); 
        } 
        $this->logger->debug(__FILE__, 534, "Validation Errors: %s", print_r($fOhpy, true)); 
        $this->sessionProxy->set($this->id . "_validationErrors", $fOhpy); 
        if ("yes" === $this->get_option("enableLiveShippingRates", "yes")) { 
            $Hdu1c = $this->prepareShippingRates($Hdu1c); 
            $this->logger->debug(__FILE__, 541, "Rates: %s", print_r($Hdu1c, true)); 
        } else { 
            $Hdu1c = []; 
        } 
        return $Hdu1c; 
    } 
 
    protected function displayDebugParcelInfo(array $pLlsY): void 
    { 
        $this->logger->debug(__FILE__, 557, "Parcel: %s", print_r($pLlsY, true)); 
        $M5fcX = [__("Parcel", $this->id) => $pLlsY["id"], __("Length", $this->id) => $pLlsY["length"], __("Width", $this->id) => $pLlsY["width"], __("Height", $this->id) => $pLlsY["height"], __("Weight", $this->id) => $pLlsY["weight"], __("Weight Unit", $this->id) => $pLlsY["weight_unit"], __("Dimension Unit", $this->id) => $pLlsY["dimension_unit"], __("Signature", $this->id) => $pLlsY["signature"], __("Signature Type", $this->id) => $pLlsY["signature_type"], __("Insurance", $this->id) => $pLlsY["insurance"], __("Media Mail", $this->id) => $pLlsY["mediaMail"], __("Vendor ID", $this->id) => $pLlsY["vendor_id"], __("Seller ID", $this->id) => $pLlsY["seller_id"], __("Currency", $this->id) => $pLlsY["currency"], __("Destination", $this->id) => $pLlsY["destination"]]; 
        $this->logger->debug(__FILE__, 577, "Parcel Info: %s", print_r($M5fcX, true)); 
    } 
 
    protected function getCustomerAddress(): array 
    { 
        $GCSjq = []; 
        $Y6_8b = []; 
        if (false === empty($_POST["post_data"])) { 
            parse_str(wp_unslash($_POST["post_data"]), $Y6_8b); 
            if (empty($Y6_8b)) { 
                $Y6_8b = []; 
            } else { 
                $Y6_8b = wc_clean($Y6_8b); 
            } 
            $this->logger->debug(__FILE__, 602, "Posted data: %s", print_r($Y6_8b, true)); 
        } 
        $jXAfc = ["first_name" => "name", "last_name" => "name", "company" => "company", "address_1" => "address", "address_2" => "address_2", "city" => "city", "postcode" => "postcode", "state" => "state", "country" => "country", "phone" => "phone", "email" => "email"]; 
        foreach ($jXAfc as $JCdso => $xNuV3) { 
            $ilmCA = null; 
            if (empty($ilmCA) && false === empty($Y6_8b["shipping_{$JCdso}"])) { 
                $ilmCA = sanitize_text_field($Y6_8b["shipping_{$JCdso}"]); 
            } 
            if (empty($ilmCA) && false === empty($Y6_8b["billing_{$JCdso}"])) { 
                $ilmCA = sanitize_text_field($Y6_8b["billing_{$JCdso}"]); 
            } 
            if (empty($ilmCA)) { 
                $ilmCA = $this->customerProxy->{"get_shipping_{$JCdso}"}(); 
            } 
            if (empty($ilmCA)) { 
                $ilmCA = $this->customerProxy->{"get_billing_{$JCdso}"}(); 
            } 
            if (false === empty($ilmCA)) { 
                if (empty($GCSjq[$xNuV3])) { 
                    $GCSjq[$xNuV3] = ''; 
                } else { 
                    $GCSjq[$xNuV3] .= " "; 
                } 
                $GCSjq[$xNuV3] .= $ilmCA; 
            } 
            W5r_g: 
        } 
        Qmvcd: 
        if (empty($GCSjq["name"])) { 
            $GCSjq["name"] = "N/A"; 
        } 
        if (empty($GCSjq["phone"])) { 
            $GCSjq["phone"] = "10000000000"; 
        } 
        $this->logger->debug(__FILE__, 657, "getCustomerAddress -> %s", print_r($GCSjq, true)); 
        return $GCSjq; 
    } 
 
    protected function prepareParcel(array $xECMj, array $pLlsY): array 
    { 
        $tM2eU = 0; 
        if (false === empty($xECMj["seller_id"])) { 
            $tM2eU = $xECMj["seller_id"]; 
        } elseif (false === empty($xECMj["vendor_id"])) { 
            $tM2eU = $xECMj["vendor_id"]; 
        } 
        $pLlsY["vendor_id"] = $pLlsY["seller_id"] = $tM2eU; 
        $pLlsY["signature"] = $xECMj["signature"] ?? "no"; 
        $pLlsY["signature_type"] = $xECMj["signature_type"] ?? ''; 
        $pLlsY["insurance"] = $this->get_option("insurance", "no"); 
        $pLlsY["mediaMail"] = $xECMj["mediaMail"] ?? "exclude"; 
        $pLlsY["destination"] = $xECMj["destination"] ?? []; 
        $DSIzD = $this->getCustomerAddress(); 
        foreach ($pLlsY["destination"] as $dVYoF => $ilmCA) { 
            if (false === empty($ilmCA)) { 
                $DSIzD[$dVYoF] = $ilmCA; 
            } 
            jx1G1: 
        } 
        mLRrn: 
        $pLlsY["destination"] = $DSIzD; 
        $pLlsY["currency"] = apply_filters($this->id . "_getDefaultCurrency", ''); 
        return $pLlsY; 
    } 
 
    protected function combineRates(array $Hdu1c, array $NGhdD): array 
    { 
        $this->logger->debug(__FILE__, 706, "combineRates"); 
        $Hdu1c = $this->ratesMerger->merge($Hdu1c, $NGhdD); 
        $this->logger->debug(__FILE__, 710, "Combined Rates: %s", print_r($Hdu1c, true)); 
        return $Hdu1c; 
    } 
 
    protected function prepareShippingRates(array $Hdu1c): array 
    { 
        $this->logger->debug(__FILE__, 723, "prepareShippingRates"); 
        $Hdu1c = $this->ratesFilter->filter($Hdu1c); 
        foreach ($Hdu1c as $M7w4L => &$gt2pR) { 
            $gt2pR["meta_data"] = $this->rateMetaDataBuilder->withService($M7w4L)->build(); 
            AOjVH: 
        } 
        K_UAO: 
        return $Hdu1c; 
    } 
 
    protected function validate(array $dK4bD): bool 
    { 
        $GxTN_ = []; 
        if (empty($this->instance_id)) { 
            $GxTN_ = $this->getSettingsValidators()->validate($dK4bD); 
        } 
        if (false === empty($GxTN_)) { 
            $this->errors = array_merge([sprintf("<strong>%s %s</strong>", $this->adapter->getName(), __("Messages", $this->id))], $this->errors ?? [], $GxTN_); 
        } 
        return true; 
    } 
 
    protected function initPackagePropertiesBuilder(): void 
    { 
        $this->packagePropertiesBuilder = new PackagePropertiesBuilder($this->logger); 
    } 
 
    protected function initRatesFilter(): void 
    { 
        $this->ratesFilter = new RatesFilter($this->logger); 
    } 
 
    protected function getSettingsValidators(): SettingsValidators 
    { 
        $V4sCx = new SettingsValidators(); 
        $V4sCx->add(new AdapterRequirements($this->plugin)); 
        $V4sCx->add(new CacheRequirements($this->plugin)); 
        $V4sCx->add(new OriginRequirements($this->plugin)); 
        $V4sCx->add(new ShippingZones($this->plugin)); 
        $V4sCx->add(new ShippingZonesWithUseSellerAddress($this->plugin)); 
        $V4sCx->add(new ProductShippingRequirements($this->plugin)); 
        return $V4sCx; 
    } 
 
    protected function debug(string $i6b7j, string $rPw5R = "notice"): void 
    { 
        if (false === empty($this->settings["debug"]) && "yes" === $this->settings["debug"] && current_user_can("administrator")) { 
            wc_add_notice(sprintf("%s: %s", $this->method_title, $i6b7j), $rPw5R); 
        } 
    } 
 
    protected function getPluginId(): string 
    { 
        $k0J33 = explode("_", get_class($this), 2); 
        return str_replace("_", "-", $k0J33[1] ?? ''); 
    } 
 
    private function isSettingsPage(): bool 
    { 
        if (false === is_admin()) { 
            return false; 
        } 
        $izAi7 = false; 
        if (0 === $this->instance_id) { 
            if (isset($_GET["page"]) && isset($_GET["section"]) && "wc-settings" === $_GET["page"] && $this->id === $_GET["section"]) { 
                $izAi7 = true; 
            } 
        } elseif (intval($_GET["instance_id"] ?? 0) === $this->instance_id) { 
            $izAi7 = true; 
        } 
        return $izAi7; 
    } 
 
    public function init_settings() 
    { 
        $this->settings = (array)apply_filters($this->id . "_getPluginSettings", []); 
        if (empty($this->settings)) { 
            parent::init_settings(); 
        } 
    } 
 
    public function init_instance_settings() 
    { 
        if (isset($this->settings["shippingZones"]) && "yes" === $this->settings["shippingZones"]) { 
            parent::init_instance_settings(); 
        } else { 
            $this->instance_settings = []; 
        } 
    } 
 
    public function is_available($xECMj) 
    { 
        $this->logger->debug(__FILE__, 897, "is_available"); 
        $xECMj = $this->tryToFixPackage((array)$xECMj); 
        if (empty($xECMj["contents"])) { 
            $this->logger->debug(__FILE__, 901, "Package contents is still empty, so we can not continue"); 
            return false; 
        } 
        $this->syncSettings(); 
        $Cycba = false; 
        if ("yes" === $this->get_option("enableLiveShippingRates", "yes") || "yes" === $this->get_option("validateAddress", "no")) { 
            $Cycba = true; 
        } 
        $Cycba = apply_filters("woocommerce_shipping_" . $this->id . "_is_available", $Cycba, $xECMj, $this); 
        $this->logger->debug(__FILE__, 918, "Is shipping method available? " . ($Cycba ? "yes" : "no")); 
        return $Cycba; 
    } 
 
    public function calculate_shipping($xECMj = array()) 
    { 
        $this->logger->debug(__FILE__, 933, $this->method_title . " - Calculate Shipping, Instance ID " . $this->instance_id . ", weight unit: " . ($this->settings["weight_unit"] ?? '') . ", dimension unit: " . ($this->settings["dimension_unit"] ?? '')); 
        $xECMj = $this->tryToFixPackage((array)$xECMj); 
        if (empty($xECMj["contents"])) { 
            $this->logger->debug(__FILE__, 937, "Package contents is still empty, so we can not continue"); 
            return; 
        } 
        $xECMj += $this->packagePropertiesBuilder->getPackageProperties($xECMj["contents"]); 
        $this->logger->debug(__FILE__, 945, "Destination of the package: %s", print_r($xECMj["destination"], true)); 
        $LLX65 = $this->parcelPacker->pack($xECMj["contents"]); 
        $this->logger->debug(__FILE__, 949, "Number of parcels: " . count($LLX65)); 
        $Hdu1c = $this->findShippingRatesForParcels($xECMj, $LLX65); 
        foreach ($Hdu1c as $gt2pR) { 
            $this->logger->debug(__FILE__, 954, "Add rate: %s", print_r($gt2pR, true)); 
            $this->add_rate($gt2pR); 
            J3q2K: 
        } 
        s8d9G: 
    } 
} 
 ?>

Did this file decode correctly?

Original Code

<?php
declare (strict_types=1);

namespace OneTeamSoftware\WC\Shipping;

use OneTeamSoftware\LazyClassProxy\LazyClassProxy;
use OneTeamSoftware\WC\Shipping\Form\SettingsForm;
use OneTeamSoftware\WC\Shipping\ParcelInfoFormatter\ParcelInfoFormatter;
use OneTeamSoftware\WC\Shipping\SettingsValidator\AdapterRequirements;
use OneTeamSoftware\WC\Shipping\SettingsValidator\CacheRequirements;
use OneTeamSoftware\WC\Shipping\SettingsValidator\OriginRequirements;
use OneTeamSoftware\WC\Shipping\SettingsValidator\ProductShippingRequirements;
use OneTeamSoftware\WC\Shipping\SettingsValidator\SettingsValidators;
use OneTeamSoftware\WC\Shipping\SettingsValidator\ShippingZones;
use OneTeamSoftware\WC\Shipping\SettingsValidator\ShippingZonesWithUseSellerAddress;

class ShippingMethod extends AbstractShippingMethod
{
    protected $plugin;
    protected $pluginPath;
    protected $version;
    protected $adapter;
    protected $cache;
    protected $keyGenerator;
    protected $ratesFinder;
    protected $parcelPacker;
    protected $shipmentBuilder;
    protected $cartProxy;
    protected $countriesProxy;
    protected $customerProxy;
    protected $sessionProxy;
    protected $logger;
    protected $weightConverter;
    protected $dimensionConverter;
    protected $settingsForm;
    protected $packagePropertiesBuilder;
    protected $ratesFilter;
    protected $settingsValidators;
    protected $ratesMerger;
    protected $rateMetaDataBuilder;
    protected $parcelInfoFormatter;

    public function __construct(int $Q_ExN = 0)
    {
        $this->plugin = null;
        $saD2e = Plugin::getInstance($this->getPluginId());
        if (is_null($saD2e)) {
            return;
        }
        parent::__construct($Q_ExN);
        $this->instance_id = $Q_ExN;
        $this->plugin = $saD2e;
        $this->id = $saD2e->getPluginId();
        $this->pluginPath = $saD2e->getPluginPath();
        $this->version = $saD2e->getVersion();
        $this->adapter = $saD2e->getAdapter();
        $this->cache = $saD2e->getCache();
        $this->keyGenerator = $saD2e->getKeyGenerator();
        $this->method_title = $saD2e->getTitle();
        $this->method_description = $saD2e->getDescription();
        $this->logger = $saD2e->getLogger();
        $this->weightConverter = $saD2e->getWeightConverter();
        $this->dimensionConverter = $saD2e->getDimensionConverter();
        $this->parcelPacker = $saD2e->getParcelPacker();
        $this->shipmentBuilder = $saD2e->getShipmentBuilder();
        $this->supports = ["\163\x65\164\x74\x69\x6e\x67\x73"];
        $this->settingsForm = new SettingsForm($this->id, $saD2e->getLogExporter());
        $this->ratesMerger = new RatesMerger();
        $this->rateMetaDataBuilder = new RateMetaDataBuilder();
        $this->cartProxy = new LazyClassProxy("\127\103\137\103\141\162\164", WC()->cart);
        $this->countriesProxy = new LazyClassProxy("\127\103\137\103\157\x75\156\164\x72\x69\x65\163", WC()->countries);
        $this->customerProxy = new LazyClassProxy("\x57\x43\x5f\103\x75\163\164\157\155\x65\162", WC()->customer);
        $this->sessionProxy = new LazyClassProxy(apply_filters("\167\157\x6f\x63\x6f\155\x6d\145\162\143\145\x5f\163\x65\x73\x73\x69\157\x6e\137\x68\141\156\x64\x6c\145\x72", "\127\103\x5f\x53\x65\x73\x73\151\x6f\x6e\x5f\x48\x61\x6e\144\x6c\145\162"), WC()->session);
        $this->init();
    }

    public function enqueueScripts(): void
    {
        if (!$this->isSettingsPage()) {
            return;
        }
        $Ptc5J = "\155\151\156\x2e\143\163\x73";
        $R3SKf = "\155\x69\x6e\56\152\x73";
        if (defined("\127\120\137\104\x45\x42\x55\x47") && WP_DEBUG) {
            $Ptc5J = "\x63\x73\x73";
            $R3SKf = "\152\x73";
        }
        wp_register_style($this->id . "\55\163\167\x69\x74\143\x68\x69\x66\171", plugins_url("\x61\x73\x73\x65\164\x73\x2f\143\x73\163\57\163\x77\151\164\x63\150\151\146\171\x2e" . $Ptc5J, str_replace("\160\150\141\x72\72\57\57", '', $this->pluginPath)), [], $this->version);
        wp_enqueue_style($this->id . "\x2d\163\x77\151\x74\x63\x68\x69\146\x79");
        wp_register_script($this->id . "\55\x73\167\x69\x74\143\x68\x69\x66\171", plugins_url("\x61\163\x73\x65\x74\163\x2f\x6a\x73\x2f\x73\167\151\164\x63\x68\151\146\x79\56" . $R3SKf, str_replace("\x70\150\x61\162\72\x2f\x2f", '', $this->pluginPath)), ["\152\161\165\x65\x72\171"], $this->version);
        wp_enqueue_script($this->id . "\55\x73\167\151\x74\143\150\151\146\171");
        wp_register_style($this->id . "\x2d\x73\150\151\160\160\x69\156\147\x6d\145\x74\150\x6f\x64", plugins_url("\x61\163\163\x65\164\163\x2f\143\163\163\x2f\x53\150\x69\160\x70\151\x6e\x67\115\145\x74\x68\x6f\x64\56" . $Ptc5J, str_replace("\160\150\x61\162\x3a\57\x2f", '', $this->pluginPath)), ["\167\160\x2d\x6a\x71\x75\145\x72\x79\55\x75\151\x2d\x64\x69\141\154\157\x67"], $this->version);
        wp_enqueue_style($this->id . "\x2d\x73\x68\x69\x70\160\x69\156\147\155\x65\164\x68\157\x64");
        wp_register_script($this->id . "\55\163\x68\151\x70\160\151\156\x67\x6d\145\164\150\157\x64", plugins_url("\x61\x73\x73\145\x74\x73\x2f\x6a\163\x2f\123\150\151\x70\160\151\156\147\x4d\x65\164\x68\x6f\x64\x2e" . $R3SKf, str_replace("\160\x68\141\x72\x3a\x2f\57", '', $this->pluginPath)), ["\x6a\x71\x75\x65\162\x79", "\152\161\x75\145\x72\x79\55\x62\x6c\157\143\153\165\x69", "\x6a\x71\x75\x65\x72\x79\55\x75\151\55\144\x69\x61\154\157\147"], $this->version);
        wp_enqueue_script($this->id . "\x2d\163\x68\x69\x70\160\x69\x6e\147\x6d\x65\164\x68\157\x64");
        wp_register_script($this->id . "\55\x66\x6f\162\x6d\x2d\156\x61\x76\x69\147\141\x74\151\157\x6e\55\164\x61\x62\x73", plugins_url("\141\163\x73\x65\x74\163\57\x6a\163\x2f\x46\x6f\162\155\x4e\141\166\151\147\141\x74\x69\157\x6e\124\141\142\x73\x2e" . $R3SKf, str_replace("\x70\150\141\x72\72\x2f\57", '', $this->pluginPath)), [], $this->version);
        wp_enqueue_script($this->id . "\x2d\x66\157\x72\155\55\156\141\166\x69\x67\141\164\151\x6f\x6e\x2d\164\141\142\163");
        wp_register_script($this->id . "\x2d\146\157\162\155\55\x6e\x61\x76\151\147\x61\x74\151\157\x6e\55\x74\x61\x62\163\55\154\157\x61\144\x65\x72", plugins_url("\x61\163\x73\145\164\x73\x2f\152\163\57\x46\157\x72\155\116\x61\166\151\x67\x61\x74\x69\x6f\156\124\x61\142\163\114\x6f\141\144\x65\162\x2e" . $R3SKf, str_replace("\x70\150\141\162\x3a\57\x2f", '', $this->pluginPath)), [], $this->version);
        wp_enqueue_script($this->id . "\x2d\146\x6f\162\x6d\55\156\141\166\151\147\141\x74\151\157\156\55\x74\x61\142\163\x2d\x6c\x6f\x61\x64\x65\162");
    }

    protected function getProFeatureSuffix(): string
    {
        $hDW6r = sprintf("\x20\74\x73\x74\x72\x6f\156\147\x3e\x28\x25\163\40\x3c\x61\x20\150\162\x65\x66\75\42\x25\x73\x22\x20\164\141\162\x67\x65\x74\75\42\137\x62\154\x61\x6e\x6b\x22\76\45\163\74\x2f\141\x3e\51\74\x2f\x73\164\x72\157\x6e\147\76", __("\x52\145\161\x75\151\x72\145\x73", $this->id), "\x68\164\x74\x70\x73\72\x2f\x2f\61\x74\x65\x61\155\163\x6f\146\x74\167\141\162\145\56\143\x6f\x6d\57\160\162\x6f\144\165\143\164\x2f" . preg_replace("\x2f\167\x63\57", "\167\157\157\143\x6f\155\155\145\x72\x63\145", $this->id) . "\55\x70\x72\157\57", __("\120\122\x4f\x20\126\x65\162\x73\151\157\156", $this->id));
        return $hDW6r;
    }

    protected function getProFeatureAttributes(): array
    {
        $RJ20H = ["\144\151\163\x61\142\154\x65\144" => "\171\145\163"];
        return $RJ20H;
    }

    protected function init(): void
    {
        if (!function_exists("\x69\x73\x5f\160\154\x75\x67\151\156\137\141\x63\x74\151\x76\145")) {
            require_once ABSPATH . "\57\167\160\55\x61\x64\155\x69\x6e\x2f\x69\x6e\x63\x6c\165\x64\x65\x73\x2f\x70\x6c\165\x67\x69\x6e\x2e\160\x68\160";
        }
        $this->initRatesFilter();
        $this->initPackagePropertiesBuilder();
        do_action($this->id . "\137\x73\145\x74\x49\156\163\x74\141\x6e\x63\x65\x49\144", $this->instance_id);
        $this->initFormFields();
        $this->init_settings();
        $this->enqueueScripts();
        remove_all_actions("\167\157\157\x63\x6f\x6d\x6d\145\162\143\x65\x5f\165\x70\144\141\164\x65\x5f\x6f\x70\164\x69\x6f\156\163\137\x73\150\x69\160\160\151\x6e\x67\x5f" . $this->id);
        add_action("\167\x6f\157\143\157\x6d\x6d\x65\162\x63\145\137\x75\160\144\x61\x74\145\x5f\x6f\160\x74\151\157\x6e\163\x5f\163\x68\x69\x70\160\151\156\147\137" . $this->id, [$this, "\160\x72\157\143\x65\163\x73\x5f\141\x64\x6d\151\x6e\137\x6f\160\164\x69\157\156\x73"]);
        $this->title = $this->get_option("\164\151\x74\x6c\x65", $this->method_title);
        $this->enabled = "\x79\145\163";
        if ("\171\145\x73" === $this->get_option("\x73\x68\151\x70\x70\151\156\x67\132\x6f\156\x65\x73", "\x6e\x6f")) {
            $this->supports[] = "\x73\x68\x69\x70\160\151\x6e\147\x2d\x7a\x6f\x6e\x65\163";
        }
        $this->initRatesFinder();
        $this->initFormFields();
        $this->initParcelPacker();
        $this->parcelInfoFormatter = new ParcelInfoFormatter($this->id, $this->settings["\x64\151\x6d\x65\x6e\x73\x69\x6f\156\x5f\165\x6e\151\164"] ?? '', $this->settings["\x77\145\151\147\150\x74\x5f\165\x6e\x69\x74"] ?? '');
    }

    protected function initRatesFinder(): void
    {
        $this->ratesFinder = new ApiRatesFinder($this->id, $this->adapter, $this->shipmentBuilder, $this->logger, $this->get_settings());
    }

    protected function initParcelPacker(): void
    {
        $this->parcelPacker->setSettings($this->get_settings());
    }

    protected function initFormFields(): void
    {
        if (!function_exists("\151\163\x5f\160\x6c\x75\x67\x69\156\137\141\143\164\151\166\145")) {
            require_once ABSPATH . "\57\167\160\55\x61\144\155\151\x6e\x2f\x69\x6e\143\x6c\x75\144\145\x73\57\x70\x6c\x75\x67\151\x6e\x2e\x70\x68\160";
        }
        $this->instance_form_fields = [];
        $this->settingsForm->setSettings($this->settings);
        $this->settingsForm->setProFeatureSuffix($this->getProFeatureSuffix());
        $this->settingsForm->setProFeatureAttributes($this->getProFeatureAttributes());
        $this->form_fields = $this->settingsForm->getFields();
        $this->form_fields = apply_filters($this->id . "\x5f\151\x6e\151\164\137\146\x6f\x72\155\137\x66\x69\x65\154\x64\163", $this->form_fields);
    }

    protected function tryToFixPackage(array $xECMj): array
    {
        if (false === empty($xECMj) && false === empty($xECMj["\x63\157\x6e\164\x65\156\164\163"])) {
            return $xECMj;
        }
        $this->logger->debug(__FILE__, 392, "\120\x61\143\153\141\x67\x65\40\x63\x6f\x6e\x74\x65\x6e\164\x73\x20\151\163\x20\145\x6d\x70\x74\171\x2c\x20\x6c\145\x74\163\x20\x74\x72\171\40\164\157\x20\165\x73\145\x20\x63\157\x6e\x74\x65\x6e\164\163\40\157\x66\40\x74\x68\x65\40\143\x61\x72\x74");
        if (empty($xECMj)) {
            $xECMj = [];
        }
        $xECMj["\143\x6f\x6e\x74\145\x6e\x74\x73"] = $this->cartProxy->get_cart();
        return $xECMj;
    }

    protected function syncSettings(): void
    {
        $this->logger->debug(__FILE__, 410, "\163\x79\x6e\143\123\x65\164\x74\x69\x6e\147\163");
        $this->logger->debug(__FILE__, 412, "\x47\x65\156\x65\162\x61\154\40\123\145\x74\164\151\156\147\x73\x3a\x20\x25\x73", print_r($this->settings, true));
        if (false === empty($this->instance_id) && is_array($this->instance_settings)) {
            $this->logger->debug(__FILE__, 414, "\111\156\x73\x74\141\x6e\x63\145\x20\123\145\164\x74\151\156\147\163\x3a\40\45\x73", print_r($this->instance_settings, true));
        }
        $dK4bD = $this->get_settings();
        $this->adapter->init($dK4bD)->wait();
        $this->parcelPacker->setSettings($dK4bD);
        $this->packagePropertiesBuilder->setSettings($dK4bD);
        $this->ratesFilter->setSettings($dK4bD);
        $this->ratesFinder->setSettings($dK4bD);
    }

    protected function displayValidationErrors(?array $fOhpy): void
    {
        $this->logger->debug(__FILE__, 434, "\104\151\163\160\x6c\x61\171\x20\126\141\x6c\x69\x64\141\x74\151\157\156\x20\105\162\x72\157\x72\163");
        if (empty($fOhpy)) {
            return;
        }
        foreach ($fOhpy as $BqmGR => $GxTN_) {
            $sIY2U = '';
            if ("\x6f\162\x69\147\151\156" === $BqmGR) {
                $sIY2U = __("\x46\162\157\x6d\x20\101\144\144\162\x65\x73\163\x3a\x20", $this->id);
            } elseif ("\144\145\x73\x74\151\x6e\141\164\x69\157\x6e" === $BqmGR) {
                $sIY2U = __("\124\x6f\40\x41\144\144\x72\x65\x73\163\x3a\x20", $this->id);
            }
            foreach ($GxTN_ as $uuWop) {
                wc_add_notice($sIY2U . $uuWop, "\x65\x72\162\x6f\x72");
                EHKKQ:
            }
            QxO60: OZsdd:
        }
        AGMyl:
    }

    protected function findShippingRatesForParcels(array $xECMj, array $LLX65): array
    {
        $this->logger->debug(__FILE__, 463, "\x66\x69\156\x64\123\x68\151\x70\160\x69\156\x67\122\141\x74\x65\163\x46\157\162\x50\x61\x72\x63\145\154\x73");
        $Hdu1c = [];
        foreach ($LLX65 as $AACCr => $pLlsY) {
            $this->logger->debug(__FILE__, 467, "\x46\x69\x6e\144\x20\x73\150\151\160\x70\151\x6e\147\40\162\141\164\x65\x20\146\x6f\x72\x20\160\141\162\x63\145\154\40\x23" . $AACCr);
            $this->debug(sprintf("\x3c\142\162\x3e\74\163\164\162\157\156\147\x3e\x25\x73\40\x23\x25\x73\x3a\x3c\57\163\164\162\x6f\156\147\x3e\74\142\x72\x2f\x3e\x25\x73\74\x2f\142\162\x3e", __("\120\x61\162\143\x65\x6c", $this->id), $AACCr + 1, $this->parcelInfoFormatter->formatParcel($pLlsY)));
            $pLlsY = $this->prepareParcel($xECMj, $pLlsY);
            $NGhdD = $this->findShippingRates($xECMj, $pLlsY);
            if ($AACCr > 0) {
                $Hdu1c = $this->combineRates($Hdu1c, $NGhdD);
            } else {
                $Hdu1c = $NGhdD;
            }
            gulsF:
        }
        a6Ntx:
        return $Hdu1c;
    }

    protected function findShippingRates(array $xECMj, array $pLlsY): array
    {
        $this->logger->debug(__FILE__, 499, "\146\151\x6e\x64\123\150\151\160\x70\x69\156\x67\x52\x61\x74\x65\163\72\40\x25\163", print_r($pLlsY, true));
        $this->rateMetaDataBuilder->withParcel($pLlsY);
        $T_PFB = $this->keyGenerator->getKey($pLlsY);
        $Hdu1c = $this->cache->get($T_PFB);
        $LGayx = $T_PFB . "\x5f\x65\162\x72\157\162\x4d\145\x73\163\141\147\145";
        $CvFbJ = $this->cache->get($LGayx);
        $icEC5 = $T_PFB . "\x5f\166\141\154\x69\x64\141\164\x69\x6f\x6e\105\162\x72\157\162\163";
        $fOhpy = $this->cache->get($icEC5);
        if (is_array($Hdu1c)) {
            $this->logger->debug(__FILE__, 513, "\x43\x61\x63\150\x65\x64\x20\x73\x68\x69\160\160\151\156\147\40\162\x61\x74\x65\163\x20\150\x61\x76\145\x20\142\145\x65\156\x20\146\x6f\165\x6e\144");
        } else {
            $Hdu1c = $this->ratesFinder->findShippingRates($pLlsY);
            $this->cache->set($T_PFB, $Hdu1c);
            $CvFbJ = $this->ratesFinder->getError();
            $this->cache->set($LGayx, $CvFbJ);
            $fOhpy = $this->ratesFinder->getValidationErrors();
            $this->cache->set($icEC5, $fOhpy);
        }
        if (empty($Hdu1c)) {
            $this->logger->debug(__FILE__, 526, "\116\x6f\40\163\150\151\x70\x70\151\156\x67\x20\162\141\x74\145\163\40\x68\x61\x76\x65\40\142\x65\x65\x6e\x20\146\157\165\x6e\x64");
        }
        if (false === empty($CvFbJ)) {
            $this->logger->debug(__FILE__, 530, "\x45\162\x72\x6f\x72\40\x4d\145\163\x73\x61\147\x65\x3a\40\45\163", $CvFbJ);
            $this->debug($CvFbJ);
        }
        $this->logger->debug(__FILE__, 534, "\126\141\154\x69\144\141\x74\151\157\x6e\40\x45\x72\162\157\x72\x73\x3a\40\x25\163", print_r($fOhpy, true));
        $this->sessionProxy->set($this->id . "\137\x76\141\154\151\144\141\164\x69\x6f\156\x45\162\x72\157\162\163", $fOhpy);
        if ("\x79\x65\x73" === $this->get_option("\145\x6e\141\142\x6c\145\x4c\x69\166\145\123\x68\x69\x70\160\x69\156\x67\x52\x61\x74\145\163", "\171\145\163")) {
            $Hdu1c = $this->prepareShippingRates($Hdu1c);
            $this->logger->debug(__FILE__, 541, "\x52\x61\164\x65\x73\72\40\45\163", print_r($Hdu1c, true));
        } else {
            $Hdu1c = [];
        }
        return $Hdu1c;
    }

    protected function displayDebugParcelInfo(array $pLlsY): void
    {
        $this->logger->debug(__FILE__, 557, "\x50\x61\162\x63\x65\x6c\72\x20\45\x73", print_r($pLlsY, true));
        $M5fcX = [__("\120\141\162\x63\x65\154", $this->id) => $pLlsY["\151\x64"], __("\x4c\x65\156\x67\x74\150", $this->id) => $pLlsY["\154\x65\156\147\x74\x68"], __("\x57\x69\144\x74\x68", $this->id) => $pLlsY["\167\151\x64\164\150"], __("\x48\x65\x69\147\150\x74", $this->id) => $pLlsY["\150\x65\x69\147\x68\x74"], __("\127\x65\151\147\x68\x74", $this->id) => $pLlsY["\167\x65\151\x67\150\x74"], __("\127\x65\x69\147\x68\x74\x20\125\x6e\151\x74", $this->id) => $pLlsY["\x77\x65\151\x67\150\x74\137\165\x6e\151\x74"], __("\x44\151\x6d\145\156\163\151\157\156\40\125\x6e\151\x74", $this->id) => $pLlsY["\144\151\x6d\145\156\163\x69\x6f\x6e\137\x75\156\x69\x74"], __("\123\x69\147\x6e\x61\164\165\x72\145", $this->id) => $pLlsY["\x73\151\x67\156\x61\x74\x75\x72\x65"], __("\x53\151\x67\x6e\141\x74\x75\162\x65\x20\x54\171\x70\145", $this->id) => $pLlsY["\163\151\x67\156\x61\164\165\162\145\x5f\164\171\x70\145"], __("\x49\x6e\x73\165\x72\x61\x6e\143\145", $this->id) => $pLlsY["\x69\156\x73\x75\x72\141\x6e\x63\x65"], __("\115\145\x64\151\x61\x20\115\x61\x69\154", $this->id) => $pLlsY["\155\145\144\151\141\115\x61\x69\154"], __("\x56\x65\x6e\144\x6f\x72\40\111\x44", $this->id) => $pLlsY["\166\145\x6e\x64\x6f\x72\137\x69\144"], __("\x53\145\x6c\154\145\x72\40\111\x44", $this->id) => $pLlsY["\163\145\x6c\154\x65\162\x5f\151\x64"], __("\103\x75\162\x72\x65\x6e\143\x79", $this->id) => $pLlsY["\x63\165\x72\162\x65\x6e\x63\x79"], __("\104\x65\163\164\151\x6e\x61\x74\151\x6f\x6e", $this->id) => $pLlsY["\x64\145\x73\164\x69\x6e\x61\164\151\157\156"]];
        $this->logger->debug(__FILE__, 577, "\120\141\x72\143\145\154\40\111\x6e\146\x6f\72\40\x25\x73", print_r($M5fcX, true));
    }

    protected function getCustomerAddress(): array
    {
        $GCSjq = [];
        $Y6_8b = [];
        if (false === empty($_POST["\x70\157\x73\164\137\144\x61\164\x61"])) {
            parse_str(wp_unslash($_POST["\160\x6f\163\164\137\144\141\x74\x61"]), $Y6_8b);
            if (empty($Y6_8b)) {
                $Y6_8b = [];
            } else {
                $Y6_8b = wc_clean($Y6_8b);
            }
            $this->logger->debug(__FILE__, 602, "\x50\157\x73\x74\145\x64\40\x64\x61\x74\141\x3a\40\45\x73", print_r($Y6_8b, true));
        }
        $jXAfc = ["\x66\151\162\x73\x74\137\156\x61\x6d\x65" => "\x6e\141\x6d\x65", "\154\141\163\x74\x5f\156\x61\155\145" => "\x6e\x61\x6d\x65", "\x63\x6f\x6d\x70\141\x6e\171" => "\x63\157\x6d\160\x61\x6e\171", "\x61\144\144\162\145\x73\163\137\61" => "\x61\144\x64\x72\145\x73\x73", "\x61\144\x64\162\x65\163\x73\x5f\x32" => "\141\x64\144\x72\x65\x73\x73\x5f\62", "\x63\151\x74\171" => "\x63\x69\164\171", "\x70\157\163\x74\x63\157\144\145" => "\x70\x6f\x73\x74\143\157\144\x65", "\163\x74\x61\164\x65" => "\x73\164\x61\x74\145", "\x63\157\165\156\x74\x72\171" => "\x63\157\165\x6e\164\162\171", "\160\x68\157\x6e\145" => "\x70\x68\x6f\156\x65", "\x65\x6d\x61\151\x6c" => "\145\x6d\x61\x69\154"];
        foreach ($jXAfc as $JCdso => $xNuV3) {
            $ilmCA = null;
            if (empty($ilmCA) && false === empty($Y6_8b["\163\150\x69\x70\x70\151\156\147\137{$JCdso}"])) {
                $ilmCA = sanitize_text_field($Y6_8b["\163\x68\151\x70\x70\x69\x6e\x67\x5f{$JCdso}"]);
            }
            if (empty($ilmCA) && false === empty($Y6_8b["\x62\x69\154\x6c\151\156\147\137{$JCdso}"])) {
                $ilmCA = sanitize_text_field($Y6_8b["\x62\x69\154\154\151\156\x67\137{$JCdso}"]);
            }
            if (empty($ilmCA)) {
                $ilmCA = $this->customerProxy->{"\x67\145\x74\x5f\x73\150\x69\x70\x70\x69\156\147\x5f{$JCdso}"}();
            }
            if (empty($ilmCA)) {
                $ilmCA = $this->customerProxy->{"\x67\145\x74\x5f\142\x69\154\154\151\x6e\x67\x5f{$JCdso}"}();
            }
            if (false === empty($ilmCA)) {
                if (empty($GCSjq[$xNuV3])) {
                    $GCSjq[$xNuV3] = '';
                } else {
                    $GCSjq[$xNuV3] .= "\40";
                }
                $GCSjq[$xNuV3] .= $ilmCA;
            }
            W5r_g:
        }
        Qmvcd:
        if (empty($GCSjq["\156\x61\x6d\145"])) {
            $GCSjq["\156\x61\x6d\x65"] = "\x4e\x2f\101";
        }
        if (empty($GCSjq["\x70\x68\x6f\156\145"])) {
            $GCSjq["\160\150\x6f\156\145"] = "\x31\x30\60\x30\x30\x30\x30\60\60\60\x30";
        }
        $this->logger->debug(__FILE__, 657, "\x67\x65\164\x43\165\x73\164\157\155\145\x72\x41\144\x64\x72\x65\163\163\40\55\x3e\40\45\163", print_r($GCSjq, true));
        return $GCSjq;
    }

    protected function prepareParcel(array $xECMj, array $pLlsY): array
    {
        $tM2eU = 0;
        if (false === empty($xECMj["\x73\x65\154\154\145\x72\x5f\151\x64"])) {
            $tM2eU = $xECMj["\163\145\154\154\x65\162\137\x69\144"];
        } elseif (false === empty($xECMj["\x76\145\x6e\x64\157\162\137\151\x64"])) {
            $tM2eU = $xECMj["\x76\x65\x6e\x64\157\x72\137\151\144"];
        }
        $pLlsY["\x76\145\156\x64\x6f\x72\x5f\151\x64"] = $pLlsY["\163\145\x6c\154\x65\x72\137\151\144"] = $tM2eU;
        $pLlsY["\163\151\x67\x6e\141\164\165\x72\x65"] = $xECMj["\x73\x69\x67\156\141\x74\x75\x72\x65"] ?? "\156\157";
        $pLlsY["\x73\x69\x67\x6e\x61\164\x75\162\x65\137\x74\171\160\145"] = $xECMj["\x73\151\147\156\141\164\165\x72\145\137\x74\x79\160\x65"] ?? '';
        $pLlsY["\x69\x6e\163\x75\x72\141\156\x63\x65"] = $this->get_option("\151\x6e\163\165\x72\141\156\x63\x65", "\156\157");
        $pLlsY["\155\145\x64\151\141\115\141\151\154"] = $xECMj["\x6d\x65\x64\151\141\x4d\141\151\x6c"] ?? "\x65\x78\143\x6c\x75\144\x65";
        $pLlsY["\x64\145\163\x74\151\156\141\x74\151\x6f\x6e"] = $xECMj["\x64\145\x73\x74\151\x6e\141\x74\151\157\x6e"] ?? [];
        $DSIzD = $this->getCustomerAddress();
        foreach ($pLlsY["\x64\x65\x73\164\x69\x6e\x61\164\151\157\156"] as $dVYoF => $ilmCA) {
            if (false === empty($ilmCA)) {
                $DSIzD[$dVYoF] = $ilmCA;
            }
            jx1G1:
        }
        mLRrn:
        $pLlsY["\x64\x65\163\164\151\156\141\x74\151\157\x6e"] = $DSIzD;
        $pLlsY["\143\x75\x72\x72\145\x6e\143\x79"] = apply_filters($this->id . "\137\x67\145\164\x44\x65\x66\x61\165\154\164\103\165\162\162\x65\156\x63\171", '');
        return $pLlsY;
    }

    protected function combineRates(array $Hdu1c, array $NGhdD): array
    {
        $this->logger->debug(__FILE__, 706, "\x63\x6f\155\x62\x69\x6e\x65\122\141\164\145\x73");
        $Hdu1c = $this->ratesMerger->merge($Hdu1c, $NGhdD);
        $this->logger->debug(__FILE__, 710, "\103\157\155\x62\151\x6e\x65\144\40\122\141\x74\x65\163\72\40\x25\x73", print_r($Hdu1c, true));
        return $Hdu1c;
    }

    protected function prepareShippingRates(array $Hdu1c): array
    {
        $this->logger->debug(__FILE__, 723, "\x70\x72\145\160\x61\162\145\x53\150\151\x70\x70\151\156\x67\x52\141\164\145\x73");
        $Hdu1c = $this->ratesFilter->filter($Hdu1c);
        foreach ($Hdu1c as $M7w4L => &$gt2pR) {
            $gt2pR["\155\x65\164\x61\x5f\144\141\x74\141"] = $this->rateMetaDataBuilder->withService($M7w4L)->build();
            AOjVH:
        }
        K_UAO:
        return $Hdu1c;
    }

    protected function validate(array $dK4bD): bool
    {
        $GxTN_ = [];
        if (empty($this->instance_id)) {
            $GxTN_ = $this->getSettingsValidators()->validate($dK4bD);
        }
        if (false === empty($GxTN_)) {
            $this->errors = array_merge([sprintf("\74\x73\164\162\157\156\147\76\45\163\x20\45\x73\x3c\x2f\163\164\162\157\156\x67\x3e", $this->adapter->getName(), __("\115\145\163\x73\x61\147\145\163", $this->id))], $this->errors ?? [], $GxTN_);
        }
        return true;
    }

    protected function initPackagePropertiesBuilder(): void
    {
        $this->packagePropertiesBuilder = new PackagePropertiesBuilder($this->logger);
    }

    protected function initRatesFilter(): void
    {
        $this->ratesFilter = new RatesFilter($this->logger);
    }

    protected function getSettingsValidators(): SettingsValidators
    {
        $V4sCx = new SettingsValidators();
        $V4sCx->add(new AdapterRequirements($this->plugin));
        $V4sCx->add(new CacheRequirements($this->plugin));
        $V4sCx->add(new OriginRequirements($this->plugin));
        $V4sCx->add(new ShippingZones($this->plugin));
        $V4sCx->add(new ShippingZonesWithUseSellerAddress($this->plugin));
        $V4sCx->add(new ProductShippingRequirements($this->plugin));
        return $V4sCx;
    }

    protected function debug(string $i6b7j, string $rPw5R = "\156\x6f\164\x69\143\x65"): void
    {
        if (false === empty($this->settings["\x64\145\x62\x75\147"]) && "\171\145\163" === $this->settings["\x64\x65\142\x75\x67"] && current_user_can("\x61\x64\x6d\151\x6e\x69\x73\164\x72\141\164\x6f\x72")) {
            wc_add_notice(sprintf("\x25\x73\72\x20\x25\163", $this->method_title, $i6b7j), $rPw5R);
        }
    }

    protected function getPluginId(): string
    {
        $k0J33 = explode("\137", get_class($this), 2);
        return str_replace("\137", "\x2d", $k0J33[1] ?? '');
    }

    private function isSettingsPage(): bool
    {
        if (false === is_admin()) {
            return false;
        }
        $izAi7 = false;
        if (0 === $this->instance_id) {
            if (isset($_GET["\x70\141\147\x65"]) && isset($_GET["\163\145\143\164\151\157\x6e"]) && "\167\x63\x2d\x73\x65\164\x74\151\x6e\147\x73" === $_GET["\x70\x61\x67\x65"] && $this->id === $_GET["\163\x65\143\x74\151\157\156"]) {
                $izAi7 = true;
            }
        } elseif (intval($_GET["\151\156\163\164\141\x6e\143\x65\x5f\151\144"] ?? 0) === $this->instance_id) {
            $izAi7 = true;
        }
        return $izAi7;
    }

    public function init_settings()
    {
        $this->settings = (array)apply_filters($this->id . "\x5f\x67\145\x74\x50\x6c\x75\x67\151\x6e\x53\x65\x74\x74\x69\x6e\x67\x73", []);
        if (empty($this->settings)) {
            parent::init_settings();
        }
    }

    public function init_instance_settings()
    {
        if (isset($this->settings["\163\x68\x69\x70\x70\151\156\147\132\x6f\x6e\145\163"]) && "\x79\145\x73" === $this->settings["\x73\150\151\160\x70\151\156\147\x5a\157\156\145\163"]) {
            parent::init_instance_settings();
        } else {
            $this->instance_settings = [];
        }
    }

    public function is_available($xECMj)
    {
        $this->logger->debug(__FILE__, 897, "\x69\163\137\141\x76\x61\151\x6c\141\x62\154\x65");
        $xECMj = $this->tryToFixPackage((array)$xECMj);
        if (empty($xECMj["\143\x6f\x6e\164\x65\156\164\x73"])) {
            $this->logger->debug(__FILE__, 901, "\120\x61\143\153\x61\147\145\x20\143\x6f\156\x74\145\156\164\x73\40\x69\x73\x20\163\x74\x69\x6c\x6c\40\x65\x6d\160\x74\171\54\x20\163\157\40\167\x65\40\143\x61\156\x20\156\157\164\x20\143\x6f\x6e\164\x69\x6e\x75\x65");
            return false;
        }
        $this->syncSettings();
        $Cycba = false;
        if ("\x79\x65\x73" === $this->get_option("\x65\156\x61\x62\x6c\x65\x4c\151\166\145\x53\x68\x69\x70\x70\x69\156\147\x52\141\164\145\x73", "\171\x65\163") || "\171\145\163" === $this->get_option("\x76\141\x6c\151\144\141\x74\x65\x41\x64\144\x72\x65\163\163", "\156\157")) {
            $Cycba = true;
        }
        $Cycba = apply_filters("\167\x6f\x6f\x63\x6f\155\x6d\x65\x72\143\x65\137\x73\x68\x69\160\160\151\x6e\x67\137" . $this->id . "\137\151\163\137\141\x76\141\x69\154\141\142\x6c\145", $Cycba, $xECMj, $this);
        $this->logger->debug(__FILE__, 918, "\x49\163\40\x73\x68\x69\160\160\x69\x6e\x67\40\155\x65\164\150\157\144\40\141\166\x61\x69\154\x61\x62\x6c\145\x3f\40" . ($Cycba ? "\x79\145\163" : "\156\x6f"));
        return $Cycba;
    }

    public function calculate_shipping($xECMj = array())
    {
        $this->logger->debug(__FILE__, 933, $this->method_title . "\x20\x2d\40\103\141\154\143\x75\x6c\141\164\x65\40\123\x68\151\160\x70\151\x6e\x67\x2c\x20\111\x6e\x73\164\x61\156\143\x65\x20\x49\104\40" . $this->instance_id . "\54\40\167\145\151\147\150\x74\40\165\x6e\x69\164\72\x20" . ($this->settings["\x77\x65\x69\147\150\164\x5f\165\x6e\x69\164"] ?? '') . "\x2c\x20\x64\x69\155\x65\156\163\x69\x6f\156\40\x75\156\x69\x74\72\40" . ($this->settings["\x64\x69\x6d\145\156\163\151\157\156\x5f\165\x6e\x69\164"] ?? ''));
        $xECMj = $this->tryToFixPackage((array)$xECMj);
        if (empty($xECMj["\x63\157\x6e\164\x65\156\164\x73"])) {
            $this->logger->debug(__FILE__, 937, "\120\141\x63\x6b\x61\x67\145\40\x63\157\x6e\164\x65\156\164\163\x20\151\163\x20\x73\164\151\154\x6c\40\x65\x6d\x70\164\171\x2c\x20\x73\157\x20\x77\145\40\143\141\156\40\156\x6f\164\x20\143\157\x6e\x74\151\156\165\x65");
            return;
        }
        $xECMj += $this->packagePropertiesBuilder->getPackageProperties($xECMj["\x63\x6f\156\x74\145\x6e\164\x73"]);
        $this->logger->debug(__FILE__, 945, "\104\145\x73\x74\x69\156\141\x74\151\157\x6e\x20\157\x66\40\164\x68\x65\x20\160\x61\x63\153\x61\x67\x65\x3a\40\45\x73", print_r($xECMj["\x64\145\163\164\x69\x6e\x61\x74\151\157\156"], true));
        $LLX65 = $this->parcelPacker->pack($xECMj["\143\157\156\x74\x65\156\x74\x73"]);
        $this->logger->debug(__FILE__, 949, "\x4e\165\155\x62\x65\x72\x20\x6f\146\40\x70\141\x72\143\145\154\x73\72\40" . count($LLX65));
        $Hdu1c = $this->findShippingRatesForParcels($xECMj, $LLX65);
        foreach ($Hdu1c as $gt2pR) {
            $this->logger->debug(__FILE__, 954, "\x41\144\x64\40\162\141\x74\145\x3a\40\45\x73", print_r($gt2pR, true));
            $this->add_rate($gt2pR);
            J3q2K:
        }
        s8d9G:
    }
}

Function Calls

None

Variables

None

Stats

MD5 69cb27fde141290aed8f3e16e290d6cb
Eval Count 0
Decode Time 66 ms