<?php
namespace Prodigy\Includes\Frontend\Mappers;

use Prodigy\Includes\Frontend\Prodigy_Product_Template_Builder;
use Prodigy\Includes\Frontend\Prodigy_Product_Template_Item;
use Prodigy\Includes\Helpers\Prodigy_Widget_Options;

/**
 * Prodigy product tags data mapper
 *
 * @version    3.0.4
 * @package    Prodigy
 * @subpackage Prodigy/includes
 */
class Prodigy_Product_Tags_Data_Mapper extends Prodigy_Main_Data_Mapper {

	/**
	 * Prepare data and variables to inject in template
	 *
	 * @param array $options
	 *
	 * @return array
	 */
	public function get_default_parameters( array $options ): array {
		$product_template      = new Prodigy_Product_Template_Builder( new Prodigy_Product_Template_Item() );
		$product               = $GLOBALS['prodigy_product'] ?? $product_template->set_product( (int) Prodigy_Product_Template_Builder::get_random_product_id() );
		$options['tags']       = ! empty( $product ) ? $product->get_remote_tags() : array();
		$options['tags_count'] = count( (array) $options['tags'] );

		$options['enable_product_tags'] = isset( $options['meta_show_tags'] )
			? ( Prodigy_Widget_Options::$bool_mapper[ $options['meta_show_tags'] ] )
			: ( $this->customizer_product_options['prodigy_product_tags'] ?? true );

		return $options;
	}
}
