<?php

declare(strict_types=1);

namespace Enot;

defined('ABSPATH') || exit;

require_once __DIR__ . '/header.php';

?>
<form id="telegram-form" method="post">
	<?php

	\wp_nonce_field('enot-admin-telegram-settings');

	?>

	<input type="hidden" name="enot-settings" value="telegram">

	<div class="row bg-white p-4 my-3 rounded-2">
		<h2><?php \esc_html_e('Token', 'error-monitor-and-notifier') ?> <sup class="text-white bg-danger p-1 fw-normal"><?php \esc_html_e('Premium only', 'error-monitor-and-notifier') ?></sup></h2>

		<p><?php \esc_html_e('Specify the Telegram bot token to send error and exception notifications.', 'error-monitor-and-notifier') ?></p>

		<div class="telegram-token">
			<label for="telegram-token"><?php \esc_html_e('Token', 'error-monitor-and-notifier') ?></label>
			<input type="text" id="telegram-token" value="" class="w-100" autocomplete="off" disabled>
		</div>

		<?php

		if (true) {

		?>
			<div class="mt-2">
				<label for="telegram-notify"><input type="checkbox" id="telegram-notify" value="1" disabled>
					<?php \esc_html_e('Enable Notifications', 'error-monitor-and-notifier') ?></label>
			</div>

			<div class="test-notification mt-4">
				<a href="javascript:void(0)" id="trigger-error" class="button" disabled><?php \esc_html_e('Test Telegram Notification', 'error-monitor-and-notifier'); ?></a>
			</div>

		<?php

		}

		?>


	</div>

	<div class="submit">
		<input type="submit" class="button button-primary" value="<?php echo \esc_attr(__('Save', 'error-monitor-and-notifier')) ?>" disabled>
	</div>
</form>

<div class="telegram-instruction">
	<ol>
		<li><?php

		echo \wp_kses(sprintf(
			// translators: 1: The Telegram BotFather link, 2: The BotFather bot name
			\__('Open a chat with the <a href="%1$s" target="_blank">@%2$s</a> bot', 'error-monitor-and-notifier'),
			\esc_url('https://t.me/BotFather'),
			\esc_html('BotFather')
		), 'post');

		?></li>
		<li>
			<?php echo \wp_kses(\__('Obtain the <strong>API Token</strong>', 'error-monitor-and-notifier'), 'default') ?>
			<ul style="list-style: inside">
				<li>
					<strong><?php \esc_html_e('New Bot', 'error-monitor-and-notifier') ?></strong>
					<ol>
						<li><?php

						// translators: The bot command
						echo \wp_kses(sprintf(\__('Send the <code>%s</code> command', 'error-monitor-and-notifier'), '/newbot'), 'post');

						?></li>
						<li><?php \esc_html_e('Set an arbitrary name for the bot', 'error-monitor-and-notifier') ?></li>
						<li><?php

						// translators: 1: The part of the bot name, 2: The bot name example
						echo \wp_kses(sprintf(\__('Set a username for the bot that ends with <span class="code">%1$s</span>, for example, <code>%2$s</code>', 'error-monitor-and-notifier'), 'bot', 'my_error_bot'), 'post');

						?></li>
						<li><?php \esc_html_e('Copy the token that BotFather provides', 'error-monitor-and-notifier') ?></li>
					</ol>
				</li>
				<li>
					<strong><?php \esc_html_e('Existing Bot', 'error-monitor-and-notifier') ?></strong>
					<ol>
						<li><?php

						// translators: The literally Telegram bot command
						echo \wp_kses(sprintf(\__('Send the <code>%s</code> command', 'error-monitor-and-notifier'), '/mybots'), 'post');

						?></li>
						<li><?php \esc_html_e('Select an existing bot from the list', 'error-monitor-and-notifier') ?></li>
						<li><?php

						// translators: The Telegram bot menu name
						echo \wp_kses(sprintf(\__('Click on the <strong>%s</strong> menu option', 'error-monitor-and-notifier'), 'API Token'), 'post');

						?></li>
						<li><?php \esc_html_e('Copy the token', 'error-monitor-and-notifier') ?></li>
					</ol>
				</li>
			</ul>
		</li>
		<li><?php

		echo \wp_kses(sprintf(
			// translators: 1: The button name, 2: The literally Telegram bot command
			\__('Find your bot in Telegram, open a conversation with it, and press the <strong>%1$s</strong> button (or send the <code>%2$s</code> command)', 'error-monitor-and-notifier'),
			'Start',
			'/start'
		), 'post');

		?></li>
		<li><?php

		echo \wp_kses(sprintf(
			// translators: 1: An example of the format of the Telegram bot command, 2: The fully Telegram bot command example
			\__('Send the <code>%1$s</code> command in the chat with your bot. For example: <code class="text-nowrap">%2$s</code>', 'error-monitor-and-notifier'),
			'/setup &lt;TOKEN&gt;',
			'/setup 123456789:ABCdefGhIJKlmNoPQRstuVWXyz'
		), 'post');
		?></li>
		<li><?php

		// translators: The tab name
		echo \wp_kses(sprintf(\__('Paste the copied token into the plugin settings on the %s tab', 'error-monitor-and-notifier'), \__('Telegram', 'error-monitor-and-notifier')), 'post');

		?></li>
		<li><?php

		// translators: The button name
		echo \wp_kses(sprintf(\__('Click the <strong>%s</strong> button', 'error-monitor-and-notifier'), \__('Save', 'error-monitor-and-notifier')), 'post');

		?></li>
	</ol>
</div>
</div><!-- .wrap -->
<?php

$ajax_trigger_error_nonce = \wp_create_nonce('enot_trigger_error');
