<?php

namespace SugarCalendarBookings\Notifications\Emails;

use SugarCalendarBookings\Appointments\AppointmentModel;
use SugarCalendarBookings\Appointments\CancellationTokenService;
use SugarCalendarBookings\Options;
use SugarCalendarBookings\Payments\PaymentModel;
use SugarCalendarBookings\Payments\PaymentsHelpers;
use SugarCalendarBookings\Locations\AbstractLocation;
use SugarCalendarBookings\Plugin;
use SugarCalendarBookings\Support\Helpers\Date;

/**
 * Email service for sending notification emails.
 *
 * @since 1.0.0
 */
class EmailService {

	/**
	 * Plugin options instance.
	 *
	 * @since 1.0.0
	 *
	 * @var Options
	 */
	protected $options;

	/**
	 * Constructor.
	 *
	 * @since 1.0.0
	 */
	public function __construct() {

		$this->options = Plugin::get( Options::class );
	}

	/**
	 * Send an email notification.
	 *
	 * @since 1.0.0
	 *
	 * @param string           $email_id        Email ID (e.g., 'new_booking_attendee', 'booking_cancellation_employee').
	 * @param AppointmentModel $appointment     Appointment model.
	 * @param array            $additional_vars Additional variables to replace.
	 *
	 * @return bool True on success, false on failure.
	 */
	public function send_email( $email_id, $appointment, $additional_vars = [] ) {

		if ( $this->should_skip_email( $appointment, $email_id ) ) {
			return false;
		}

		// Get recipient email based on email ID.
		$recipient_email = $this->get_recipient_email( $appointment, $email_id );

		if ( ! $recipient_email ) {
			return false;
		}

		// Get email template.
		$template = $this->get_email_template( $email_id, $appointment );

		if ( ! $template ) {
			return false;
		}

		// Prepare email data.
		$email_data = $this->prepare_email_data( $appointment, $additional_vars );

		// Replace variables in subject and content.
		$subject = $this->replace_variables( $template['subject'], $email_data );
		$content = $this->replace_variables( $template['content'], $email_data );

		$content = self::email_wrapper( $content );

		// Send the email.
		$result = $this->send_wp_email( $recipient_email, $subject, $content );

		return $result;
	}

	/**
	 * Send an admin email notification (non-appointment).
	 *
	 * @since 1.4.0
	 *
	 * @param string $email_id Email ID.
	 * @param string $to       Recipient email address.
	 * @param array  $vars     Variables to replace in subject/content.
	 *
	 * @return bool True on success, false on failure.
	 */
	public function send_admin_email( string $email_id, string $to, array $vars = [] ): bool {

		// Check if this email type is enabled.
		$email_enabled = $this->options->get( "emails.{$email_id}.enabled", true );

		if ( ! $email_enabled ) {
			return false;
		}

		// Get email template.
		$template = $this->get_email_template( $email_id );

		if ( ! $template ) {
			return false;
		}

		// Replace variables in subject and content.
		$subject = $this->replace_variables( $template['subject'], $vars );
		$content = $this->replace_variables( $template['content'], $vars );

		$content = self::email_wrapper_admin( $content );

		return $this->send_wp_email( $to, $subject, $content );
	}

	/**
	 * Check if the email should be skipped.
	 *
	 * @since 1.0.0
	 *
	 * @param AppointmentModel $appointment Appointment model.
	 * @param string           $email_id    Email ID.
	 *
	 * @return bool True if the email should be skipped, false otherwise.
	 */
	protected function should_skip_email( $appointment, $email_id ) {

		// Skip employee emails when current user is that employee and it's admin.
		if ( $this->is_employee_self_notification( $appointment, $email_id ) ) {
			return true;
		}

		// Check if this specific email type is enabled.
		$email_enabled = $this->options->get( "emails.{$email_id}.enabled", true );

		if ( ! $email_enabled ) {
			return true;
		}

		return false;
	}

