<?php
/**
 * Base abstract class for conditional email tag conditions.
 *
 * Provides default metadata behavior shared by concrete condition classes.
 *
 * @package EDD\Pro\Emails\ConditionalTags\Conditions
 * @copyright Copyright (c) 2026, Sandhills Development, LLC
 * @license https://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since 3.6.6
 */

namespace EDD\Pro\Emails\ConditionalTags\Conditions;

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore

use EDD\Pro\Emails\ConditionalTags\Conditions\Traits\ContextAware;

/**
 * Class AbstractCondition
 *
 * @since 3.6.6
 */
abstract class AbstractCondition implements ConditionInterface {

	use ContextAware;

	/**
	 * Supported operators for this condition.
	 *
	 * Child conditions can override this property as needed.
	 *
	 * @since 3.6.6
	 * @var string[]
	 */
	protected $supported_operators = array();

	/**
	 * Supported email contexts for this condition.
	 *
	 * Empty means all contexts are allowed.
	 *
	 * @since 3.6.6
	 * @var string[]
	 */
	protected $supported_contexts = array();

	/**
	 * UI input type descriptor for the value field.
	 *
	 * Child conditions can override this property to render a different
	 * input widget (e.g. 'date', 'select', 'number', 'hidden').
	 *
	 * @since 3.6.6
	 * @var array
	 */
	protected $ui_input_type = array( 'type' => 'text' );

	/**
	 * Get the comparison operators supported by this condition.
	 *
	 * @since 3.6.6
	 *
	 * @return string[]
	 */
	public function get_supported_operators() {
		return $this->supported_operators;
	}

	/**
	 * Get the email contexts supported by this condition.
	 *
	 * @since 3.6.6
	 *
	 * @return string[]
	 */
	public function get_supported_contexts() {
		return $this->supported_contexts;
	}

	/**
	 * Get the UI input type descriptor for the value field.
	 *
	 * @since 3.6.6
	 *
	 * @return array{type: string, options?: array}
	 */
	public function get_ui_input_type() {
		return $this->ui_input_type;
	}

	/**
	 * Get custom operator labels for the UI.
	 *
	 * Override in child classes to replace the default operator labels
	 * (e.g. "is" / "is not") with condition-specific labels like
	 * "contains" / "does not contain" for multi-select conditions.
	 *
	 * @since 3.6.6
	 *
	 * @return array<string, string> Operator symbol to label map, or empty for defaults.
	 */
	public function get_operator_labels() {
		return array();
	}
}
