<?php
/**
 * A class for setting the plugin’s default values.
 */

declare(strict_types=1);
namespace FeData\FastEvents\Utilities;

defined( 'ABSPATH' ) || exit;

/**
 * A class for setting the plugin’s default values.
 */
class SettingsDefaults {

	/**
	 * HTML Purifier for HTML content
	 *
	 * @since 1.0
	 *
	 * @return mixed JSON decoded array.
	 */
	public static function default_settings(): mixed {
		$urlparts = wp_parse_url( home_url() );
		$domain   = preg_replace( '/^www\./', '', $urlparts['host'] );
		$tmp      = <<<'EOT'
			{
				"payment_provider": "{\"type\":\"payment\",\"provider\":{\"class\":\"FeData\\\\FastEvents\\\\Payment\\\\Provider\\\\MollieProvider\",\"live_key\":\"\",\"test_key\":\"\"}}",
				"payment_config": {
					"wait": true,
					"currency": "EUR",
					"currency_symbol": "€",
					"refund_costs": 2.25,
					"refund_per": 1,
					"expire": 10,
					"cancel_url": "",
					"errorpage": "",
					"saas_mode": false,
					"saas_test": true,
					"saas_client_id": "",
					"saas_client_secret": "",
					"saas_client_fee": 0.05,
					"saas_client_fee_per": 1
				},
				"mail_provider": "{\"type\":\"mailer\",\"provider\":{\"class\":\"FeData\\\\FastEvents\\\\Mail\\\\Provider\\\\LocalMailer\"}}",
				"email_retries": {
					"enabled": false,
					"retry_scheme": "2,4,8,16,32,64,128",
					"webhooks": false,
					"queues": false
				},
				"email_sender": {
					"name": "",
					"email": ""
				},
				"captcha": {
					"provider": 0,
					"site_key": "",
					"secret_key": ""
				},
				"action_scheduler": {
					"purge_days": 30,
					"time_limit": 30,
					"batch_size": 25,
					"concurrent_batches": 1,
					"additional_runners": 0
				},
				"logging": {
					"level": "notice",
					"log_retention_days": 30,
					"monolog": "{\"type\":\"monolog\",\"channel\":\"fast-events\",\"handlers\":[]}"
				},
				"misc": {
					"custom_order_status": "processing,shipped",
					"orders_cleanup": false,
					"stats_queries_cache_time": 60,
					"ordering_api": false,
					"order_form_cache_time": 60
				}
			}
			EOT;

		$json                             = json_decode( $tmp );
		$json->fe_admin_api_key           = UniqIds::uniq_id();
		$json->payment_config->cancel_url = home_url();
		$json->payment_config->errorpage  = home_url() . '/order-error/';
		$json->email_sender->name         = get_bloginfo();
		$json->email_sender->email        = 'info@' . $domain;

		return $json;
	}
}
