<?php

namespace BWDK\Support;

class Constant
{

    const META_BWDK_UUID = '_bwdk_order_uuid';
    const META_BWDK_ASSIGN_URL = '_bwdk_order_assign_url';
    const META_BWDK_CB_URL = '_bwdk_order_callback_url';
    const META_BWDK_JSON_CB = '_bwdk_order_json_cb';
    const META_BWDK_WOO_ORDER_UUID = '_bwdk_woo_order_uuid';
    const META_BWDK_REFUND_STATUS = '_bwdk_refund_status';
    const META_BWDK_SINGLE_FLOW = '_bwdk_single_flow';
    const BWDK_OPTION_NAME = 'bwdk_options';
    /** DigiExpress admin UI (order screen meta box, actions, notices). Default off when unset. */
    const OPTION_BWDK_ENABLE_DIGIEXPRESS = 'bwdk_enable_digiexpress';
    const BWDK_CB_URL = '/bwdk-callback/';

    // Phone format option
    const OPT_PHONE_FORMAT = 'phone_format'; // Values: with_zero | no_zero | country_plus | country_no_plus

    // User meta keys
    const META_PHONE_E164 = '_bwdk_phone_e164';       // Reference: 98912xxxxxxx
    const META_AUTO_CREATED = '_bwdk_auto_created';   // 1 if user was auto-created
    const META_USER_ATTACHED = '_bwdk_user_attached'; // 1 if order was already attached to user

    const RIAL = "IRR";
    const TOMAN = "IRT";


    public function __construct()
    {
        $this->defineConstants();
    }

    protected function defineConstants(): void
    {
        $path = trailingslashit(plugin_dir_path(dirname(__FILE__, 2)));
        $url = trailingslashit(plugin_dir_url(dirname(__FILE__, 2)));

        $this->define('BWDK_PATH', $path);
        $this->define('BWDK_URL', $url);

        // Assets - Admin
        $this->define('BWDK_ADMIN_CSS', $url . 'assets/admin/css/');
        $this->define('BWDK_ADMIN_JS', $url . 'assets/admin/js/');
        $this->define('BWDK_ADMIN_IMG', $url . 'assets/admin/img/');
        $this->define('BWDK_ADMIN_FONTS', $url . 'assets/admin/fonts/');

        // Assets - Public
        $this->define('BWDK_PUBLIC_CSS', $url . 'assets/public/css/');
        $this->define('BWDK_PUBLIC_JS', $url . 'assets/public/js/');
        $this->define('BWDK_PUBLIC_IMG', $url . 'assets/public/img/');
        $this->define('BWDK_PUBLIC_FONTS', $url . 'assets/public/fonts/');

        // Template paths (PHP files)
        $this->define('BWDK_ADMIN_TEMPLATE', $path . 'src/Admin/Views/');
        $this->define('BWDK_FRONT_TEMPLATE', $path . 'src/Front/Views/');



        if(!defined('BWDK_STORE_CURRENCY')){
            define('BWDK_STORE_CURRENCY', get_woocommerce_currency());
        }

        if(!defined('BWDK_STORE_GET_PRICE_DECIMALS')){
            define('BWDK_STORE_GET_PRICE_DECIMALS', wc_get_price_decimals());
        }


    }

    protected function define(string $name, string $value): void
    {
        if (!defined($name)) {
            define($name, $value);
        }
    }
}
