<?php
/**
 * Cryptoniq Options — config array.
 *
 * Loaded by admin/index.php and passed to Cryptoniq_Options::register().
 * Storage format is preserved from the previous Redux-based config:
 * one option row (`cryptoniq_option`), keyed by the field IDs below.
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit();
}

require_once CRYPTONIQ_DIR_PATH . 'admin/validators.php';
require_once CRYPTONIQ_DIR_PATH . 'admin/webhooks.php';

$cryptoniq_is_pro_mode = function_exists( 'cryptoniq_is_pro' ) && cryptoniq_is_pro();

$cryptoniq_sections = array(

        // ------------------------------------------------- License
        'tab_license' => array(
            'title'  => esc_html__( 'License', 'cryptoniq-pro' ),
            'icon'   => 'icon ion-md-key',
            'fields' => array(
                array(
                    'id'                => 'license_key',
                    'type'              => 'text',
                    'title'             => esc_html__( 'License Key', 'cryptoniq-pro' ),
                    'subtitle'          => sprintf(
                        esc_html__( 'Get license key from %1$s', 'cryptoniq-pro' ),
                        '<a class="cryptoniq-options-link" href="https://cryptoniq.io" target="_blank">' .
                            esc_html__( 'here!', 'cryptoniq-pro' ) .
                        '</a>'
                    ),
                    'validate_callback' => 'cryptoniq_license_validate',
                ),
            ),
        ),

        // ------------------------------------------------- Coins
        'tab_coins' => cryptoniq_options_build_coins_section(),

        // ------------------------------------------------- Wallets
        'tab_wallets' => array(
            'title' => esc_html__( 'Wallets', 'cryptoniq-pro' ),
            'icon'  => 'icon ion-md-wallet',
            'desc'  => sprintf(
                /* translators: %d: max number of wallet addresses */
                esc_html__( 'Up to %d addresses combined across all coins', 'cryptoniq-pro' ),
                cryptoniq_wallet_limit()
            ) . ' <span class="cn-wallet-counter" aria-live="polite"></span>',
            'fields' => cryptoniq_options_build_wallet_fields(),
        ),

        // ------------------------------------------------- Prices
        'tab_prices' => array(
            'title'  => esc_html__( 'Prices', 'cryptoniq-pro' ),
            'icon'   => 'icon ion-md-cash',
            'fields' => array(
                array(
                    'id'       => 'price_coin_show',
                    'type'     => 'switch',
                    'title'    => esc_html__( 'Show coin prices', 'cryptoniq-pro' ),
                    'subtitle' => esc_html__( 'Add coin calculated prices near products prices.', 'cryptoniq-pro' ),
                    'default'  => true,
                ),
                array(
                    'id'       => 'price_coin_ticker',
                    'type'     => 'image_radio',
                    'title'    => esc_html__( 'Coin', 'cryptoniq-pro' ),
                    'options'  => cryptoniq_options_build_price_coin_options(),
                    'default'  => 'BTC',
                    'required' => array( 'price_coin_show', '=', '1' ),
                ),
                array(
                    'id'       => 'price_coin_sign',
                    'type'     => 'select',
                    'title'    => esc_html__( 'Sign', 'cryptoniq-pro' ),
                    'options'  => array(
                        'text' => esc_html__( 'Text', 'cryptoniq-pro' ),
                        'icon' => esc_html__( 'Icon', 'cryptoniq-pro' ),
                    ),
                    'default'  => 'icon',
                    'validate' => 'not_empty',
                    'required' => array( 'price_coin_show', '=', '1' ),
                ),
                array(
                    'id'       => 'price_coin_divider',
                    'type'     => 'text',
                    'title'    => esc_html__( 'Divider', 'cryptoniq-pro' ),
                    'default'  => '/',
                    'required' => array( 'price_coin_show', '=', '1' ),
                ),
            ),
        ),

        // ------------------------------------------------- Payment
        'tab_payment' => array(
            'title'  => esc_html__( 'Payment', 'cryptoniq-pro' ),
            'icon'   => 'icon ion-md-cart',
            'fields' => array(
                array(
                    'id'       => 'order_status',
                    'type'     => 'select',
                    'title'    => esc_html__( 'Order Status', 'cryptoniq-pro' ),
                    'subtitle' => esc_html__( 'Select status for order after completed payment', 'cryptoniq-pro' ),
                    'options'  => array(
                        'processing' => 'Processing',
                        'completed'  => 'Completed',
                        'on-hold'    => 'On Hold',
                    ),
                    'default'  => 'processing',
                ),
            ),
        ),

        // ------------------------------------------------- Titles
        'tab_titles' => array(
            'title'  => esc_html__( 'Titles', 'cryptoniq-pro' ),
            'icon'   => 'icon ion-md-list-box',
            'fields' => array(
                array(
                    'id'       => 'description',
                    'type'     => 'textarea',
                    'title'    => esc_html__( 'Description', 'cryptoniq-pro' ),
                    'subtitle' => esc_html__( "Write some description for this payment type. It will be shown in 'Checkout' page.", 'cryptoniq-pro' ),
                    'default'  => esc_html__( 'Pay with cryptocurrencies.', 'cryptoniq-pro' ),
                    'validate' => 'not_empty',
                ),
            ),
        ),

        // ------------------------------------------------- Colors
        'tab_colors' => array(
            'title'  => esc_html__( 'Colors', 'cryptoniq-pro' ),
            'icon'   => 'icon ion-md-color-fill',
            'fields' => array(
                array(
                    'id'       => 'pg_bar_tx_errors',
                    'type'     => 'color',
                    'title'    => esc_html__( 'Progress bar: Errors', 'cryptoniq-pro' ),
                    'default'  => '#bf4141',
                    'validate' => 'color',
                ),
                array(
                    'id'       => 'pg_bar_tx_checking',
                    'type'     => 'color',
                    'title'    => esc_html__( 'Progress bar: Checking', 'cryptoniq-pro' ),
                    'default'  => '#000000',
                    'validate' => 'color',
                ),
                array(
                    'id'       => 'pg_bar_tx_process',
                    'type'     => 'color',
                    'title'    => esc_html__( 'Progress bar: Processing', 'cryptoniq-pro' ),
                    'default'  => '#255b40',
                    'validate' => 'color',
                ),
            ),
        ),

        // ------------------------------------------------- Referral
        'tab_referral' => array(
            'title'  => esc_html__( 'Referral', 'cryptoniq-pro' ),
            'icon'   => 'icon ion-md-gift',
            'desc'   => esc_html__( 'We are launching a referral system where you can earn passive income.', 'cryptoniq-pro' )
                . '<br>'
                . sprintf(
                    esc_html__( 'For more, contact us via Telegram: %1$s', 'cryptoniq-pro' ),
                    '<a class="cryptoniq-options-link" href="https://t.me/div_engine" target="_blank">@div_engine</a>'
                ),
        ),

        // ------------------------------------------------- Support
        'tab_help' => array(
            'title'  => esc_html__( 'Support 24/7', 'cryptoniq-pro' ),
            'icon'   => 'icon ion-md-help-buoy',
            'desc'   => sprintf(
                esc_html__( 'For any questions, please contact via Telegram: %1$s', 'cryptoniq-pro' ),
                '<a class="cryptoniq-options-link" href="https://t.me/div_engine" target="_blank">@div_engine</a>'
            ),
        ),
);

// Hide license-gated tabs when no license is active. "Show coin prices
// next to product prices" only works with a license.
if ( ! $cryptoniq_is_pro_mode ) {
    unset( $cryptoniq_sections['tab_prices'] );
}

return array(
    'opt_name'      => CRYPTONIQ_OPTION,
    'menu_title'    => 'Cryptoniq',
    'page_title'    => 'Cryptoniq',
    'page_slug'     => 'cryptoniq',
    'page_parent'   => '', // empty => top-level admin menu
    'menu_icon'     => 'dashicons-money-alt',
    'menu_position' => 56,
    'capability'    => 'manage_woocommerce',
    'version'       => CRYPTONIQ_VER,
    'sections'      => $cryptoniq_sections,
);
