<?php
/**
 * The WooCommerce Panel class is responsible for loading and
 * registering the customizer settings and controls for the Header Builder module.
 *
 * @package Brandy\Customizer
 * @since   1.0.0
 */

namespace Brandy\Customizer\Panels\WooCommerce;

use Brandy\Abstracts\AbstractCustomizerModuleLoader;
use Brandy\Traits\SingletonTrait;

/**
 * Register General stuffs
 * General panel and section are registered here
 */
class General extends AbstractCustomizerModuleLoader {

	use SingletonTrait;

	public const SECTION_ID = 'wc_general';

	protected function __construct() {
		add_filter(
			'brandy_wc_sections',
			function ( $sections ) {
				return array_merge(
					$sections,
					array_filter(
						self::get_configurations(),
						function ( $item ) {
							return 'section' === $item['configuration_type'];
						}
					)
				);
			}
		);

		add_filter(
			'brandy_wc_default_settings',
			function ( $settings ) {
				$settings[ self::SECTION_ID ] = true;
				return $settings;
			}
		);

		parent::__construct();
	}

	public static function get_configurations() {
		$configurations[] = array(
			'configuration_type' => 'section',
			'id'                 => self::SECTION_ID,
			'title'              => __( 'General', 'brandy' ),
			'panel'              => WooCommercePanel::PANEL_ID,
			'type'               => 'brandy-section',
			'description_hidden' => true,
		);
		$configurations[] = array(
			'configuration_type' => 'control',
			'id'                 => 'enable_product_image_hover_effect',
			'label'              => __( 'Enable product image hover effect', 'brandy' ),
			'section'            => self::SECTION_ID,
			'type'               => 'brandy_settings',
			'input_attrs'        => array(
				'value' => '',
				'style' => 'display:none;',
			),
			'partial'            => false,
			'default'            => true,
			'transport'          => 'refresh',
		);
		$configurations[] = array(
			'configuration_type' => 'control',
			'id'                 => 'product_image_hover_effect',
			'label'              => __( 'Product image hover effect', 'brandy' ),
			'section'            => self::SECTION_ID,
			'type'               => 'brandy_settings',
			'input_attrs'        => array(
				'value' => '',
				'style' => 'display:none;',
			),
			'partial'            => false,
			'default'            => 'display-slider',
			'transport'          => 'refresh',
		);

		$configurations[] = array(
			'configuration_type' => 'control',
			'id'                 => 'enable_product_image_hover_zoom',
			'label'              => __( 'Enable product image hover zoom', 'brandy' ),
			'section'            => self::SECTION_ID,
			'type'               => 'brandy_settings',
			'input_attrs'        => array(
				'value' => '',
				'style' => 'display:none;',
			),
			'partial'            => false,
			'default'            => true,
			'transport'          => 'refresh',
		);

		$configurations[] = array(
			'configuration_type' => 'control',
			'id'                 => 'product_image_hover_scale',
			'label'              => __( 'Product image hover scale', 'brandy' ),
			'section'            => self::SECTION_ID,
			'type'               => 'brandy_settings',
			'input_attrs'        => array(
				'value' => '',
				'style' => 'display:none;',
			),
			'partial'            => false,
			'default'            => 1.1,
			'transport'          => 'refresh',
		);

		return $configurations;
	}
}
