<?php
// @generated by build-free-packages.mjs — DO NOT EDIT.
/**
 * WooCommerce Trigger Definitions
 *
 * Configuration-driven definitions for WooCommerce triggers.
 * Returns plain arrays instead of TriggerDefinition objects, allowing
 * PackageLoader to create the objects during initialization.
 *
 * @package Sequensy\Integrations\WooCommerce
 * @since 1.0.0
 */

declare(strict_types=1);

namespace Sequensy\Integrations\WooCommerce\Triggers;

use Sequensy\Integrations\WooCommerce\Helpers\OrderFields;
use Sequensy\Integrations\WooCommerce\Helpers\ProductFields;

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}

/**
 * Class WooCommerceTriggers
 *
 * Provides configuration-driven definitions for WooCommerce triggers.
 */
final class WooCommerceTriggers {

	/**
	 * Get all trigger definitions.
	 *
	 * @return array<array> Array of trigger definition arrays.
	 */
	public static function get_definitions(): array {
		return array(
			self::new_order(),
			self::order_completed(),
		);
	}

	/**
	 * New Order trigger definition.
	 *
	 * @return array
	 */
	public static function new_order(): array {
		return array(
			'type'             => 'new_order',
			'label'            => __( 'New Order', 'sequensy' ),
			'description'      => __( 'Triggers when a new WooCommerce order is created', 'sequensy' ),
			'hook'             => 'woocommerce_new_order',
			'priority'         => 10,
			'accepted_args'    => 2,
			'available_fields' => OrderFields::available_fields(),
			'build_context'    => function ( int $order_id, $order = null ): ?array {
				return OrderFields::build_context( $order_id, $order );
			},
		);
	}

	/**
	 * Order Completed trigger definition.
	 *
	 * @return array
	 */
	public static function order_completed(): array {
		return array(
			'type'             => 'order_completed',
			'label'            => __( 'Order Completed', 'sequensy' ),
			'description'      => __( 'Triggers when a WooCommerce order status changes to completed', 'sequensy' ),
			'hook'             => 'woocommerce_order_status_completed',
			'priority'         => 10,
			'accepted_args'    => 2,
			'available_fields' => OrderFields::available_fields(),
			'build_context'    => function ( int $order_id, $order = null ): ?array {
				return OrderFields::build_context( $order_id, $order );
			},
		);
	}
}
