<?php

declare(strict_types=1);

if (!defined('ABSPATH')) {
	exit;
}

use Signocore\Multilanguage\Application\Constants;
use Signocore\Multilanguage\Support\FlagHelper;

/**
 * @var array<string, object> $activeLanguages
 * @var object|null $defaultLanguage
 * @var string $urlStrategy
 */

$strategyLabels = [
	Constants::URL_STRATEGY_DIRECTORY => __('Directory Prefix', 'signocore-multilanguage'),
	Constants::URL_STRATEGY_SUBDOMAIN => __('Subdomain', 'signocore-multilanguage'),
	Constants::URL_STRATEGY_DOMAIN => __('Custom Domains', 'signocore-multilanguage'),
];

$strategyExamples = [
	Constants::URL_STRATEGY_DIRECTORY => '/da/page-name/',
	Constants::URL_STRATEGY_SUBDOMAIN => 'da.example.com/page-name/',
	Constants::URL_STRATEGY_DOMAIN => 'example.dk/page-name/',
];

$defaultCode = $defaultLanguage !== null ? $defaultLanguage->code : '';
?>

<div class="sml-done-icon">
	<span class="dashicons dashicons-yes-alt"></span>
</div>

<h2 class="sml-wizard-title" style="text-align: center;"><?php esc_html_e('You\'re all set!', 'signocore-multilanguage'); ?></h2>
<p class="sml-wizard-subtitle" style="text-align: center;"><?php esc_html_e('Your multilingual site is ready. Here\'s a summary of your configuration.', 'signocore-multilanguage'); ?></p>

<div class="sml-done-summary">
	<div class="sml-done-section">
		<div class="sml-done-section-title"><?php esc_html_e('Languages', 'signocore-multilanguage'); ?></div>
		<div class="sml-done-languages">
			<?php foreach ($activeLanguages as $lang): ?>
				<div class="sml-done-language-tag <?php echo $lang->code === $defaultCode ? 'is-default' : ''; ?>">
					<?php echo FlagHelper::getFlagImg($lang->code, 20, 15, $lang->name); ?>
					<span><?php echo esc_html($lang->name); ?></span>
					<?php if ($lang->code === $defaultCode): ?>
						<span class="sml-default-badge"><?php esc_html_e('Default', 'signocore-multilanguage'); ?></span>
					<?php endif; ?>
				</div>
			<?php endforeach; ?>
		</div>
	</div>

	<div class="sml-done-section">
		<div class="sml-done-section-title"><?php esc_html_e('URL Strategy', 'signocore-multilanguage'); ?></div>
		<div class="sml-done-strategy">
			<strong><?php echo esc_html($strategyLabels[$urlStrategy] ?? $urlStrategy); ?></strong>
			&mdash;
			<code><?php echo esc_html($strategyExamples[$urlStrategy] ?? ''); ?></code>
		</div>
	</div>
</div>

<div class="sml-done-actions">
	<button type="button" id="sml-finish-btn" class="sml-btn sml-btn-primary">
		<?php esc_html_e('Go to Dashboard', 'signocore-multilanguage'); ?>
		<span class="sml-spinner"></span>
	</button>
	<a href="<?php echo esc_url(admin_url('post-new.php')); ?>" class="sml-btn sml-btn-outline">
		<?php esc_html_e('Translate your first post', 'signocore-multilanguage'); ?>
	</a>
</div>
