<?php

namespace HulkPlugins\ElementorPro\Forms\AdvancedFields\Fields\Color;

use HulkPlugins\ElementorPro\Forms\AdvancedFields\Fields\FieldBase;
use const HulkPlugins\ElementorPro\Forms\AdvancedFields\PREFIX;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

class Field extends FieldBase {

	public $depended_styles = [ PREFIX . 'Color' ];

	protected bool $showContentTab = false;
	protected bool $showStyleTab = false;
	protected bool $showWidgetControls = true;

	/**
	 * Get field type.
	 * @return string
	 */
	public function get_type(): string {
		return PREFIX . 'native_color';
	}

	/**
	 * Get field name.
	 * @return string
	 */
	public function get_name(): string {
		return esc_attr__( 'Color', 'advanced-fields-for-elementor-forms' );
	}

	/**
	 * Hide required control
	 * @param $control_data
	 *
	 * @return void
	 */
	public function update_field_control_data( &$control_data ): void {
		if ( isset( $control_data['fields']['required']['conditions']['terms'] ) ) {
			$control_data['fields']['required']['conditions']['terms'][] = [
				'name'     => 'field_type',
				'operator' => '!in',
				'value'    => [ $this->get_type() ],
			];
		}
	}
}
