<?php
/**
 * @var array<int, array{tracking_number: string, tracking_url: string}> $tracking_data  .
 * @var WC_Order                                                          $order          .
 * @var bool                                                              $sent_to_admin  .
 * @var bool                                                              $plain_text     .
 * @var object                                                            $email          .
 *
 * @package DhlPolska\Shipment
 */

defined( 'ABSPATH' ) || exit;

if ( [] === $tracking_data ) {
	return;
}

if ( $plain_text ) {
	echo esc_html__( 'Śledzenie przesyłki DHL', 'dhl-polska' ) . "\n";
	foreach ( $tracking_data as $tracking_item ) {
		echo esc_html__( 'Numer śledzenia:', 'dhl-polska' ) . ' ';
		echo esc_html( $tracking_item['tracking_number'] ) . ' - ';
		echo esc_url( $tracking_item['tracking_url'] ) . "\n";
	}
	echo "\n";
	return;
}
?>
<table cellspacing="0" cellpadding="0" border="0" style="width: 100%; vertical-align: top; margin-bottom: 40px; padding: 0;">
	<tbody>
	<tr>
		<td valign="top" style="text-align: left; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; padding: 0;">
			<h3><?php esc_html_e( 'Śledzenie przesyłki DHL', 'dhl-polska' ); ?></h3>
			<?php foreach ( $tracking_data as $tracking_item ) : ?>
				<p>
					<?php esc_html_e( 'Numer śledzenia:', 'dhl-polska' ); ?>
					<a target="_blank" rel="noopener noreferrer" href="<?php echo esc_url( $tracking_item['tracking_url'] ); ?>">
						<?php echo esc_html( $tracking_item['tracking_number'] ); ?>
					</a>
				</p>
			<?php endforeach; ?>
		</td>
	</tr>
	</tbody>
</table>