	/**
	 * Check if this is an employee self-notification.
	 *
	 * Returns true when the current logged-in user is creating an appointment
	 * for themselves as an employee in the admin context.
	 *
	 * @since 1.0.0
	 *
	 * @param AppointmentModel $appointment Appointment model.
	 * @param string           $email_id    Email ID.
	 *
	 * @return bool True if this is a self-notification, false otherwise.
	 */
	protected function is_employee_self_notification( $appointment, $email_id ) {

		return is_user_logged_in() && is_admin() && strpos( $email_id, '_employee' ) !== false && $appointment->employee->user_id === (int) get_current_user_id();
	}

	/**
	 * Get recipient email address based on email ID.
	 *
	 * @since 1.0.0
	 *
	 * @param AppointmentModel $appointment Appointment model.
	 * @param string           $email_id    Email ID.
	 *
	 * @return string|null Email address or null if not found.
	 */
	private function get_recipient_email( $appointment, $email_id ) {

		// Determine recipient type from email ID.
		if ( strpos( $email_id, '_attendee' ) !== false ) {
			return $appointment->customer->email ?? null;
		}

		if ( strpos( $email_id, '_employee' ) !== false ) {
			return $appointment->employee->email ?? null;
		}

		return null;
	}

	/**
	 * Get email template by type.
	 *
	 * @since 1.0.0
	 *
	 * @param string                $email_type  Email type.
	 * @param AppointmentModel|null $appointment Appointment model (for Pro service-level overrides).
	 *
	 * @return array|null Template data or null if not found.
	 */
	protected function get_email_template( $email_type, $appointment = null ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed

		$email_settings = $this->options->get( "emails.{$email_type}" );

		// Get defaults.
		$defaults      = EmailDefaults::to_array();
		$default_email = $defaults[ $email_type ] ?? null;

		// If no saved settings or missing subject/content, use defaults.
		if ( empty( $email_settings ) || empty( $email_settings['subject'] ) || empty( $email_settings['content'] ) ) {
			$email_settings = $default_email;
		}

		return $email_settings;
	}

	/**
	 * Prepare email data with all available variables.
	 *
	 * @since 1.0.0
	 *
	 * @param AppointmentModel $appointment     Appointment model.
	 * @param array            $additional_vars Additional variables.
	 *
	 * @return array Email data.
	 */
	private function prepare_email_data( $appointment, $additional_vars = [] ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh

		$customer = $appointment->customer;
		$service  = $appointment->service;
		$employee = $appointment->employee;
		$location = $appointment->get_location();

		$data = [
			// Customer information.
			'{customer_full_name}'      => $customer->name ?? '',
			'{customer_email}'          => $customer->email ?? '',
			'{customer_phone}'          => $customer->phone ?? '',
			// Service information.
			'{service_name}'            => $service->name ?? '',
			// Employee information.
			'{employee_full_name}'      => $employee->name ?? '',
			// Appointment timing.
			'{start_date}'              => $this->format_appointment_date( $appointment ),
			'{start_time}'              => $this->format_appointment_time( $appointment ),
			'{end_time}'                => $this->format_appointment_end_time( $appointment ),
			// Location and other details.
			'{location_name}'           => $this->get_location_display( $appointment, $location ),
			'{appointment_code}'        => $appointment->code ?? '',
			'{site_name}'               => get_bloginfo( 'name' ),
			'{site_url}'                => get_bloginfo( 'url' ),
			'{appointment_admin_url}'   => $this->get_appointment_admin_url( $appointment ),
			'{cancellation_url}'        => $this->get_cancellation_url( $appointment ),
			// Order summary.
			'{order_summary_breakdown}' => $this->generate_order_summary( $appointment ),
			'{refund_amount}'           => PaymentsHelpers::format_currency( $service->price ?? 0 ),
			'{payment_gateway}'         => $this->get_payment_gateway_name( $appointment ),
		];

		// Merge additional variables. Keys must be braced placeholders to override the defaults above.
		$data = array_merge( $data, $additional_vars );

		return $data;
	}

