<?php

namespace WeDevs\AppBridge\Integrations\WooCommerce\Notifications;

/**
 * Canonical Customer App (Pocket Store) push-notification event catalog.
 *
 * Lives with the WooCommerce integration since these events target the
 * customer mobile app. Consumed by:
 *   - {@see \WeDevs\AppBridge\Integrations\WooCommerce\SettingsSchema} (editor UI)
 *   - {@see \WeDevs\AppBridge\Core\Notifications\EventRegistry} (dispatch),
 *     wired in via WooCommerceIntegration::event_catalogs()
 *
 * Each event: id, label, channel, screen_route, title, body.
 *
 * Both `customer_push_event_categories` consumers and the registry must
 * read through this class so the wire payload (channel, route) and the
 * editable copy (title, body) stay in lockstep.
 */
class CustomerEventCatalog {

	/**
	 * @return array<string, array{label:string, description?:string, events:array<int, array<string, mixed>>}>
	 */
	public static function categories(): array {
		return [
			'order'   => [
				'label'       => __( 'Order', 'app-bridge' ),
				'description' => __( 'Order lifecycle notifications sent to the customer.', 'app-bridge' ),
				'events'      => [
					[
						'id'           => 'order_placed',
						'label'        => __( 'Order Placed', 'app-bridge' ),
						'channel'      => 'order',
						'screen_route' => 'order_details',
						'title'        => __( 'Order Placed Successfully!', 'app-bridge' ),
						'body'         => __( "Your order #{order_number} has been placed. We'll notify you when it's confirmed.", 'app-bridge' ),
					],
					[
						'id'           => 'order_confirmed',
						'label'        => __( 'Order Confirmed', 'app-bridge' ),
						'channel'      => 'order',
						'screen_route' => 'order_details',
						'title'        => __( 'Order Confirmed', 'app-bridge' ),
						'body'         => __( 'Great news! Your order #{order_number} has been confirmed by the seller.', 'app-bridge' ),
					],
					[
						'id'           => 'order_processing',
						'label'        => __( 'Order Processing', 'app-bridge' ),
						'channel'      => 'order',
						'screen_route' => 'order_details',
						'title'        => __( 'Order is Being Processed', 'app-bridge' ),
						'body'         => __( 'Your order #{order_number} is now being prepared by the seller.', 'app-bridge' ),
					],
					[
						'id'           => 'order_delivered',
						'label'        => __( 'Order Delivered', 'app-bridge' ),
						'channel'      => 'order',
						'screen_route' => 'order_details',
						'title'        => __( 'Order Delivered', 'app-bridge' ),
						'body'         => __( 'Your order #{order_number} has been delivered. Enjoy your purchase!', 'app-bridge' ),
					],
					[
						'id'           => 'order_cancelled',
						'label'        => __( 'Order Cancelled', 'app-bridge' ),
						'channel'      => 'order',
						'screen_route' => 'order_details',
						'title'        => __( 'Order Cancelled', 'app-bridge' ),
						'body'         => __( 'Your order #{order_number} has been cancelled. If you have questions, contact support.', 'app-bridge' ),
					],
					[
						'id'           => 'order_failed',
						'label'        => __( 'Order Failed', 'app-bridge' ),
						'channel'      => 'important',
						'screen_route' => 'order_details',
						'title'        => __( 'Order Failed', 'app-bridge' ),
						'body'         => __( 'Unfortunately, your order #{order_number} could not be processed. Please try again.', 'app-bridge' ),
					],
					[
						'id'           => 'order_on_hold',
						'label'        => __( 'Order On Hold', 'app-bridge' ),
						'channel'      => 'order',
						'screen_route' => 'order_details',
						'title'        => __( 'Order On Hold', 'app-bridge' ),
						'body'         => __( "Your order #{order_number} is on hold pending payment verification. We'll update you shortly.", 'app-bridge' ),
					],
				],
			],
			'payment' => [
				'label'       => __( 'Payment', 'app-bridge' ),
				'description' => __( 'Payment confirmation and failure alerts.', 'app-bridge' ),
				'events'      => [
					[
						'id'           => 'payment_success',
						'label'        => __( 'Payment Success', 'app-bridge' ),
						'channel'      => 'important',
						'screen_route' => 'order_details',
						'title'        => __( 'Payment Successful', 'app-bridge' ),
						'body'         => __( 'Your payment of {amount} for order #{order_number} was successful.', 'app-bridge' ),
					],
					[
						'id'           => 'payment_failed',
						'label'        => __( 'Payment Failed', 'app-bridge' ),
						'channel'      => 'important',
						'screen_route' => 'payment_methods',
						'title'        => __( 'Payment Failed', 'app-bridge' ),
						'body'         => __( "We couldn't process your payment for order #{order_number}. Please check your payment method.", 'app-bridge' ),
					],
				],
			],
			'refund'  => [
				'label'       => __( 'Refund', 'app-bridge' ),
				'description' => __( 'Refund request, approval, rejection and completion updates.', 'app-bridge' ),
				'events'      => [
					[
						'id'           => 'refund_requested',
						'label'        => __( 'Refund Requested', 'app-bridge' ),
						'channel'      => 'refund',
						'screen_route' => 'refund_details',
						'title'        => __( 'Refund Request Received', 'app-bridge' ),
						'body'         => __( 'Your refund request for order #{order_number} has been submitted and is under review.', 'app-bridge' ),
					],
					[
						'id'           => 'refund_approved',
						'label'        => __( 'Refund Approved', 'app-bridge' ),
						'channel'      => 'refund',
						'screen_route' => 'refund_details',
						'title'        => __( 'Refund Approved', 'app-bridge' ),
						'body'         => __( 'Your refund of {amount} for order #{order_number} has been approved. Allow 3–5 business days to reflect.', 'app-bridge' ),
					],
					[
						'id'           => 'refund_rejected',
						'label'        => __( 'Refund Rejected', 'app-bridge' ),
						'channel'      => 'refund',
						'screen_route' => 'refund_details',
						'title'        => __( 'Refund Request Rejected', 'app-bridge' ),
						'body'         => __( 'Your refund request for order #{order_number} was not approved. Contact support for help.', 'app-bridge' ),
					],
					[
						'id'           => 'refund_completed',
						'label'        => __( 'Refund Completed', 'app-bridge' ),
						'channel'      => 'refund',
						'screen_route' => 'order_details',
						'title'        => __( 'Refund Processed', 'app-bridge' ),
						'body'         => __( 'Your refund of {amount} has been credited back to your original payment method.', 'app-bridge' ),
					],
				],
			],
			'support' => [
				'label'       => __( 'Support / Chat', 'app-bridge' ),
				'description' => __( 'Messages and ticket updates from the seller and support.', 'app-bridge' ),
				'events'      => [
					[
						'id'           => 'support_message_received',
						'label'        => __( 'New Support Message', 'app-bridge' ),
						'channel'      => 'chat',
						'screen_route' => 'support_chat',
						'title'        => __( 'New Message from Seller', 'app-bridge' ),
						'body'         => __( 'The seller has replied to your support request for order #{order_number}.', 'app-bridge' ),
					],
					[
						'id'           => 'support_ticket_closed',
						'label'        => __( 'Ticket Closed', 'app-bridge' ),
						'channel'      => 'chat',
						'screen_route' => 'support_ticket_details',
						'title'        => __( 'Support Ticket Closed', 'app-bridge' ),
						'body'         => __( 'Your support ticket #{ticket_id} has been resolved and closed.', 'app-bridge' ),
					],
				],
			],
			'review'  => [
				'label'       => __( 'Review', 'app-bridge' ),
				'description' => __( 'Replies to the reviews the customer has posted.', 'app-bridge' ),
				'events'      => [
					[
						'id'           => 'review_reply_received',
						'label'        => __( 'Seller Replied to Review', 'app-bridge' ),
						'channel'      => 'general',
						'screen_route' => 'product_reviews',
						'title'        => __( 'Seller Replied to Your Review', 'app-bridge' ),
						'body'         => __( "The seller has responded to your review on '{product_name}'.", 'app-bridge' ),
					],
				],
			],
			'account' => [
				'label'       => __( 'Account', 'app-bridge' ),
				'description' => __( 'Account and security-related alerts.', 'app-bridge' ),
				'events'      => [
					[
						'id'           => 'account_registered',
						'label'        => __( 'Account Registered', 'app-bridge' ),
						'channel'      => 'general',
						'screen_route' => 'home',
						'title'        => __( 'Welcome to Dokan!', 'app-bridge' ),
						'body'         => __( 'Your account has been created successfully. Start exploring now.', 'app-bridge' ),
					],
					[
						'id'           => 'account_password_changed',
						'label'        => __( 'Password Changed', 'app-bridge' ),
						'channel'      => 'important',
						'screen_route' => 'account_security',
						'title'        => __( 'Password Changed', 'app-bridge' ),
						'body'         => __( "Your account password was recently changed. If this wasn't you, contact support immediately.", 'app-bridge' ),
					],
					[
						'id'           => 'account_password_reset',
						'label'        => __( 'Password Reset Requested', 'app-bridge' ),
						'channel'      => 'important',
						'screen_route' => 'login',
						'title'        => __( 'Password Reset Requested', 'app-bridge' ),
						'body'         => __( 'A password reset was requested for your account. Follow the instructions to proceed.', 'app-bridge' ),
					],
				],
			],
		];
	}
}