	/**
	 * Get appointment admin URL.
	 *
	 * @since 1.0.0
	 *
	 * @param AppointmentModel $appointment Appointment model.
	 *
	 * @return string Admin URL.
	 */
	private function get_appointment_admin_url( $appointment ) {

		return admin_url( 'admin.php?page=sugar-calendar-bookings-appointments&view=details&appointment_id=' . $appointment->id );
	}

	/**
	 * Get cancellation URL for an appointment.
	 *
	 * @since 1.1.0
	 *
	 * @param AppointmentModel $appointment Appointment model.
	 *
	 * @return string Cancellation URL.
	 */
	private function get_cancellation_url( $appointment ) {

		return Plugin::get( CancellationTokenService::class )->generate_cancellation_url( $appointment );
	}

	/**
	 * Replace variables in email content.
	 *
	 * @since 1.0.0
	 *
	 * @param string $content Email content with variables.
	 * @param array  $data    Variable data.
	 *
	 * @return string Processed content.
	 */
	protected function replace_variables( $content, $data ) {

		foreach ( $data as $variable => $value ) {
			$content = str_replace( $variable, $value, $content );
		}

		return $content;
	}

	/**
	 * Send email using WordPress wp_mail function.
	 *
	 * @since 1.0.0
	 *
	 * @param string $to      Recipient email.
	 * @param string $subject Email subject.
	 * @param string $content Email content.
	 *
	 * @return bool True on success, false on failure.
	 */
	protected function send_wp_email( $to, $subject, $content ) {

		// Get from email settings.
		$from_email = $this->options->get( 'emails.from_email', get_option( 'admin_email' ) );
		$from_name  = $this->options->get( 'emails.from_name', get_bloginfo( 'name' ) );

		// Set email headers.
		$headers = [
			'Content-Type: text/html; charset=UTF-8',
			'From: ' . sanitize_text_field( $from_name ) . ' <' . sanitize_email( $from_email ) . '>',
		];

		// Send email.
		$result = wp_mail( $to, $subject, $content, $headers );

		return $result;
	}

	/**
	 * Format appointment date.
	 *
	 * @since 1.0.0
	 *
	 * @param AppointmentModel $appointment Appointment model.
	 *
	 * @return string Formatted date.
	 */
	private function format_appointment_date( $appointment ) {

		$date_format = $this->options->get( 'display.date_format' );

		return $appointment->start_at->setTimezone( Date::get_default_timezone() )->format( $date_format );
	}

	/**
	 * Format appointment time.
	 *
	 * @since 1.0.0
	 *
	 * @param AppointmentModel $appointment Appointment model.
	 *
	 * @return string Formatted time.
	 */
	private function format_appointment_time( $appointment ) {

		$time_format = $this->options->get( 'display.time_format' );

		return $appointment->start_at->setTimezone( Date::get_default_timezone() )->format( $time_format );
	}

	/**
	 * Format appointment duration.
	 *
	 * @since 1.0.0
	 *
	 * @param AppointmentModel $appointment Appointment model.
	 *
	 * @return string Formatted duration.
	 */
	private function format_appointment_duration( $appointment ) {

		$duration = $appointment->get_duration();

		if ( $duration <= 60 ) {
			return sprintf(
			/* translators: %d - number of minutes. */
				_n( '%d minute', '%d minutes', $duration, 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				$duration
			);
		}

		$hours   = floor( $duration / 60 );
		$minutes = $duration % 60;

		if ( $minutes === 0 ) {
			return sprintf(
			/* translators: %d - number of hours. */
				_n( '%d hour', '%d hours', $hours, 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				$hours
			);
		}

		return sprintf(
		/* translators: %1$d - number of hours; %2$d - number of minutes. */
			esc_html__( '%1$d hour %2$d minutes', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			$hours,
			$minutes
		);
	}

	/**
	 * Format appointment end time.
	 *
	 * @since 1.0.0
	 *
	 * @param AppointmentModel $appointment Appointment model.
	 *
	 * @return string Formatted end time.
	 */
	private function format_appointment_end_time( $appointment ) {

		$time_format = $this->options->get( 'display.time_format' );

		return $appointment->end_at->setTimezone( Date::get_default_timezone() )->format( $time_format );
	}

	/**
	 * Generate order summary breakdown.
	 *
	 * @since 1.0.0
	 *
	 * @param AppointmentModel $appointment Appointment model.
	 *
	 * @return string Order summary.
	 */
	private function generate_order_summary( $appointment ) {

		$service = $appointment->service;
		$price   = $service->price ?? 0;

		if ( $price <= 0 ) {
			return esc_html__( 'No charge', 'sugar-calendar-bookings-scheduling-appointments-lite' );
		}

		$summary = sprintf(
		/* translators: %1$s - service name; %2$s - price with currency. */
			esc_html__( '%1$s: %2$s', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			$service->name,
			PaymentsHelpers::format_currency( $price )
		);

		// Append payment status if available.
		$payment_status = $this->get_payment_status_text( $appointment );

		if ( ! empty( $payment_status ) ) {
			$summary .= '<br>' . $payment_status;
		}

		return $summary;
	}

	/**
	 * Get payment status text for the appointment.
	 *
	 * @since 1.0.0
	 *
	 * @param AppointmentModel $appointment Appointment model.
	 *
	 * @return string Payment status text.
	 */
	private function get_payment_status_text( $appointment ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh

		// Get first payment.
		$payment = PaymentsHelpers::get_payment( $appointment );

		if ( ! $payment instanceof PaymentModel ) {
			return '';
		}

		$gateway = PaymentsHelpers::get_payment_gateway_display_name( $payment );

		switch ( $payment->status ) {
			case PaymentModel::STATUS_COMPLETED:
				$text = sprintf(
					/* translators: %1$s - payment gateway name. */
					esc_html__( 'Paid via %1$s', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
					$gateway
				);
				break;

			case PaymentModel::STATUS_PENDING:
				$text = esc_html__( 'Payment: Pending', 'sugar-calendar-bookings-scheduling-appointments-lite' );
				break;

			case PaymentModel::STATUS_FAILED:
				$text = esc_html__( 'Payment: Failed', 'sugar-calendar-bookings-scheduling-appointments-lite' );
				break;

			case PaymentModel::STATUS_REFUNDED:
				$text = sprintf(
					/* translators: %1$s - payment gateway name. */
					esc_html__( 'Refunded via %1$s', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
					$gateway
				);
				break;

			default:
				$text = '';
				break;
		}

		return $text;
	}

	/**
	 * Get payment gateway name for the appointment.
	 *
	 * @since 1.1.0
	 *
	 * @param AppointmentModel $appointment Appointment model.
	 *
	 * @return string Payment gateway name.
	 */
	private function get_payment_gateway_name( $appointment ) {

		// Get first payment.
		$payment = PaymentsHelpers::get_payment( $appointment );

		if ( ! $payment instanceof PaymentModel ) {
			return '';
		}

		return PaymentsHelpers::get_payment_gateway_display_name( $payment );
	}

	/**
	 * Get the location display for email content.
	 *
	 * Returns a full list item with location info. For online locations
	 * with a meeting join URL, the location name becomes a clickable link.
	 * Returns empty string when no location is set.
	 *
	 * @since 1.4.0
	 *
	 * @param AppointmentModel      $appointment Appointment model.
	 * @param AbstractLocation|null $location    Location object.
	 *
	 * @return string Location list item HTML or empty string.
	 */
	private function get_location_display( $appointment, $location ) {

		if ( ! $location ) {
			return '';
		}

		$display_name = $location->get_display_name();

		$online_location = $appointment->online_location ?? [];

		// Check for online meeting join URL.
		$join_url = $online_location['join_url'] ?? $online_location['url'] ?? '';

		if ( ! empty( $join_url ) ) {
			$display_name = sprintf(
				'<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a>',
				esc_url( $join_url ),
				esc_html( $display_name )
			);
		} else {
			$display_name = esc_html( $display_name );
		}

		return sprintf(
			'<li>%1$s %2$s</li>',
			esc_html__( 'Location:', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			$display_name
		);
	}

	/**
	 * Email wrapper for branded admin notifications.
	 *
	 * Wraps content with a logo header, white content card, and minimal footer.
	 * Used by send_admin_email() only — customer-facing emails continue to use
	 * the simpler email_wrapper().
	 *
	 * @since 1.4.0
	 *
	 * @param string $content Email content.
	 *
	 * @return string Wrapped email content.
	 */
	private static function email_wrapper_admin( string $content ): string {

		// Brand tokens — mirror admin palette in assets/src/styles/admin/_variables.scss.
		$color_bg    = '#f0f0f1';
		$color_card  = '#ffffff';
		$color_text  = '#2c3338';
		$color_muted = '#646970';

		$logo_url  = SCBOOKINGS_PLUGIN_URL . 'assets/images/logo-email.png';
		$site_name = wp_specialchars_decode( get_bloginfo( 'name' ) );
		$site_url  = home_url();

		ob_start();
		?>

		<div style="padding: 30px 0; background-color: <?php echo esc_attr( $color_bg ); ?>; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">
			<div style="max-width: 600px; margin: 0 auto;">

				<div style="text-align: center; padding: 30px 0;">
					<img src="<?php echo esc_url( $logo_url ); ?>"
						width="330"
						alt="<?php esc_attr_e( 'Sugar Calendar Bookings', 'sugar-calendar-bookings-scheduling-appointments-lite' ); ?>"
						style="display: inline-block; width: 330px; max-width: 80%; height: auto;">
				</div>

				<div style="background-color: <?php echo esc_attr( $color_card ); ?>; padding: 40px; border-radius: 6px; box-shadow: 0px 2px 6px -1px rgba(0,0,0,0.08);">
					<div style="font-size: 16px; line-height: 1.5; color: <?php echo esc_attr( $color_text ); ?>;">
						<?php echo wp_kses_post( $content ); ?>
					</div>
				</div>

				<div style="text-align: center; padding: 30px 0; font-size: 14px; color: <?php echo esc_attr( $color_muted ); ?>; line-height: 1.4;">
					<?php
					echo wp_kses(
						sprintf(
							/* translators: %1$s - site name link. */
							__( 'This email was auto-generated and sent from %1$s.', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
							'<a href="' . esc_url( $site_url ) . '" style="color: ' . esc_attr( $color_muted ) . '; text-decoration: underline;">' . esc_html( $site_name ) . '</a>'
						),
						[
							'a' => [
								'href'  => [],
								'style' => [],
							],
						]
					);
					?>
				</div>

			</div>
		</div>

		<?php

		return ob_get_clean();
	}

	/**
	 * Email wrapper for consistent email styling.
	 *
	 * @since 1.0.0
	 *
	 * @param string $content Email content.
	 *
	 * @return string Wrapped email content.
	 */
	private static function email_wrapper( $content ) {

		ob_start();
		?>

		<div style="padding: 20px; background-color: #f0f0f0; font-family: -apple-system, system-ui, BlinkMacSystemFont, sans-serif;">
			<div style="background-color: #fff; padding: 30px; margin: 0px auto; max-width: 450px; box-shadow: 0px 2px 6px -1px rgba(0,0,0,0.2); border-radius: 6px;">
				<div style="font-size: 16px; line-height: 1.5;">
					<?php echo wp_kses_post( $content ); ?>
				</div>
			</div>
		</div>

		<?php

		return ob_get_clean();
	}

	/**
	 * Get email notifications configuration.
	 *
	 * @since 1.0.0
	 *
	 * @return array
	 */
	public function get_email_notifications() {

		return [
			'booking_pending_attendee'      => [
				'label'       => esc_html__( 'Pending Booking Email To Attendee', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				'description' => esc_html__( 'Email sent to attendee when booking is awaiting approval', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			],
			'booking_pending_employee'      => [
				'label'       => esc_html__( 'Pending Booking Email To Employee', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				'description' => esc_html__( 'Email sent to employee when booking is awaiting approval', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			],
			'booking_confirmation_attendee' => [
				'label'       => esc_html__( 'Booking Confirmation Email To Attendee', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				'description' => esc_html__( 'Confirmation email sent to attendee', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			],
			'booking_confirmation_employee' => [
				'label'       => esc_html__( 'Booking Confirmation Email To Employee', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				'description' => esc_html__( 'Confirmation email sent to employee', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			],
			'booking_update_attendee'       => [
				'label'       => esc_html__( 'Booking Rescheduled Email to Attendee', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				'description' => esc_html__( 'Email sent to attendee when their appointment was rescheduled', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			],
			'booking_update_employee'       => [
				'label'       => esc_html__( 'Booking Rescheduled Email to Employee', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				'description' => esc_html__( 'Email sent to employee when customer\'s appointment was rescheduled', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			],
			'booking_cancellation_attendee' => [
				'label'       => esc_html__( 'Booking Cancellation Email to Attendee', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				'description' => esc_html__( 'Email sent to attendee when their appointment got cancelled', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			],
			'booking_cancellation_employee' => [
				'label'       => esc_html__( 'Booking Cancellation Email to Employee', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				'description' => esc_html__( 'Email sent to employee when their appointment got cancelled', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			],
			'appointment_reminder_attendee' => [
				'label'       => esc_html__( 'Appointment Reminders to Attendee', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				'description' => esc_html__( 'Email reminder sent to attendee 24 hours before their appointment', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			],
			'appointment_reminder_employee' => [
				'label'       => esc_html__( 'Appointment Reminders to Employee', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				'description' => esc_html__( 'Email reminder sent to employee 24 hours before a customer appointment', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			],
			'payment_refund_attendee'       => [
				'label'       => esc_html__( 'Payment Refund Email to Customer', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				'description' => esc_html__( 'Email sent to customer when their payment is refunded', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
			],
		];
	}

	/**
	 * Get smart tags for email editor.
	 *
	 * @since 1.0.0
	 *
	 * @return array
	 */
	public function get_email_smart_tags() {

		return [
			'customer'    => [
				[
					'value' => 'customer_full_name',
					'label' => esc_html__( 'Customer Full Name', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
				[
					'value' => 'customer_email',
					'label' => esc_html__( 'Customer Email', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
				[
					'value' => 'customer_phone',
					'label' => esc_html__( 'Customer Phone', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
			],
			'employee'    => [
				[
					'value' => 'employee_full_name',
					'label' => esc_html__( 'Employee Full Name', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
			],
			'appointment' => [
				[
					'value' => 'start_date',
					'label' => esc_html__( 'Start Date', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
				[
					'value' => 'start_time',
					'label' => esc_html__( 'Start Time', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
				[
					'value' => 'end_time',
					'label' => esc_html__( 'End Time', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
				[
					'value' => 'appointment_admin_url',
					'label' => esc_html__( 'Appointment Admin URL', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
				[
					'value' => 'cancellation_url',
					'label' => esc_html__( 'Cancellation URL', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
			],
			'service'     => [
				[
					'value' => 'service_name',
					'label' => esc_html__( 'Service Name', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
				[
					'value' => 'service_duration',
					'label' => esc_html__( 'Service Duration', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
				[
					'value' => 'service_price',
					'label' => esc_html__( 'Service Price', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
				[
					'value' => 'service_locations',
					'label' => esc_html__( 'Service Locations', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
			],
			'order'       => [
				[
					'value' => 'order_summary_breakdown',
					'label' => esc_html__( 'Order Summary Breakdown', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
				[
					'value' => 'refund_amount',
					'label' => esc_html__( 'Refund Amount', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
				[
					'value' => 'payment_gateway',
					'label' => esc_html__( 'Payment Gateway', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
			],
			'general'     => [
				[
					'value' => 'site_name',
					'label' => esc_html__( 'Site Name', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
				[
					'value' => 'admin_email',
					'label' => esc_html__( 'Admin Email', 'sugar-calendar-bookings-scheduling-appointments-lite' ),
				],
			],
		];
	}
}
